text_plain_output_1.png
from lightgbm import LGBMClassifier

from sklearn import decomposition

from sklearn.ensemble import AdaBoostClassifier

from sklearn.ensemble import BaggingClassifier

from sklearn.ensemble import GradientBoostingClassifier

from sklearn.ensemble import RandomForestClassifier

from sklearn.metrics import accuracy_score, confusion_matrix

from sklearn.tree import DecisionTreeClassifier

import pandas as pd

train_df_final = pd.read_csv('../input/pumpitup-challenge-dataset/train_df_final.csv')
X_test_final = pd.read_csv('../input/pumpitup-challenge-dataset/X_test_final.csv')

X_test_final.shape

sc = ss()
X_train = sc.fit_transform(X_train)
X_valid = sc.transform(X_valid)
X_test = sc.transform(X_test_final)

pca = decomposition.PCA(0.95)

pca.fit(X_train)

pca.n_components_

X_train_pca = pca.transform(X_train)
X_test_pca = pca.transform(X_test)
X_valid_pca = pca.transform(X_valid)

decision_tree = DecisionTreeClassifier()
decision_tree.fit(X_train, y_train)
y_pred = decision_tree.predict(X_valid)
acc_decision_tree = round(accuracy_score(y_valid, y_pred) * 100, 2)
acc_decision_tree

extra_tree = DecisionTreeClassifier()
extra_tree.fit(X_train, y_train)
y_pred = extra_tree.predict(X_valid)
acc_extra_tree = round(accuracy_score(y_valid, y_pred) * 100, 2)
acc_extra_tree

rfc = RandomForestClassifier(criterion='entropy', n_estimators=1000, min_samples_split=8, random_state=42, verbose=5)
rfc.fit(X_train, y_train)
y_pred = rfc.predict(X_valid)
acc_rfc = round(accuracy_score(y_valid, y_pred) * 100, 2)
acc_rfc

GB = GradientBoostingClassifier(n_estimators=100, learning_rate=0.075, max_depth=13, max_features=0.5, min_samples_leaf=14, verbose=5)
GB.fit(X_train, y_train)
y_pred = GB.predict(X_valid)
acc_GB = round(accuracy_score(y_valid, y_pred) * 100, 2)
acc_GB

HGB = HistGradientBoostingClassifier(learning_rate=0.075, loss='categorical_crossentropy', max_depth=8, min_samples_leaf=15)
HGB = HGB.fit(X_train_pca, y_train)
y_pred = HGB.predict(X_valid_pca)
acc_HGB = round(accuracy_score(y_valid, y_pred) * 100, 2)
acc_HGB

LGB = LGBMClassifier(objective='multiclass', learning_rate=0.75, num_iterations=100, num_leaves=50, random_state=123, max_depth=8)
LGB.fit(X_train, y_train)
y_pred = LGB.predict(X_valid)
acc_LGB = round(accuracy_score(y_valid, y_pred) * 100, 2)
acc_LGB

AB = AdaBoostClassifier(n_estimators=100, learning_rate=0.075)
AB.fit(X_train, y_train)
y_pred = AB.predict(X_valid)
acc_AB = round(accuracy_score(y_valid, y_pred) * 100, 2)
acc_AB

BC = BaggingClassifier(n_estimators=100)
BC.fit(X_train_pca, y_train)
y_pred = BC.predict(X_valid_pca)
acc_BC = round(accuracy_score(y_valid, y_pred) * 100, 2)
acc_BC