Spandan Dhadse
Spandan Dhadse

Reputation: 1

streamlit error in AttributeError: 'OneHotEncoder' object has no attribute '_infrequent_enabled'

Traceback: File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script exec(code, module.dict) File "C:\Users\spand\Desktop\laptop price prediction\app.py", line 68, in st.title(int(np.exp(pipe.predict(query)))) File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\pipeline.py", line 457, in predict Xt = transform.transform(Xt) File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\compose_column_transformer.py", line 763, in transform Xs = self._fit_transform( File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\compose_column_transformer.py", line 621, in _fit_transform return Parallel(n_jobs=self.n_jobs)( File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py", line 1085, in call if self.dispatch_one_batch(iterator): File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py", line 901, in dispatch_one_batch self._dispatch(tasks) File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py", line 819, in _dispatch job = self._backend.apply_async(batch, callback=cb) File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib_parallel_backends.py", line 208, in apply_async result = ImmediateResult(func) File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib_parallel_backends.py", line 597, in init self.results = batch() File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py", line 288, in call return [func(*args, **kwargs) File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\joblib\parallel.py", line 288, in return [func(*args, **kwargs) File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\utils\fixes.py", line 117, in call return self.function(*args, **kwargs) File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\pipeline.py", line 853, in _transform_one res = transformer.transform(X) File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\preprocessing_encoders.py", line 888, in transform self._map_infrequent_categories(X_int, X_mask) File "C:\Users\spand\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\preprocessing_encoders.py", line 726, in _map_infrequent_categories if not self._infrequent_enabled:

How to overcome this problem no i can't find the reason behind it

Upvotes: 0

Views: 448

Answers (2)

Steven Jerjian
Steven Jerjian

Reputation: 1

Came here because I ran into this same problem with both OneHotEncoder and OrdinalEncoder on streamlit.

Specifying sklearn version in the requirements.txt file fixed the problem (i.e. making sure sklearn version matches the version used to train the model)

Upvotes: 0

Syed Sajjad Askari
Syed Sajjad Askari

Reputation: 59

Please check the version of streamlit (update the sklearn version)

ColumnTransformer(transformers=[('col_tnf',OneHotEncoder(sparse=False,drop='first'),0,1,3,8,11])],remainder='passthrough')

Upvotes: 0

Related Questions