为什么我的肘关节功能没有定义?

时间:2016-11-29 14:03:33

标签: python python-2.7

我成功创建了我的函数但是当我调用它时出现错误:

  

未定义的功能'肘'

出了什么问题?

import pandas as pd
import matplotlib.pyplot as plt
import seaborn
from sklearn.cluster import KMeans
import numpy as np
from scipy.spatial.distance import cdist, pdist

def eblow(df,n):
    kMeansVar = [KMeans(n_clusters=NUM_CLUSTERS, n_jobs=1, random_state=0, n_init=1, verbose=True).fit(df) for k in range(1, n)]
    centroids = [X.cluster_centers_ for X in kMeansVar]
    k_euclid = [cdist(df, cent) for cent in centroids]
    dist = [np.min(ke, axis=1) for ke in k_euclid]
    wcss = [sum(d**2) for d in dist]
    tss = sum(pdist(df)**2)/df.shape[0]
    bss = tss - wcss
    plt.plot(bss)
plt.show()

X=np.random.rand(60,45)
el=elbow(X,30)

1 个答案:

答案 0 :(得分:4)

你定义了eblow,但我没有看到功能肘。