from  featur_selection import df,race,occupation,workclass,country
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import cross_val_score,KFold
from sklearn.linear_model import LogisticRegression
from imblearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer
from imblearn.combine import SMOTETomek
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier,AdaBoostClassifier
from sklearn.neighbors import KNeighborsClassifier
from catboost import CatBoostClassifier
from xgboost import XGBClassifier
from sklearn.svm import SVC
from matplotlib import pyplot as plt
import seaborn as sns
df1=df.copy()
salary=df1['salary'].reset_index(drop=True)
df1=df1.drop(['salary'],axis=1)
def concat_dataframes(data):
    dataframe = pd.concat([data, workclass.iloc[data.index, :],                           race.iloc[data.index , :],                           occupation.iloc[data.index, :],                           country.iloc[data.index, :]], axis = 1)

    dataframe = dataframe.dropna()
    dataframe = dataframe.reset_index(drop=True)
    return dataframe

df1= concat_dataframes(df1)
features=['age_logarthmic','hours_per_week']
scaler = ColumnTransformer(transformers = [('scale_num_features', StandardScaler(), features)], remainder='passthrough')

models = [LogisticRegression(), SVC(), AdaBoostClassifier(), RandomForestClassifier(), XGBClassifier(),DecisionTreeClassifier(), KNeighborsClassifier(), CatBoostClassifier()]
model_labels = ['LogisticReg.','SVC','AdaBoost','RandomForest','Xgboost','DecisionTree','KNN', 'CatBoost']
mean_validation_f1_scores = []

for model in models:

  data_pipeline = Pipeline(steps = [
                                    ('scaler', scaler),
                                    ('resample', SMOTETomek()),
                                    ('model', model)
  ])
  mean_validation_f1 = float(cross_val_score(data_pipeline, df1, salary, cv=KFold(n_splits=10), scoring='f1',n_jobs=-1).mean())
  mean_validation_f1_scores.append(mean_validation_f1)
print(mean_validation_f1_scores)
fig, axes = plt.subplots(nrows = 2, ncols = 1, figsize = (15,8))

sns.set_style('dark')
sns.barplot(y = model_labels ,x = mean_validation_f1_scores, ax=axes[0])
axes[0].grid(True, color='k')

sns.set_style('whitegrid')
sns.lineplot(x = model_labels, y = mean_validation_f1_scores)
axes[1].grid(True, color='k')
fig.show()
[((17, 4, 17, 13), 'featur_selection.df.copy', 'df.copy', ({}, {}), '()', False, 'from featur_selection import df, race, occupation, workclass, country\n'), ((45, 12, 45, 64), 'matplotlib.pyplot.subplots', 'plt.subplots', (), '', True, 'from matplotlib import pyplot as plt\n'), ((47, 0, 47, 21), 'seaborn.set_style', 'sns.set_style', ({(47, 14, 47, 20): '"""dark"""'}, {}), "('dark')", True, 'import seaborn as sns\n'), ((48, 0, 48, 72), 'seaborn.barplot', 'sns.barplot', (), '', True, 'import seaborn as sns\n'), ((51, 0, 51, 26), 'seaborn.set_style', 'sns.set_style', ({(51, 14, 51, 25): '"""whitegrid"""'}, {}), "('whitegrid')", True, 'import seaborn as sns\n'), ((52, 0, 52, 61), 'seaborn.lineplot', 'sns.lineplot', (), '', True, 'import seaborn as sns\n'), ((21, 16, 21, 240), 'pandas.concat', 'pd.concat', (), '', True, 'import pandas as pd\n'), ((31, 10, 31, 30), 'sklearn.linear_model.LogisticRegression', 'LogisticRegression', ({}, {}), '()', False, 'from sklearn.linear_model import LogisticRegression\n'), ((31, 32, 31, 37), 'sklearn.svm.SVC', 'SVC', ({}, {}), '()', False, 'from sklearn.svm import SVC\n'), ((31, 39, 31, 59), 'sklearn.ensemble.AdaBoostClassifier', 'AdaBoostClassifier', ({}, {}), '()', False, 'from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier\n'), ((31, 61, 31, 85), 'sklearn.ensemble.RandomForestClassifier', 'RandomForestClassifier', ({}, {}), '()', False, 'from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier\n'), ((31, 87, 31, 102), 'xgboost.XGBClassifier', 'XGBClassifier', ({}, {}), '()', False, 'from xgboost import XGBClassifier\n'), ((31, 103, 31, 127), 'sklearn.tree.DecisionTreeClassifier', 'DecisionTreeClassifier', ({}, {}), '()', False, 'from sklearn.tree import DecisionTreeClassifier\n'), ((31, 129, 31, 151), 'sklearn.neighbors.KNeighborsClassifier', 'KNeighborsClassifier', ({}, {}), '()', False, 'from sklearn.neighbors import KNeighborsClassifier\n'), ((31, 153, 31, 173), 'catboost.CatBoostClassifier', 'CatBoostClassifier', ({}, {}), '()', False, 'from catboost import CatBoostClassifier\n'), ((29, 66, 29, 82), 'sklearn.preprocessing.StandardScaler', 'StandardScaler', ({}, {}), '()', False, 'from sklearn.preprocessing import StandardScaler\n'), ((39, 49, 39, 61), 'imblearn.combine.SMOTETomek', 'SMOTETomek', ({}, {}), '()', False, 'from imblearn.combine import SMOTETomek\n'), ((42, 76, 42, 94), 'sklearn.model_selection.KFold', 'KFold', (), '', False, 'from sklearn.model_selection import cross_val_score, KFold\n')]