小编los*_*_19的帖子

使用python中的scikit包在SVM中获得负的alpha值

我在python中使用scikit包实现SVM.我在解释plot_separating_hyperplane.py中的"alpha i"值时遇到了困难

import numpy as np
import pylab as pl
from sklearn import svm

# we create 40 separable points
np.random.seed(0)
X = np.r_[np.random.randn(20, 2) - [2, 2], np.random.randn(20, 2) + [2, 2]]
Y = [0] * 20 + [1] * 20

# fit the model
clf = svm.SVC(kernel='linear')
clf.fit(X, Y)
print clf.support_vectors_
#support_vectors_ prints the support vectors
print clf.dual_coef_
#dual_coef_ gives us the "alpha i, y i" value for all support vectors
Run Code Online (Sandbox Code Playgroud)

样本输出

Dual_coef_ = [[ 0.04825885 …
Run Code Online (Sandbox Code Playgroud)

python machine-learning convex-optimization svm scikit-learn

5
推荐指数
1
解决办法
1654
查看次数

使用条件随机场的多标签分类

是否可以使用条件随机场进行多标签分类?我在https://pystruct.github.io/user_guide.html看到了 python CRF 实现,但无法找到进行多标签分类的方法。

python classification machine-learning crf multilabel-classification

5
推荐指数
1
解决办法
2478
查看次数

如何使用scikit规范化核密度估计?

我正在使用KDE进行多类分类.我正在使用scikit实现它.如网站上所述,点x的KDE定义为,

我应该在比较不同类别的不同内核密度估计值时对结果进行标准化吗?

KDE的链接:http:
//scikit-learn.org/stable/modules/density.html#kernel-density-estimation

python machine-learning kernel-density scikit-learn

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

随机梯度增强提供了不可预测的结果

我正在使用用于Python的Scikit模块来实现随机梯度增强。我的数据集具有2700个实例和1700个特征(x),并包含二进制数据。我的输出向量是“ y”,并且包含0或1(二进制分类)。我的代码是

gb = GradientBoostingClassifier(n_estimators=1000,learn_rate=1,subsample=0.5) gb.fit(x,y)

print gb.score(x,y)

一旦运行,它的精度为1.0(100%),有时我的精度约为0.46(46%)。知道为什么其性能如此巨大的差距吗?

python machine-learning scikits scikit-learn

0
推荐指数
1
解决办法
1536
查看次数