小编Rez*_*wan的帖子

Sklearn:每个群集的质心的平均距离

如何找到质心到每个簇中所有数据点的平均距离.我能够从每个聚类的质心中找到每个点(在我的数据集中)的欧氏距离.现在我想找到质心到每个簇中所有数据点的平均距离.计算每个质心的平均距离的好方法是什么?到目前为止我做到了这一点..

def k_means(self):
    data = pd.read_csv('hdl_gps_APPLE_20111220_130416.csv', delimiter=',')
    combined_data = data.iloc[0:, 0:4].dropna()
    #print combined_data
    array_convt = combined_data.values
    #print array_convt
    combined_data.head()


    t_data=PCA(n_components=2).fit_transform(array_convt)
    #print t_data
    k_means=KMeans()
    k_means.fit(t_data)
    #------------k means fit predict method for testing purpose-----------------
    clusters=k_means.fit_predict(t_data)
    #print clusters.shape
    cluster_0=np.where(clusters==0)
    print cluster_0

    X_cluster_0 = t_data[cluster_0]
    #print X_cluster_0


    distance = euclidean(X_cluster_0[0], k_means.cluster_centers_[0])
    print distance


    classified_data = k_means.labels_
    #print ('all rows forst column........')
    x_min = t_data[:, 0].min() - 5
    x_max = t_data[:, 0].max() - 1
    #print ('min is ')
    #print x_min
    #print ('max is ')
    #print …
Run Code Online (Sandbox Code Playgroud)

python numpy cluster-analysis k-means scikit-learn

8
推荐指数
2
解决办法
1万
查看次数

如何在 gitlab-ci 脚本中执行 git 命令

我想更改文件并在 gitlab-ci 管道内提交更改

我尝试在脚本中编写普通的 git 命令

script:
    - git clone git@gitlab.url.to.project.git
    - cd project file
    - touch test.txt
    - git config --global user.name "${GITLAB_USER_NAME}"
    - git config --global user.email "${GITLAB_USER_EMAIL}"
    - git add .
    - git commit -m "testing autocommit"
    - git push
Run Code Online (Sandbox Code Playgroud)

我找不到命令 git 或类似的东西,我知道它与标签有关,但是如果我尝试添加 git 标签,它会说没有活动的跑步者。有人知道如何在 gitlab-ci 上运行 git 命令吗?

gitlab-ci

3
推荐指数
1
解决办法
4965
查看次数