# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import pandas as pd
import numpy as np
import matplotlib as plt
import seaborn as sns

# %matplotlib inline
# -

df = pd.read_csv('resources/member_sample.csv')
pd.set_option('display.max_columns', None)
df = df.drop(['City', 'Individual Key', 'Household Key', 'State - Grouped', 'Race', 'Home Owner', 'Date Of Birth', 'Education', 'Dwelling Type', 'Language', 'Gender', 'Bad Address Flag', 'Billing Code Description', 'Birth Date MMDDYYYY', 'Cancel Date', 'Cancel Reason'], axis=1)
df = df.drop(['Number of Children', 'Responded to Catalog', 'Length Of Residence', 'Mail Responder', 'Do Not Direct Mail Solicit', 'Email Available', 'Email Status', 'Right_Gender', 'Right_Individual Key', 'Join AAA Date', 'Member Key', 'Member Map Location', 'Member Number Associate ID', 'Member Phone Type'], axis=1)
df = df.drop(['Member Type', 'Months from Join to Cancel', 'Opt-Out - Publication', 'Reason Joined', 'Reinstate Date', 'Renew Method', 'Mosaic Household', 'Mosaic Global Household', 'kcl_B_IND_MosaicsGrouping', 'New Mover Flag', 'Occupation Code', 'Occupation Group', 'Right_Dwelling Type', 'Move Distance', 'Occupant Type', 'Breakdown Map Location', 'Breakdown City', 'Breakdown State'], axis=1)
df = df.drop(['Call Canceled', 'Call Killed', 'Call Status Recv Date', 'Cash Call', 'Clearing Code Last Description', 'Dispatch Code1 Description', 'Dispatch Code2Description', 'DTL Prob1 Code Description', 'Fleet Indicator', 'Is Duplicate', 'Is NSR', 'Member Match Flag', 'Member Number and Associate ID', 'Motorcycle Indicator'], axis=1)
df = df.drop(['Prob1 Code Description', 'Prob2 Code Description', 'SC Call Club Code Description', 'SC Date', 'Rec ID', 'SC STS RSN Code Description', 'SC Vehicle Manufacturer Name', 'SC Vehicle Model Name', 'SVC Facility Name', 'SVC Facility Type'], axis=1)
df = df.drop(['Tow Destination Latitude', 'Tow Destination Longitude', 'Tow Destination Name', 'Was Duplicated', 'Was Towed To AAR Referral'], axis=1)
df.replace(to_replace='N', value=0, inplace=True)
df.replace(to_replace='Y', value=1, inplace=True)
df.head()

# +
# 
# print(df['FSV CMSI Flag'].sum()/len(df['FSV CMSI Flag']) * 100)
# print(df['FSV Credit Card Flag'].sum()/len(df['FSV Credit Card Flag']) * 100)
# print(df['FSV Deposit Program Flag'].sum()/len(df['FSV Deposit Program Flag']) * 100)
# print(df['FSV Home Equity Flag'].sum()/len(df['FSV Home Equity Flag']) * 100)
# print(df['FSV ID Theft Flag'].sum()/len(df['FSV ID Theft Flag']) * 100)
# print(df['FSV Mortgage Flag'].sum()/len(df['FSV Mortgage Flag']) * 100)
# print(df['INS Client Flag'].sum()/len(df['INS Client Flag']) * 100)
# print(df['TRV Globalware Flag'].sum()/len(df['TRV Globalware Flag']) * 100)

# df = df[np.isfinite(df['Total Cost'])]
# df['Total Cost'].count()
# x = df[['FSV CMSI Flag', '', '', '', '', '', '', '']]
# 'ERS Member Cost Year 2'
# sns.set(style="ticks", color_codes=True)
# sns.pairplot(df, palette="husl")
sns.pairplot(df[['Member Tenure Years', 'ERS Member Cost Year 2']], size=4)
# -

659184.4199999999
13944

# +
from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(scaled_features,df['TARGET CLASS'], test_size=0.30)

# -

from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier(n_neighbors=5)







# +

# sns.pairplot(active_users)
# df[['Membership ID', 'Income', 'Total Cost']]
# grouped_members = df.groupby('Membership ID')
# df['Member Flag'] == 'Y'
# grouped_members.first()['Income']
# customers = df_grouped[]
# customers[['Membership ID', 'Income']]
# -



StarcoderdataJupyterScriptsDedupFiltered