Predicting probability

后端 未结 2 569
猫巷女王i
猫巷女王i 2021-01-07 00:42

Trying to use SVC from sklearn to do a classification problem. Given a bunch of data, and information telling me whether some subject is in a certa

相关标签:
2条回答
  • Always set the parameters before fit.

    from sklearn.svm import SVC
    clf=SVC(probability=True)
    clf=clf.fit(X,Y)
    print clf.predict_proba(W)
    
    0 讨论(0)
  • 2021-01-07 01:03

    You have to construct the SVC object with probability=True

    from sklearn.svm import SVC
    clf=SVC(probability=True)
    clf.fit(X,Y)
    print clf.predict_proba(W) #No error
    

    Your code creates a SVC with probability estimates and discards it (as you do not store it in any variable) and use some previous SVC stored in clf (without probability)

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