Holiday Hours open 12-7 til December 24th Christmas Eve. Give the Gift of Holistic Wellness for the Holidays
# Import Library
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import pickle
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import roc_auc_score
import lightgbm
#import dataset
data = pd.read_csv('master_classification.csv).fillna(0)
#creating a concise list of the categorical features
cat = data[['year' , 'state', 'make', 'model', 'body', 'bodystyle']]
#X-features
X = data.loc[:, 'abs_text' 'features' 'c-sect' 'vehicle_age' 'Cylinders' 'kbb_M' 'kbb_C' 'kbb_R' 'milage']
X1 = pd.concat([X.astype(str),cat],axis=1)
X.head()
#Y-target
y = data['bought']
# creating dummy binary variables for cat values
X2= pd.get_dummies(X1)
X_new=X2.to_numpy()
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(X_new,y,test_size=0.25,random_state=42)
#RESAMPLING DUE TO UNBALANCE DATA
from imblearn.over_sampling import SMOTE # doctest: +NORMALIZE_WHITESPACE
smote = SMOTE()
X_train, y_train = smote.fit_resample(X_train, y_train)
#NN CLASSIFIER
from sklearn.neural_network import MLPClassifier
NN_model = MLPClassifier(hidden_layer_sizes=(90,90,90,90))
NN_model.fit(X_train,y_train)
y_pred=NN_model.predict(X_test)
y_pred
#pickle model
pickle.dump(NN_model,open('gan_classifier.pkl','wb'))
Continue reading
Comments
Be the first to comment.