'>=' not supported between instances of 'str' and 'int' 利用PCA报错解决

发布时间:2024-11-11 17:42

最新推荐文章于 2024-09-22 22:55:12 发布

共觞 于 2018-07-16 17:27:16 发布

CA为主成分分析库

导入方式:from sklearn.decomposition import PCA

其中默认有三个主要参数:


n_components

此参数可以帮我们指定希望PCA降维后的特征维度数目,可以是int型的数字123,也可以是阈值百分比,类似98%,也可以指定为string类型,MLE


copy

类型:bool,True或者False,缺省时默认为True,
意义:表示是否在运行算法时,将原始数据复制一份。如果为True,则运行PCA算法后,原始数据的值不会有任何改变。因为是在原始数据的副本上进行运算的。


whiten

类型:bool,缺省时默认为False
意义:白化,目的是每个特征具有相同的方差。


svd_solver

指定奇异值分解SVD的方法,有4个可以选择的值:{‘auto’, ‘full’, ‘arpack’, ‘randomized’,}具体详见【http://www.cnblogs.com/pinard/p/6243025.html】

但是在pca = PCA(n_components = ‘mle’)(MLE即极大似然估计)时报错

TypeError: ‘>=’ not supported between instances of ‘str’ and ‘int’

通过查看help(PCA)发现,当n_components == ‘mle’时,需要和参数svd_solver一起使用,且svd_solver需要选择full参数


即pca = PCA(n_components = ‘mle’,svd_solver=’full’)才可执行成功

网址:'>=' not supported between instances of 'str' and 'int' 利用PCA报错解决 https://www.yuejiaxmz.com/news/view/35488

相关内容

‘str‘ object cannot be interpreted as an integer
【Java报错已解决】Driver class ‘net.sourceforge.jtds.jdbc.Driver’ could not be found, make sure the
Database Exception – yii\db\Exception
Python中的遇到的错误(持续更新)
Life and journey(生活和旅游)作文(精选43篇)
关于养宠物的英语作文27篇
关于提高学习效率的英语作文(通用5篇)
Dullpain on Steam
【指南解读】2022ESPEN家庭肠内营养实践指南解读
让生活更美好的 50 个小贴士

随便看看