美文网首页
python的一个SVM多分类例子

python的一个SVM多分类例子

作者: 小小杨树 | 来源:发表于2021-11-15 15:28 被阅读0次

    一个SVM的简单例子可以从中窥探奥秘,大家可以更改X的数值,更改Y 的标签名

    import numpy as np
    from sklearn.svm import SVC
    
    X = np.array([[0, 1], [2, 3], [4, 5], [6, 7]])
    print(X)
    y = np.array([1, 2, 3, 4])
    clf = SVC()
    clf.fit(X, y)
    SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
        decision_function_shape='ovr', degree=3, gamma='auto', kernel='rbf',
        max_iter=-1, probability=False, random_state=None, shrinking=True,
        tol=0.001, verbose=False)
    print(clf.predict([[2.1, 3.9]]))
    

    相关文章

      网友评论

          本文标题:python的一个SVM多分类例子

          本文链接:https://www.haomeiwen.com/subject/dujqtrtx.html