The required data is an numpyarray (in this case, the "matrix") with the form (n_samples, n_features).
csv-file numpy.genfromtxt. . .
csv ( file.csv ):
a,b,c,target
1,1,1,0
1,0,1,0
1,1,0,1
0,0,1,1
0,1,1,0
,
data = np.genfromtxt('file.csv', skip_header=True)
skip_header True, ( a,b,c,target). . numpy.
. - () ( ).
( ) ( ),
features = data[:, :3]
targets = data[:, 3]
CSV :
features = array([[ 0, 1, 0],
[ 1, 1, 0],
[ 0, 1, 1],
[ 0, 0, 0]])
targets = array([ 1, 1, 1, 0])
- fit. svm-,
>>> from sklearn.svm import LinearSVC
>>> linear_svc_model = LinearSVC()
>>> linear_svc_model.fit(X=features, y=targets)