'module' object has no attribute 'svc'

前端 未结 6 423
野性不改
野性不改 2021-01-19 02:14
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.cros         


        
相关标签:
6条回答
  • 2021-01-19 02:48

    Your problem originate from the fact that you call:

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

    with lowercase svc in svm.svc, which should be svm.SVC. Additionally, as Alex Hall noted, you call c=1 with in lower case which should be C=1. Giving:

    model = svm.SVC(kernel='linear', C=1, gamma=1) 
    
    0 讨论(0)
  • 2021-01-19 02:54

    You can try

    from sklearn.svm import SVC
    

    then

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

    worked fine for me

    0 讨论(0)
  • 2021-01-19 03:04

    Im using sklearn version 0.18

    my problem was solved

    from sklearn import svm
    

    change for

    from sklearn.svm import SVC
    
    0 讨论(0)
  • 2021-01-19 03:05
    svc = svm.SVC(kernel='linear', C=1, gamma=1)
    

    Note that capital C.

    See the docs.

    0 讨论(0)
  • 2021-01-19 03:05

    You can try this:

    from sklearn import svm
    clf = svm.SVC(kernel='linear', C=1,gamma=1)
    

    'C' must be in capital

    0 讨论(0)
  • 2021-01-19 03:08

    The error come from you code below:

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

    After you use :

    svc = svm.SVC()
    

    svc is an object produced by svm.SVC(). So I guess what you want is :

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

    or

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

    Wish this could help~

    0 讨论(0)
提交回复
热议问题