Skip to content
Snippets Groups Projects
ex2_3_4.py 725 B
Newer Older
  • Learn to ignore specific revisions
  • bjje's avatar
    bjje committed
    # requires data from exercise 4.1.1
    
    bjje's avatar
    bjje committed
    import matplotlib.pyplot as plt
    
    bjje's avatar
    bjje committed
    
    
    bjje's avatar
    bjje committed
    plt.figure(figsize=(14, 7))
    
    bjje's avatar
    bjje committed
    for c in range(C):
    
    bjje's avatar
    bjje committed
        plt.subplot(1, C, c + 1)
    
    Stas Syrota's avatar
    Stas Syrota committed
        class_mask = y == c  # binary mask to extract elements of class c
    
    bjje's avatar
    bjje committed
        # or: class_mask = nonzero(y==c)[0].tolist()[0] # indices of class c
    
    Stas Syrota's avatar
    Stas Syrota committed
    
    
    bjje's avatar
    bjje committed
        plt.boxplot(X[class_mask, :])
    
    Stas Syrota's avatar
    Stas Syrota committed
        # title('Class: {0}'.format(classNames[c]))
    
    bjje's avatar
    bjje committed
        plt.title("Class: " + classNames[c])
        plt.xticks(
    
    Stas Syrota's avatar
    Stas Syrota committed
            range(1, len(attributeNames) + 1), [a[:7] for a in attributeNames], rotation=45
        )
        y_up = X.max() + (X.max() - X.min()) * 0.1
        y_down = X.min() - (X.max() - X.min()) * 0.1
    
    bjje's avatar
    bjje committed
        plt.ylim(y_down, y_up)
    
    bjje's avatar
    bjje committed
    
    
    bjje's avatar
    bjje committed
    plt.show()
    
    bjje's avatar
    bjje committed