Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'module' object has no attribute 'svc'

import pandas as pd
from sklearn import svm

### Read the CSV ###
df = pd.read_csv('C:/Users/anagha/Documents/Python Scripts/sampleData.csv')
df

from sklearn.cross_validation import train_test_split
train, test = train_test_split(df, train_size = 0.8)
train
test

x_column=['Userid','day_of_week','hour_of_day','minute_of_hour']
y_column = ['thermostat']

svc = svm.SVC()
model = svm.svc(kernel='linear', c=1, gamma=1) 

I'm getting an error AttributeError: 'module' object has no attribute 'svc'. Tried many techniques, but none of them are working. I'm new to python, and would really appreciate the help

like image 261
Anagha Avatar asked Nov 15 '16 07:11

Anagha


2 Answers

svc = svm.SVC(kernel='linear', C=1, gamma=1)

Note that capital C.

See the docs.

like image 147
Alex Hall Avatar answered Oct 06 '22 00:10

Alex Hall


You can try

from sklearn.svm import SVC

then

model = SVC(kernel='linear', c=1, gamma=1)

worked fine for me

like image 31
Anush Avatar answered Oct 06 '22 00:10

Anush