Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Label management problem for Multilable classification #278

Open
imaspol opened this issue Oct 27, 2023 · 0 comments
Open

Label management problem for Multilable classification #278

imaspol opened this issue Oct 27, 2023 · 0 comments

Comments

@imaspol
Copy link

imaspol commented Oct 27, 2023

Encounted error: ValueError: yhas classes not inself.classes_. self.classes_ has [0 1]. 'y' has [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80].
My code structure
X_train is of type list, ex. ["invoice order number ... ", "invoice no xxx ... "]
Labels transformed with MultiLabelBinarizer of sklearn
`pipeline = Pipeline(
[
("tfidf", TfidfVectorizer()),
("deepclf", MLPClassifier(random_state=0, early_stopping=True, verbose=True, learning_rate='adaptive')),
]
)

parameter_grid = {
'tfidf__max_df': tune.uniform(0.06,0.14),
'tfidf__min_df': [15, 20],
}

tune_search = TuneSearchCV(
estimator=pipeline,
param_distributions=parameter_grid,
early_stopping=True,
n_trials=3,
scoring=scoring,
n_jobs=-1,
search_optimization="hyperopt",
refit="accuracy",
verbose=2,
random_state=0,
error_score="raise",
return_train_score=True,
max_iters=10,
pipeline_auto_early_stop=True,
)

tune_search.fit(X_train, y_train)`

Error in detail:
RayTaskError(ValueError): ray::_Inner.train() (pid=406, ip=172.19.2.2, actor_id=e7cf6c475f0758242d05693101000000, repr=<ray.tune.trainable.util._PipelineTrainable object at 0x7de876343fd0>) File "/opt/conda/lib/python3.10/site-packages/ray/tune/trainable/trainable.py", line 389, in train raise skipped from exception_cause(skipped) File "/opt/conda/lib/python3.10/site-packages/ray/tune/trainable/trainable.py", line 386, in train result = self.step() File "/opt/conda/lib/python3.10/site-packages/tune_sklearn/_trainable.py", line 126, in step return self._train() File "/opt/conda/lib/python3.10/site-packages/tune_sklearn/_trainable.py", line 230, in _train raise e File "/opt/conda/lib/python3.10/site-packages/tune_sklearn/_trainable.py", line 208, in _train self._early_stopping_partial_fit( File "/opt/conda/lib/python3.10/site-packages/tune_sklearn/_trainable.py", line 480, in _early_stopping_partial_fit estimator.steps[-1][1].partial_fit( File "/opt/conda/lib/python3.10/site-packages/sklearn/neural_network/_multilayer_perceptron.py", line 1207, in partial_fit return self._fit(X, y, incremental=True) File "/opt/conda/lib/python3.10/site-packages/sklearn/neural_network/_multilayer_perceptron.py", line 437, in _fit X, y = self._validate_input(X, y, incremental, reset=first_pass) File "/opt/conda/lib/python3.10/site-packages/sklearn/neural_network/_multilayer_perceptron.py", line 1132, in _validate_input raise ValueError( ValueError: yhas classes not inself.classes_. self.classes_has [0 1]. 'y' has [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80]. 2023-10-27 12:59:41,111 ERROR worker.py:408 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): ray::_Inner.train() (pid=477, ip=172.19.2.2, actor_id=cbac4dbe9e353b549123a68501000000, repr=<ray.tune.trainable.util._PipelineTrainable object at 0x7efef9527fa0>) File "/opt/conda/lib/python3.10/site-packages/ray/tune/trainable/trainable.py", line 389, in train raise skipped from exception_cause(skipped) File "/opt/conda/lib/python3.10/site-packages/ray/tune/trainable/trainable.py", line 386, in train result = self.step() File "/opt/conda/lib/python3.10/site-packages/tune_sklearn/_trainable.py", line 126, in step return self._train() File "/opt/conda/lib/python3.10/site-packages/tune_sklearn/_trainable.py", line 230, in _train raise e File "/opt/conda/lib/python3.10/site-packages/tune_sklearn/_trainable.py", line 208, in _train self._early_stopping_partial_fit( File "/opt/conda/lib/python3.10/site-packages/tune_sklearn/_trainable.py", line 480, in _early_stopping_partial_fit estimator.steps[-1][1].partial_fit( File "/opt/conda/lib/python3.10/site-packages/sklearn/neural_network/_multilayer_perceptron.py", line 1207, in partial_fit return self._fit(X, y, incremental=True) File "/opt/conda/lib/python3.10/site-packages/sklearn/neural_network/_multilayer_perceptron.py", line 437, in _fit X, y = self._validate_input(X, y, incremental, reset=first_pass) File "/opt/conda/lib/python3.10/site-packages/sklearn/neural_network/_multilayer_perceptron.py", line 1132, in _validate_input raise ValueError( ValueError:yhas classes not inself.classes_. self.classes_ has [0 1]. 'y' has [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80].

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant