Skip to content
Snippets Groups Projects
Select Git revision
  • ab5be3106cdc4b5dc30ee68dfa953c397c0be855
  • main default protected
  • s2025dev
  • plot-fixes
  • Fall2024
5 results

ex2_2_2.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ex2_3_5.py 777 B
    # Exercise 2.3.5
    # (requires data from exercise 2.3.1)
    from ex2_3_1 import *
    from matplotlib.pyplot import (
        figure,
        legend,
        plot,
        show,
        subplot,
        xlabel,
        xticks,
        ylabel,
        yticks,
    )
    
    figure(figsize=(12, 10))
    for m1 in range(M):
        for m2 in range(M):
            subplot(M, M, m1 * M + m2 + 1)
            for c in range(C):
                class_mask = y == c
                plot(np.array(X[class_mask, m2]), np.array(X[class_mask, m1]), ".")
                if m1 == M - 1:
                    xlabel(attributeNames[m2])
                else:
                    xticks([])
                if m2 == 0:
                    ylabel(attributeNames[m1])
                else:
                    yticks([])
                                
    legend(classNames)
    
    show()
    
    print("Ran Exercise 2.3.5")