Skip to content

Commit

Permalink
Replaces GBR with Voting Regressor(two GBRs)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhatwalia committed Aug 24, 2021
1 parent 60f43d4 commit 17c12d0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions allauthdemo/views/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from keras.models import Sequential
from keras.layers import Dense
from pandas import *
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.ensemble import GradientBoostingRegressor, VotingRegressor
from sklearn.model_selection import train_test_split
import numpy as np

Expand All @@ -32,7 +32,9 @@ def get_health_rates(request, instance):
y = data['charges']
train_x, test_x, train_y, test_y = train_test_split(x, y, test_size=0.4)

model = GradientBoostingRegressor(loss='huber', learning_rate=0.13, max_features='auto', alpha=0.7, random_state=1)
r1 = GradientBoostingRegressor(loss='huber', learning_rate=0.13, max_features='auto', alpha=0.7, random_state=1)
r2 = GradientBoostingRegressor(loss='huber', learning_rate=0.13, max_features='auto', alpha=0.7, random_state=1)
model = VotingRegressor([('gbr1', r1), ('gbr2', r2)])
model.fit(train_x, train_y)

test_x = np.asarray([[instance.age, instance.bmi, instance.children, instance.sex=='male', instance.smoker=='yes', instance.region=='northwest', instance.region=='southeast', instance.region=='southwest']])
Expand Down

0 comments on commit 17c12d0

Please sign in to comment.