[英]ValueError: Unknown label type: 'continuous', SVC Sklearn
I am trying to use this library from sklearn named SVC. 我正在尝试使用来自名为SVC的sklearn的该库。
However I have this error when I run my program: 但是,当我运行程序时出现此错误:
ValueError: Unknown label type: 'continuous'
I do not know if there is a regressor library for Support Vector Regressor, this is the only I have found so far. 我不知道是否有支持向量回归器的回归器库,这是我到目前为止发现的唯一库。 Here is my code:
这是我的代码:
import sklearn
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import numpy as np
from sklearn.svm import SVC
X, Y = get_data(filename)
X_train, X_test, y_train, y_test = train_test_split(X, Y, random_state=33)
svc = SVC()
svc.fit(X_train, y_train)
print(svc.score(X_train, y_train))
print(svc.score(X_test, y_test))
Thanks. 谢谢。
SVC is a classifier so will not support continous values in targets. SVC是分类器,因此将不支持目标中的连续值。 What you need is SVR .
您需要的是SVR 。 Just replace all occurences of SVC with SVR and you are good to go.
只需用SVR替换所有出现的SVC,您就可以开始了。
from sklearn.svm import SVR
svr = SVR()
svr.fit(X_train, y_train)
print(svr.score(X_train, y_train))
print(svr.score(X_test, y_test))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.