text_plain_output_1.png
from sklearn import metrics

from sklearn.metrics import classification_report, accuracy_score, confusion_matrix

from xgboost import XGBClassifier

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

train_set = pd.read_csv('/kaggle/input/aviakompaniya/train_dataset.csv')
test_set = pd.read_csv('/kaggle/input/aviakompaniya/test_dataset.csv')
sample = pd.read_csv('/kaggle/input/aviakompaniya/sample_submission.csv')

df = train_set.dropna()

df_100 = df[df['Flight Distance'] > 100]

df_100.select_dtypes('object').columns

Gender = list(df_100.Gender) + list(df_100.Gender)
Customer_Type = list(df_100['Customer Type']) + list(df_100['Customer Type'])
Type_of_Travel = list(df_100['Type of Travel']) + list(df_100['Type of Travel'])
Classes = list(df_100['Class']) + list(df_100['Class'])

satisfaction_rate = df_100['satisfaction'].value_counts() / len(df_100) * 100

fig, axes = plt.subplots(1,3, figsize=(15,5))

sns.countplot(x='Gender', hue='satisfaction', palette='viridis', data=df_100, ax=axes[0])
axes[0].set_title("Qolgan va qaytgan mijozrlarning jinsi")

sns.countplot(x='Class', hue='satisfaction', palette='viridis', data=df_100, ax=axes[1])
axes[1].set_title("Qolgan va qaytgan mijozrlarning qaysi classda uchganligi")

sns.countplot(x='Type of Travel', hue='satisfaction', palette='viridis', data=df_100, ax=axes[2])
axes[1].set_title("Qolgan va qaytgan mijozrlarning parvoz turi")

plt.show()

xgb_model = XGBClassifier()
xgb_model.fit(X_train, y_train)
y_pred = xgb_model.predict(X_test)
print(classification_report(y_test, y_pred))
print('Model aniqligi:', accuracy_score(y_test, y_pred))
conf_mat = confusion_matrix(y_test, y_pred)
sns.heatmap(conf_mat, annot=True, fmt='g')
plt.show()
fpr, tpr, thresholds = metrics.roc_curve(y_test, y_pred)
roc_auc = metrics.auc(fpr, tpr)
display = metrics.RocCurveDisplay(fpr=fpr, tpr=tpr, roc_auc=roc_auc, estimator_name='ROC curve')
display.plot()
plt.show()