分类问题
类别是固定的,假设有3类,更改输入得到类别在这三类之间:
import numpy as np
import matplotlib.pyplot as plt
from sklearn import svm
a = np.array([[0, 1],
[2, 3],
[4, 5],
[6, 7]
])
b = np.array([0, 1, 2, 3])
clf = svm.SVC(C=0.5, kernel='linear', decision_function_shape='ovr')
clf.fit(a, b, sample_weight=None)
print(clf.predict([[2, 1]]))
'''
[1]
'''
回归是得到一个模型,比如y = ax + b
回归得到值随x变化而变化。
import numpy as np
import matplotlib.pyplot as plt
from sklearn import svm
X = [[0, 0], [2, 2]]
y = [0.5, 2.5]
clf = svm.SVR(kernel='linear')
clf.fit(X, y)
print(clf.predict([[2, 1]]))
来源:CSDN
作者:qq_43043256
链接:https://blog.csdn.net/qq_43043256/article/details/104307195