Skip to content
Snippets Groups Projects
ex2_3_5.py 815 B
Newer Older
  • Learn to ignore specific revisions
  • bjje's avatar
    bjje committed
    # Exercise 4.2.5
    
    # requires data from exercise 4.2.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([])
    
    Stas Syrota's avatar
    Stas Syrota committed
                # ylim(0,X.max()*1.1)
                # xlim(0,X.max()*1.1)
    
    bjje's avatar
    bjje committed
    legend(classNames)
    
    show()
    
    
    Stas Syrota's avatar
    Stas Syrota committed
    print("Ran Exercise 4.2.5")