Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import pickle
from sklearn.model_selection import train_test_split
from sklearn import ensemble
from imblearn.over_sampling import SMOTE
dataset = pd.read_csv('train_df.csv')
X = dataset.iloc[:, :7]
y = dataset.iloc[:, -1]
smote = SMOTE(sampling_strategy = 'not majority')
x_sm, y_sm = smote.fit_resample(X, y)
X_train, X_test, y_train, y_test = train_test_split(x_sm, y_sm, test_size=0.2, random_state=0)
# Fit or Train the Model
params = {'n_estimators': 1000, 'max_depth': 4, "min_samples_split": 5, 'learning_rate':0.01}
lr_model = ensemble.GradientBoostingClassifier(**params)
lr_model.fit(X_train,y_train.values.ravel())
# Saving model to disk
pickle.dump(lr_model, open('model.pkl','wb'))
# Loading model to compare the results
model = pickle.load(open('model.pkl','rb'))
print(model.predict([[33,3, 3,1,3,3,3]]))