Meu dataset (treino_set)
descritores;span;tipo
[4.333071178949439e-15, 24.84928492867941, 12....]; 157.237531; 3
[1.0849128708666645e-14, 27.27532469343159, 12...] ; 109.656511; 2
X = treino_set[["descritores","span"]] #Shape - (28689, 2)
y = treino_set[["tipo"]] #Shape - (28689, 1)
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import classification_report
modelo = RandomForestClassifier(n_estimators=1024)
modelo.fit(X, y)
Erros:
TypeError Traceback (most recent call last)
TypeError: only size-1 arrays can be converted to Python scalars
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
<ipython-input-144-f95036ce816e> in <module>
3
4 modelo = RandomForestClassifier(n_estimators=1024)
----> 5 modelo.fit(X, y)
6
7 print("Precisão do conjunto de treino: {}".format(modelo.score(X, y)))
c:\users\joaon\desktop\doutorado\ensaios\tensorflow-keras\lib\site-packages\sklearn\ensemble\_forest.py in fit(self, X, y, sample_weight)
301 "sparse multilabel-indicator for y is not supported."
302 )
--> 303 X, y = self._validate_data(X, y, multi_output=True,
304 accept_sparse="csc", dtype=DTYPE)
305 if sample_weight is not None:
c:\users\joaon\desktop\doutorado\ensaios\tensorflow-keras\lib\site-packages\sklearn\base.py in _validate_data(self, X, y, reset, validate_separately, **check_params)
430 y = check_array(y, **check_y_params)
431 else:
--> 432 X, y = check_X_y(X, y, **check_params)
433 out = X, y
434
c:\users\joaon\desktop\doutorado\ensaios\tensorflow-keras\lib\site-packages\sklearn\utils\validation.py in inner_f(*args, **kwargs)
71 FutureWarning)
72 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 73 return f(**kwargs)
74 return inner_f
75
c:\users\joaon\desktop\doutorado\ensaios\tensorflow-keras\lib\site-packages\sklearn\utils\validation.py in check_X_y(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, estimator)
794 raise ValueError("y cannot be None")
795
--> 796 X = check_array(X, accept_sparse=accept_sparse,
797 accept_large_sparse=accept_large_sparse,
798 dtype=dtype, order=order, copy=copy,
c:\users\joaon\desktop\doutorado\ensaios\tensorflow-keras\lib\site-packages\sklearn\utils\validation.py in inner_f(*args, **kwargs)
71 FutureWarning)
72 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 73 return f(**kwargs)
74 return inner_f
75
c:\users\joaon\desktop\doutorado\ensaios\tensorflow-keras\lib\site-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)
597 array = array.astype(dtype, casting="unsafe", copy=False)
598 else:
--> 599 array = np.asarray(array, order=order, dtype=dtype)
600 except ComplexWarning:
601 raise ValueError("Complex data not supported\n"
c:\users\joaon\desktop\doutorado\ensaios\tensorflow-keras\lib\site-packages\numpy\core\_asarray.py in asarray(a, dtype, order)
83
84 """
---> 85 return array(a, dtype, copy=False, order=order)
86
87
ValueError: setting an array element with a sequence.