标签:png span 分享 lob rand color inf numpy sha
import mglearn from sklearn.datasets import make_blobs import matplotlib.pyplot as plt import numpy as np from sklearn.svm import LinearSVC X,Y=make_blobs(random_state=42) linear_svm=LinearSVC().fit(X,Y) mglearn.discrete_scatter(X[:,0],X[:,1],Y) coef=linear_svm.coef_ #shape(3个类别,2个特征) intercept=linear_svm.intercept_ #shape(3个类别) color1=[‘b‘,‘r‘,‘g‘] for c,i,co in zip(coef,intercept,color1): plt.plot(line,-(line*c[0]+i)/c[1],c=co) #就是决策边界 C[0]就是第一个类别的第一个特征 plt.ylim(-10,15) plt.xlim(-10,8) plt.xlabel(‘feature 0‘) plt.ylabel(‘feature 1‘)
标签:png span 分享 lob rand color inf numpy sha
原文地址:https://www.cnblogs.com/vivianzy1985/p/9228552.html