小编use*_*472的帖子

你如何从sklearn.cluster.ward_tree可视化病房树?

在sklearn中,实现了一种凝聚聚类算法,病房方法最小化方差.通常sklearn有许多很好的用法示例,但我找不到如何使用此函数的示例.

基本上我的问题是根据我的数据的聚类绘制树形图,但我不理解函数的输出.该文件说,它返回的儿童,组件的数量,叶片数和每个节点的父母.

然而,对于我的数据样本,结果没有任何意义.对于已使用连接矩阵聚类的(32,542)矩阵,这是输出:

>>> wt = ward_tree(mymat, connectivity=connectivity, n_clusters=2)

>>> mymat.shape
(32, 542)
>>> wt
(array([[16,  0],
       [17,  1],
       [18,  2],
       [19,  3],
       [20,  4],
       [21,  5],
       [22,  6],
       [23,  7],
       [24,  8],
       [25,  9],
       [26, 10],
       [27, 11],
       [28, 12],
       [29, 13],
       [30, 14],
       [31, 15],
       [34, 33],
       [47, 46],
       [41, 40],
       [36, 35],
       [45, 44],
       [48, 32],
       [50, 42],
       [38, 37],
       [52, 43],
       [54, 39],
       [53, 51],
       [58, 55],
       [56, 49],
       [60, 57]]), 1, 32, array([32, …
Run Code Online (Sandbox Code Playgroud)

python machine-learning hierarchical-clustering scikit-learn

9
推荐指数
1
解决办法
4459
查看次数

如何更改在Visual Studio 2017中运行的R版本?

我想运行R版本3.4而不是当前版本3.3.2,并且不知道从哪里开始.

尽管如此,网络搜索仍然很少,因为我不习惯在Windows 10平台上工作,也不完全了解Visual Studio中的组件是如何分层的.

r rtvs visual-studio-2017

3
推荐指数
2
解决办法
1756
查看次数

使用sklearn.feature_extraction.text CountVectorizer时从文件中读取文档

我可以使用文档中的示例中的代码,其中fit_transform()函数的输入是一个句子列表,即:

corpus = [
   'this is the first document',
   'this is the second second document',
   'and the third one',
   'is this the first document?'
]
Run Code Online (Sandbox Code Playgroud)

X = vectorizer.fit_transform(语料库)

并获得预期的数据.但是,当我尝试用文件列表或文件对象替换语料库时,文档建议它可以是:

"fit(raw_documents,y = None)

Learn a vocabulary dictionary of all tokens in the raw documents.
Parameters :    
raw_documents : iterable
    An iterable which yields either str, unicode or file objects.
Returns :   
self :
Run Code Online (Sandbox Code Playgroud)

"

..我认为,对管道的理解有些缺失.给定一个我想要CountVectorize的文件目录,我该怎么做?如果我尝试提供文件对象列表,如[open(file,'r')],我得到的错误信息是文件对象没有较低的功能.

python-2.7 scikit-learn

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

为什么R会像它一样绕自然对数?

我对R的不同感到困惑:

log(0.0001)/0.0001
-92103.4
Run Code Online (Sandbox Code Playgroud)

并且,例如,谷歌计算器渲染:

 ln(0.0001)/0.0001
 -92103.4037198
Run Code Online (Sandbox Code Playgroud)

为什么四舍五入如此不同?

r natural-logarithm

-2
推荐指数
1
解决办法
75
查看次数