Commit
·
4aac4eb
1
Parent(s):
5a99899
Update app.py
Browse files
app.py
CHANGED
@@ -14,18 +14,22 @@ from sklearn.model_selection import train_test_split
|
|
14 |
x_train, x_test, y_train, y_test = train_test_split(df.drop('charges',axis=1), df['charges'], test_size=0.2, random_state=42)
|
15 |
|
16 |
#decision tree regressor
|
17 |
-
from sklearn.tree import DecisionTreeRegressor
|
18 |
-
dtree = DecisionTreeRegressor()
|
19 |
#model training
|
20 |
-
dtree.fit(x_train,y_train)
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
23 |
|
24 |
def func(a, b, c, d, e, f):
|
25 |
|
26 |
|
27 |
x_test = [[a, b, c, d, e, f]]
|
28 |
-
result =
|
29 |
rounded_result = round(result, 2)
|
30 |
str="Your Medical Expenses could be: ₹"
|
31 |
str1="Thankyou🤗 for using our Model"
|
|
|
14 |
x_train, x_test, y_train, y_test = train_test_split(df.drop('charges',axis=1), df['charges'], test_size=0.2, random_state=42)
|
15 |
|
16 |
#decision tree regressor
|
17 |
+
#from sklearn.tree import DecisionTreeRegressor
|
18 |
+
#dtree = DecisionTreeRegressor()
|
19 |
#model training
|
20 |
+
#dtree.fit(x_train,y_train)
|
21 |
+
|
22 |
+
from sklearn.ensemble import RandomForestRegressor
|
23 |
+
rf = RandomForestRegressor()
|
24 |
+
#model training
|
25 |
+
rf.fit(x_train,y_train)
|
26 |
+
|
27 |
|
28 |
def func(a, b, c, d, e, f):
|
29 |
|
30 |
|
31 |
x_test = [[a, b, c, d, e, f]]
|
32 |
+
result = rf.predict(x_test)[0]
|
33 |
rounded_result = round(result, 2)
|
34 |
str="Your Medical Expenses could be: ₹"
|
35 |
str1="Thankyou🤗 for using our Model"
|