Jose Nieto
Jose Nieto

Reputation: 39

ValueError: Unknown label type: 'continuous', SVC Sklearn

I am trying to use this library from sklearn named SVC.

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.

Upvotes: 3

Views: 10596

Answers (1)

Vivek Kumar
Vivek Kumar

Reputation: 36619

SVC is a classifier so will not support continous values in targets. What you need is SVR. Just replace all occurences of SVC with SVR and you are good to go.

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))

Upvotes: 14

Related Questions