from IPython.core.display import HTML
css_file = 'style.css'
HTML(open(css_file, 'r').read())
from numpy import array
import pickle
# Opening the pickle file
# The rb stands for read binary
model_pkl = open("Random_forest_regressor_model.pkl", "rb")
# Reading the model
model = pickle.load(model_pkl)
# Calling the model
model
RandomForestRegressor(bootstrap=True, criterion='mse', max_depth=None, max_features='auto', max_leaf_nodes=None, min_impurity_split=1e-07, min_samples_leaf=1, min_samples_split=2, min_weight_fraction_leaf=0.0, n_estimators=100, n_jobs=-1, oob_score=True, random_state=42, verbose=0, warm_start=False)
# Confirming the number of features
model.n_features_
13
# The importance of each feature
model.feature_importances_
array([ 0.12339053, 0.10903826, 0.19797339, 0.45332269, 0.01259731, 0.01452948, 0.01445595, 0.01312439, 0.01143903, 0.01015556, 0.01254152, 0.01582894, 0.01160294])
# Testing the probability of a positive outcome of a new example
new_patient = array([[3, 16, 9, 22, 1, 0, 0, 0, 1, 0, 0, 1, 0]])
model.predict(new_patient)
array([ 0.08])