Elbow Vizualizer Curves

11 views
Skip to first unread message

Jon Dickens

unread,
Dec 4, 2023, 5:04:09 PM12/4/23
to Yellowbrick
I would like to use a modified version of this function to take as input two distinct X_Arrays and then plot two comparative curves on the same set of axes.
    
def Visualize_Elbow_YB(X_Array , y , Metric):
   
    from sklearn.cluster import KMeans

    from yellowbrick.cluster import KElbowVisualizer
   
    print('Specify the Metric Method to be used: [ silhouette, distortion , calinski_harabasz ]')
    print()
   
    KM_Model = KMeans(n_init = 'auto' , random_state = 42)    # Instantiate the KMeans Clustering Model and Visualizer
   
    E_Visualizer = KElbowVisualizer(KM_Model ,                # The K_Means Model for Cluster Analysis
                                    k       = (2 , 12) ,      # Specify the Range of K Values ( Clusters ) to be used
                                    metric  = Metric ,        # Specify the Metric Method to be used
                                    timings = False
                                   )
   
    E_Visualizer.fit(X_Array) # Fit the Elbow Visualizer to the Data
   
    E_Visualizer.show()       # Finalize and Display the Graph

    return
Reply all
Reply to author
Forward
0 new messages