当前位置: 首页>>代码示例>>Python>>正文


Python LinearSVC.intercept_方法代码示例

本文整理汇总了Python中sklearn.svm.LinearSVC.intercept_方法的典型用法代码示例。如果您正苦于以下问题:Python LinearSVC.intercept_方法的具体用法?Python LinearSVC.intercept_怎么用?Python LinearSVC.intercept_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sklearn.svm.LinearSVC的用法示例。


在下文中一共展示了LinearSVC.intercept_方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: print

# 需要导入模块: from sklearn.svm import LinearSVC [as 别名]
# 或者: from sklearn.svm.LinearSVC import intercept_ [as 别名]
		("scaler", scaler),
		("linear_svc", svm_clf2)
	))

scaled_svm_clf2.fit(X, y)
scaled_svm_clf1.fit(X, y)

print(scaled_svm_clf2.predict([[5.5, 1.7]]))
print(scaled_svm_clf1.predict([[5.5, 1.7]]))


b1 = svm_clf1.decision_function([-scaler.mean_ / scaler.scale_])
b2 = svm_clf2.decision_function([-scaler.mean_ / scaler.scale_])
w1 = svm_clf1.coef_[0] / scaler.scale_
w2 = svm_clf2.coef_[0] / scaler.scale_
svm_clf1.intercept_ = np.array([b1])
svm_clf2.intercept_ = np.array([b2])
svm_clf1.coef_ = np.array([w1])
svm_clf2.coef_ = np.array([w2])

t = y * 2 - 1
support_vectors_idx1 = (t * (X.dot(w1) + b1) < 1).ravel()
support_vectors_idx2 = (t * (X.dot(w2) + b2) < 1).ravel()
svm_clf1.support_vectors_ = X[support_vectors_idx1]
svm_clf2.support_vectors_ = X[support_vectors_idx2]

plt.figure(figsize=(12, 3.2))
plt.subplot(121)
plt.plot(X[:, 0][y==1], X[:, 1][y==1], "g^", label="Iris-Virginia")
plt.plot(X[:, 0][y==0], X[:, 1][y==0], "bs", label="Iris-Versicolor")
plot_svc_decision_boundary(svm_clf1, 4, 6)
开发者ID:stonecoder19,项目名称:machine_learning,代码行数:33,代码来源:ch05_support_vector_machine.py


注:本文中的sklearn.svm.LinearSVC.intercept_方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。