Eu escrevi:
porco1 = [1, 1, 0, 1];
porco2 = [0, 1, 0, 1];
porco3 = [0, 0, 0, 1];
porco4 = [0, 0, 0, 0];
porco5 = [0, 0, 0, 1];
porco6 = [1, 0, 0, 0];
porco7 = [0, 0, 0, 1];
porco8 = [1, 0, 0, 0];
porco9 = [0, 1, 0, 1];
porco10 = [1, 1, 0, 0];
cachorro1 = [1, 0, 1];
cachorro2 = [0, 1, 1];
cachorro3 = [1, 1, 1];
cachorro4 = [1, 0, 1];
cachorro5 = [0, 1, 1];
cachorro6 = [1, 0, 1];
cachorro7 = [0, 0, 1];
cachorro8 = [1, 0, 1];
cachorro9 = [1, 1, 1];
cachorro10 = [0, 1, 1];
dados = [porco1, porco2, porco3, porco4, porco5, porco6, porco7, porco8, porco9, porco10, cachorro1, cachorro2, cachorro3, cachorro4, cachorro5, cachorro6, cachorro7, cachorro8, cachorro9, cachorro10];
classes = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
from sklearn.svm import LinearSVC
model = LinearSVC()
model.fit(dados, classes)
Tive este erro:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-43-d4aebfbe10e7> in <module>()
7
8 model = LinearSVC()
----> 9 model.fit(dados,classes_transformadas)
3 frames
/usr/local/lib/python3.7/dist-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator)
744 array = array.astype(dtype, casting="unsafe", copy=False)
745 else:
--> 746 array = np.asarray(array, order=order, dtype=dtype)
747 except ComplexWarning as complex_warning:
748 raise ValueError(
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (20,) + inhomogeneous part.