<jupyter_start><jupyter_text>Medical Appointment No Shows Capstone  5. DOCUMENTATION - Review the Results- Finalize Code- Finalize Documentation<jupyter_code>import os
import pandas as pd
import datetime
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from sklearn import linear_model
from sklearn.metrics import explained_variance_score,mean_absolute_error
%matplotlib inline
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split as TTS

from sklearn.ensemble import RandomForestClassifier as RFC


import pandas.util.testing as tm
import xgboost as xgb

SEED =1
def load_dataframe():
    csv_path = os.path.join("data/df_ohe.csv")
    return pd.read_csv(csv_path)
df_ohe = load_dataframe()
df_ohe.head()<jupyter_output><empty_output><jupyter_text>___  SummaryThis is Supervised Classification project to predict whether patients will show up to their appointment. The data was taken from patients who had their appointments from 11-10-2015 to  06-08-2016. Data Wrangling.- Used a conditional statement to keep the ages of the patients between 0 to 100 years old.- Created a new feature called ['WaitingDays'] that is the number of waiting days from day the appointment was scheduled until the actual day of the appointment. - Created a new features to return the time, hour, name of the week, and name of the month of the appointment and scheduled day.  Model Performance:ROC/AUC was used to determine the best model.  Model Findings:The most important features where: - 1. Age (0.177744)- 2. WaitingDays (0.110100)- 3. ScheduledHour (0.106352)- 4. ScheduledDay_D (0.058988)- 5. AppointmentDay_D (0.052590)- 6. Gender_1 (0.031152)- 7. SMSSent (0.014983)  Best Model Random Forest was the best model.<jupyter_code>X = df_ohe.drop(['NoShow_1'], axis = 1)
y = df_ohe['NoShow_1']

SEED = 42
TS = 0.25

# Create training and test sets
X_train, X_test, y_train, y_test = \
    train_test_split(X, y, test_size = TS, random_state=SEED, stratify=y)

#Feature Scaling to prevent information leakage
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)

print (X_train.shape)
print (y_train.shape)
print (X_test.shape)
print (y_test.shape)<jupyter_output>(82887, 112)
(82887,)
(27630, 112)
(27630,)<jupyter_text>Finalize Code<jupyter_code>import pickle
s = pickle.dumps(model)
from joblib import dump, load
dump(model, 'models/model.joblib')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07801691006917756, 'fraction_numerical': 0.04342813220599539, 'mean_word_length': 5.42716049382716, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '552231', 'license': 'MIT', 'n_tokens_mistral': 919, 'n_tokens_neox': 833, 'n_words': 292, 'path': '6_Documentation.ipynb', 'repo_name': 'asaadkhattab/MedicalAppointmentNoShowsCapstone', 'size': '2602'}