import pandas as pd
from imblearn.over_sampling import SMOTE

# Read Excel file
df = pd.read_excel(r"C:\Users\29177\Desktop\2.xlsx")

# Divide the data set into features and labels
X = df.iloc[:, :-1]
y = df.iloc[:, -1]
X.columns = X.columns.astype(str)
X = X.astype(str)
y = y.astype(str)

# Resampling using SMOTE
smote = SMOTE()
X_resampled, y_resampled = smote.fit_resample(X, y)

# Save the resampled data to an Excel file
resampled_df = pd.concat([pd.DataFrame(X_resampled), pd.DataFrame(y_resampled)], axis=1)
resampled_df.to_excel(r"C:\Users\29177\Desktop\1.xlsx", index=False)

