<jupyter_start><jupyter_text>CatBoost  Importing the libraries<jupyter_code>!pip install catboost 
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd<jupyter_output><empty_output><jupyter_text>Importing the dataset<jupyter_code>dataset = pd.read_csv('Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, -1].values
dataset.head()<jupyter_output><empty_output><jupyter_text>Splitting the dataset into the Training set and Test set<jupyter_code>from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)<jupyter_output><empty_output><jupyter_text>Training CatBoost on the Training set<jupyter_code>from catboost import CatBoostClassifier
classifier = CatBoostClassifier()
classifier.fit(X_train, y_train)<jupyter_output>Learning rate set to 0.007956
0:	learn: 0.6778283	total: 47.7ms	remaining: 47.6s
1:	learn: 0.6642874	total: 48.9ms	remaining: 24.4s
2:	learn: 0.6510578	total: 50ms	remaining: 16.6s
3:	learn: 0.6351685	total: 51.1ms	remaining: 12.7s
4:	learn: 0.6203906	total: 52.3ms	remaining: 10.4s
5:	learn: 0.6053561	total: 53.3ms	remaining: 8.83s
6:	learn: 0.5913363	total: 54.4ms	remaining: 7.72s
7:	learn: 0.5773888	total: 55.5ms	remaining: 6.88s
8:	learn: 0.5638394	total: 56.5ms	remaining: 6.22s
9:	learn: 0.5507421	total: 57.6ms	remaining: 5.71s
10:	learn: 0.5377201	total: 58.7ms	remaining: 5.28s
11:	learn: 0.5243873	total: 59.8ms	remaining: 4.92s
12:	learn: 0.5129034	total: 60.8ms	remaining: 4.62s
13:	learn: 0.5047204	total: 61.9ms	remaining: 4.36s
14:	learn: 0.4942404	total: 63ms	remaining: 4.13s
15:	learn: 0.4836253	total: 64ms	remaining: 3.94s
16:	learn: 0.4733355	total: 65.1ms	remaining: 3.76s
17:	learn: 0.4629416	total: 66.1ms	remaining: 3.61s
18:	learn: 0.4527778	total: 67.2ms	remaining: 3.47[...]<jupyter_text>Making the Confusion Matrix<jupyter_code>from sklearn.metrics import confusion_matrix, accuracy_score
y_pred = classifier.predict(X_test)
cm = confusion_matrix(y_test, y_pred)
print(cm)
accuracy_score(y_test, y_pred)<jupyter_output>[[84  3]
 [ 0 50]]<jupyter_text>This turned out higher that the XGBoost model!  Applying k-Fold Cross Validation<jupyter_code>from sklearn.model_selection import cross_val_score
accuracies = cross_val_score(estimator = classifier, X = X_train, y = y_train, cv = 10)
print("Accuracy: {:.2f} %".format(accuracies.mean()*100))
print("Standard Deviation: {:.2f} %".format(accuracies.std()*100))<jupyter_output>[1;30;43mStreaming output truncated to the last 5000 lines.[0m
6:	learn: 0.6007221	total: 9.92ms	remaining: 1.41s
7:	learn: 0.5865261	total: 11.1ms	remaining: 1.37s
8:	learn: 0.5760173	total: 12.3ms	remaining: 1.35s
9:	learn: 0.5641784	total: 13.2ms	remaining: 1.3s
10:	learn: 0.5538549	total: 14.3ms	remaining: 1.28s
11:	learn: 0.5413434	total: 15.4ms	remaining: 1.27s
12:	learn: 0.5308262	total: 16.5ms	remaining: 1.26s
13:	learn: 0.5187893	total: 17.6ms	remaining: 1.24s
14:	learn: 0.5084890	total: 18.7ms	remaining: 1.23s
15:	learn: 0.4986254	total: 19.8ms	remaining: 1.22s
16:	learn: 0.4890714	total: 20.9ms	remaining: 1.21s
17:	learn: 0.4790883	total: 21.9ms	remaining: 1.2s
18:	learn: 0.4700108	total: 23.1ms	remaining: 1.19s
19:	learn: 0.4630325	total: 24.2ms	remaining: 1.18s
20:	learn: 0.4536134	total: 25.3ms	remaining: 1.18s
21:	learn: 0.4429695	total: 26.4ms	remaining: 1.17s
22:	learn: 0.4362340	total: 27.6ms	remaining: 1.17s
23:	learn: 0.4280061	total: 28.7ms	remaining: 1.17s
24:	l[...]<jupyter_text>The Std Dev is almost same as XGBoost, however the mean accuracy has also slightly increase just as the test accuracy. So, definitely a better model than XGB, in this case.<jupyter_code><jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup