after the deployment of smote library on target columns still showing the imbalance target result.code is running successful but not showing the smote deployment results. y_train.value_counts():
False 538 True 38 Name: isLegendary, dtype: int64
from sklearn.compose import ColumnTransformer #apply trnasformation on columns
from imblearn.pipeline import Pipeline as imbpipeline
from imblearn.over_sampling import SMOTE
smote = SMOTE(sampling_strategy='auto',random_state=42)
prepro = ColumnTransformer(
transformers=[
('ohe', OneHotEncoder(handle_unknown='ignore', sparse=False, drop='first'), ["Type_1", "Type_2", "Color", "Egg_Group_1", "Body_Style"]),
('ft', FunctionTransformer(func=np.log1p), ['Total', 'HP', 'Attack', 'Defense', 'Sp_Atk', 'Sp_Def', 'Speed', 'Generation', 'Pr_Male', 'Height_m', 'Weight_kg']),
('scaler', MinMaxScaler(), ['Total', 'HP', 'Attack', 'Defense', 'Sp_Atk', 'Sp_Def', 'Speed', 'Generation', 'Pr_Male', 'Height_m', 'Weight_kg'])
],
remainder='passthrough'
)
from sklearn.ensemble import RandomForestClassifier
model=RandomForestClassifier(bootstrap= True,criterion='gini',max_depth=15,max_features='log2',n_estimators= 10,verbose=False)
# Create the imbalanced-learn pipeline
pipeline = imbpipeline([
('preprocessor', prepro),
('smote', smote),
('model',model)
])
# Fit the pipeline on the data
pipeline.fit(x_train, y_train)
i am expecting that it should convert imbalance into balance class:-
y_train.value_counts():
False 538
True 538
Name: isLegendary, dtype: int64
The code is running successful but not converting it into balanced class