Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:模块';sklearn.metrics';没有属性';卡林斯基-哈拉巴兹评分';_Python_Scikit Learn - Fatal编程技术网

Python 属性错误:模块';sklearn.metrics';没有属性';卡林斯基-哈拉巴兹评分';

Python 属性错误:模块';sklearn.metrics';没有属性';卡林斯基-哈拉巴兹评分';,python,scikit-learn,Python,Scikit Learn,我正在尝试应用sklearn文档中的代码 我得到一个错误:AttributeError:module'sklearn.metrics'没有属性'calinski_harabaz_score' 这是我的版本: Python版本3.5.2 |由conda forge |打包(默认,2016年7月26日,01:37:38) [GCC 4.2.1兼容苹果LLVM 6.0(clang-600.0.54)] 我使用的代码是: from sklearn import metrics from sklearn.

我正在尝试应用sklearn文档中的代码

我得到一个错误:AttributeError:module'sklearn.metrics'没有属性'calinski_harabaz_score'

这是我的版本:

Python版本3.5.2 |由conda forge |打包(默认,2016年7月26日,01:37:38)

[GCC 4.2.1兼容苹果LLVM 6.0(clang-600.0.54)]

我使用的代码是:

from sklearn import metrics
from sklearn.metrics import pairwise_distances
from sklearn import datasets
dataset = datasets.load_iris()
X = dataset.data
y = dataset.target

import numpy as np
from sklearn.cluster import KMeans
kmeans_model = KMeans(n_clusters=3, random_state=1).fit(X)
labels = kmeans_model.labels_
metrics.calinski_harabaz_score(X, labels) 

谢谢

升级scikit learn,此功能是最近才添加的。

请使用

metrics.calinski_harabasz_分数(X,标签)

然后,完成。

在康达升级scikit learn时,我解决了同样的问题。非常感谢。