<jupyter_start><jupyter_text>Features Table   Let's Label our Data based on Maturity Group ( Method 1 using Literature Thresholds)<jupyter_code>thresholds = {'Maturity Group 1': [84.74,23.53,15.41,11.11,11.91],
        'Maturity Group 2': [96.83,26.14,15.06,10.9,11.30] }

thresholds=pd.DataFrame(thresholds,
    index=['Formant 2','Formant 1','Max Freq','Min Freq','Finish Freq'], 
                        columns = ['Maturity Group 1', 'Maturity Group 2'])

thresholds_mean=np.mean(thresholds, axis=0)
Fmean=np.mean(F[['formant2','formant1','f0max','f0min','f0final']],axis=1)
t=np.empty(np.shape(F)[0])
t[:] = np.nan
t[Fmean<thresholds_mean['Maturity Group 1']]=0
t[Fmean>thresholds_mean['Maturity Group 1']]=1
t=pd.DataFrame(t)
t.columns=['Maturity Group Method 1']
t=t.astype('int32')
F.reset_index()
F.insert(3,"Maturity Group Method 1",t)<jupyter_output><empty_output><jupyter_text>Let's Add an Additional Alternative Labeling based on Maturity Group ( Method 2 using K means and check with PCA)<jupyter_code>df=F.drop(['filename','Maturity Group Method 1'],axis=1)
pca = PCA(2)
projected = pca.fit_transform(df)
from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=2)
kmeans.fit(df)
y_kmeans = kmeans.predict(df)
y_kmeans=pd.DataFrame(y_kmeans)
F.insert(4,"Maturity Group Method 2",y_kmeans)<jupyter_output><empty_output><jupyter_text>We can see clear signs of clustering with 2 centroids<jupyter_code>plt.scatter(projected[:, 0], projected[:, 1], c=y_kmeans.values)<jupyter_output><empty_output><jupyter_text>Comparing the two methods we see nearly 75% overlap which is a good sign<jupyter_code>from sklearn.metrics import confusion_matrix
conf=confusion_matrix(t, y_kmeans)
np.trace(conf)/sum(sum(conf))
F<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup