微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

SVM 图超平面可视化

如何解决SVM 图超平面可视化

我一直在搜索如何可视化用于文本分类的超平面支持向量机方法,但我真的不知道如何使用管道和 tfidfvectorizer 可视化数据。

train,test = train_test_split(df,test_size=0.2,random_state=1)
x_train = train['data'].values
x_test = test['data'].values
y_train = train['Final']
y_test = test['Final']
kfolds = StratifiedKFold(n_splits=10,shuffle=True,random_state=1)
vectorizer = TfidfVectorizer()
np.random.seed(1) 

pipeline_rbf = make_pipeline(vectorizer1,SVC(kernel="rbf"))
pipeline_rbf.fit(x_train,y_train)

y_pred=pipeline_rbf.predict(x_test)
from sklearn.metrics import classification_report,confusion_matrix
print(confusion_matrix(y_test,y_pred))
print(classification_report(y_test,y_pred))

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。