text_plain_output_1.png
from joblib import dump, load

from sklearn.linear_model import LinearRegression , Ridge , LogisticRegression

from sklearn.linear_model import LogisticRegression

from sklearn.linear_model import LogisticRegression

import matplotlib.pyplot as plt

import numpy as np

import numpy as np # linear algebra

import pandas as pd

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import pickle

import seaborn as sns

import warnings

import warnings

import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import statsmodels.api as sm
from sklearn.linear_model import LinearRegression, Ridge, LogisticRegression
from sklearn.preprocessing import LabelEncoder, PolynomialFeatures
from sklearn.model_selection import train_test_split
from sklearn.metrics import r2_score, mean_squared_error
from scipy import stats
from sklearn.pipeline import make_pipeline
from sklearn.svm import SVC
from sklearn.neighbors import KNeighborsClassifier
from sklearn import tree
from sklearn.tree import DecisionTreeClassifier
from xgboost import XGBClassifier
from sklearn.ensemble import RandomForestClassifier
from imblearn.over_sampling import SMOTE
from graphviz import Source
from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import confusion_matrix, classification_report
from mlxtend.plotting import plot_confusion_matrix
from sklearn.model_selection import GridSearchCV, RandomizedSearchCV
import warnings
warnings.filterwarnings('ignore')
sns.set(style='darkgrid')
plt.style.use('fivethirtyeight')

train = pd.read_csv('/kaggle/input/airline-passenger-satisfaction/train.csv', index_col=None)
test = pd.read_csv('/kaggle/input/airline-passenger-satisfaction/test.csv', index_col=None)

def dataset_overview(data, col):
    pass

train = train.drop('Unnamed: 0', axis=1)

test = test.drop('Unnamed: 0', axis=1)

train = train.fillna(train.mean())

test = test.fillna(test.mean())

def correlation_matrix(data):
    corr = data.corr().round(2)

    # Mask for the upper triangle
    mask = np.zeros_like(corr, dtype=np.bool)
    mask[np.triu_indices_from(mask)] = True

    # Set figure size
    f, ax = plt.subplots(figsize=(20, 20))

    # Define custom colormap
    cmap = sns.diverging_palette(220, 10, as_cmap=True)

    # Draw the heatmap
    d=sns.heatmap(corr, mask=mask, cmap=cmap, vmin=-1, vmax=1, center=0,
                square=True, linewidths=.5, cbar_kws={"shrink": .5}, annot=True)

    plt.tight_layout()
    return d

train.columns

X = train.drop(['satisfaction'], axis=1)
y = train['satisfaction']

from sklearn.linear_model import LogisticRegression
clf_lr = LogisticRegression(solver='liblinear')
clf_lr.fit(X, y)

s = pickle.dumps(clf_lr)

X_test = test.drop('satisfaction', axis=1)

clf = load('filename.joblib')

clf.predict(X_test)

def prediction_pickle(clf, input_data, data):
    dump(clf, 'pipeline.joblib')
    s = load('pipeline.joblib')
    prediction = s.predict(input_data)
    data['prediction'] = prediction
    return

prediction_pickle(clf_lr, X_test, test)