Skip to content
Snippets Groups Projects
ex2_3_5.py 777 B
Newer Older
  • Learn to ignore specific revisions
  • # Exercise 2.3.5
    # (requires data from exercise 2.3.1)
    
    Stas Syrota's avatar
    Stas Syrota committed
    from matplotlib.pyplot import (
        figure,
        legend,
        plot,
        show,
        subplot,
        xlabel,
        xticks,
        ylabel,
        yticks,
    )
    
    bjje's avatar
    bjje committed
    
    
    Stas Syrota's avatar
    Stas Syrota committed
    figure(figsize=(12, 10))
    
    bjje's avatar
    bjje committed
    for m1 in range(M):
        for m2 in range(M):
    
    Stas Syrota's avatar
    Stas Syrota committed
            subplot(M, M, m1 * M + m2 + 1)
    
    bjje's avatar
    bjje committed
            for c in range(C):
    
    Stas Syrota's avatar
    Stas Syrota committed
                class_mask = y == c
                plot(np.array(X[class_mask, m2]), np.array(X[class_mask, m1]), ".")
                if m1 == M - 1:
    
    bjje's avatar
    bjje committed
                    xlabel(attributeNames[m2])
                else:
                    xticks([])
    
    Stas Syrota's avatar
    Stas Syrota committed
                if m2 == 0:
    
    bjje's avatar
    bjje committed
                    ylabel(attributeNames[m1])
                else:
                    yticks([])
    
    bjje's avatar
    bjje committed
    legend(classNames)
    
    show()