AttributeError" Can't get attribute '_RemainderColsList' on <module 'sklearn.compose._column_transformer' #32018
Clffordojuka
started this conversation in
General
Replies: 1 comment 1 reply
-
|
Hey, How did you fix this error? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am getting this error"AttributeError: Can't get attribute '_RemainderColsList' on <module 'sklearn.compose._column_transformer' from 'C:\Users\USER\kenyan-crop-yield-prediction\venv\Lib\site-packages\sklearn\compose\_column_transformer.py'>" when trying to test my app with Streamlit Cloud. I have attempted to upgrade sklearn, even setting a reminder, but the error persists. here is some part of the code
Step 0: Imports
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import os
from sklearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import OneHotEncoder, StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.linear_model import ElasticNet
from sklearn.model_selection import train_test_split, cross_val_score
from sklearn.metrics import r2_score, mean_absolute_error, root_mean_squared_error, make_scorer
from sklearn.inspection import permutation_importance
import joblib
import warnings
warnings.filterwarnings("ignore")
Numeric transformer: imputation and scaling
numeric_transformer = Pipeline(steps=[
("imputer", SimpleImputer(strategy="median")),
("scaler", StandardScaler())
])
Categorical transformer: imputation and one-hot encoding
categorical_transformer = Pipeline(steps=[
("imputer", SimpleImputer(strategy="constant", fill_value="missing")),
("onehot", OneHotEncoder(handle_unknown="ignore"))
])
Combine preprocessing
preprocessor = ColumnTransformer(
transformers=[
("num", numeric_transformer, num_features),
("cat", categorical_transformer, cat_features)
],
remainder="drop"
)
Define Models
model_rf = RandomForestRegressor(n_estimators=250, random_state=42, n_jobs=-1)
model_enet = ElasticNet(alpha=0.001, l1_ratio=0.1, random_state=42)
Pipelines
pipe_rf = Pipeline(steps=[
("preprocessor", preprocessor),
("model", model_rf)
])
pipe_enet = Pipeline(steps=[
("preprocessor", preprocessor),
("model", model_enet)
])
Beta Was this translation helpful? Give feedback.
All reactions