AttributeError:模块“sklearn.metrics"没有属性“calinski_harabaz_score" [英] AttributeError: module 'sklearn.metrics' has no attribute 'calinski_harabaz_score'

查看:85
本文介绍了AttributeError:模块“sklearn.metrics"没有属性“calinski_harabaz_score"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to apply this code from sklearn documentation.

我收到一个错误:AttributeError:模块sklearn.metrics"没有属性calinski_harabaz_score"

I got an error: AttributeError: module 'sklearn.metrics' has no attribute 'calinski_harabaz_score'

这是我的版本:

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

Python version 3.5.2 | packaged by conda-forge | (default, Jul 26 2016, 01:37:38)

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

[GCC 4.2.1 Compatible Apple 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,这个功能是最近才添加的.

Upgrade scikit-learn, this function was only added recently.

这篇关于AttributeError:模块“sklearn.metrics"没有属性“calinski_harabaz_score"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆