Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save audhiaprilliant/6c7f0367957224c03416b94a7effdb82 to your computer and use it in GitHub Desktop.

Select an option

Save audhiaprilliant/6c7f0367957224c03416b94a7effdb82 to your computer and use it in GitHub Desktop.
End to end machine learning model deployment using flask
# -------------------- TESTING SET --------------------
# Data frame metadata
df_test.info()
# Change column types
df_test = df_test.astype({'Credit_History': object})
df_test.select_dtypes(include = ['object']).dtypes
# Summary statistics of categorical columns
for i in df_test.select_dtypes('object').columns:
print(df_test[i].value_counts(),'\n')
# Check missing values
df_test.isna().sum()
# Handle missing values
# 1 Dependents
print('Number of missing values in Dependents is about {} rows'.format(df_test['Dependents'].isna().sum()))
# Replace missing values with "0"
df_test['Dependents'].fillna(value = '0', inplace = True)
# 2 Self_Employed
print('Number of missing values in Self_Employed is about {} rows'.format(df_test['Self_Employed'].isna().sum()))
# Replace missing values with "No"
df_test['Self_Employed'].fillna(value = 'No', inplace = True)
# 3 Loan_Amount_Term
# Replace missing values with "360"
df_test['Loan_Amount_Term'].fillna(value = 360, inplace = True)
# 4 Gender, Married, LoanAmount and Credit_History
# Drop missing values
df_test.dropna(axis = 0, how = 'any', inplace = True)
# Check missing values
df_test.isna().sum()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment