jcjurado commited on
Commit
953bf59
1 Parent(s): 31ca4ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -47,17 +47,17 @@ y_all = train['Survived']
47
  num_test = 0.20
48
  X_train, X_test, y_train, y_test = train_test_split(X_all, y_all, test_size=num_test, random_state=23)
49
 
50
- #clf = RandomForestClassifier()
51
- tree = DecisionTreeClassifier()
52
- tree.fit(X_train, y_train)
53
- predictions = tree.predict(X_test)
54
 
55
  def predict_survival(sex, age, fare):
56
  df = pd.DataFrame.from_dict({'Sex': [sex], 'Age': [age], 'Fare': [fare]})
57
  df = encode_sex(df)
58
  df = encode_fares(df)
59
  df = encode_ages(df)
60
- pred = tree.predict_proba(df)[0]
61
  return {'Perishes': float(pred[0]), 'Survives': float(pred[1])}
62
 
63
  sex = gr.inputs.Radio(['female', 'male'], label="Sex")
 
47
  num_test = 0.20
48
  X_train, X_test, y_train, y_test = train_test_split(X_all, y_all, test_size=num_test, random_state=23)
49
 
50
+ clf = RandomForestClassifier()
51
+ #tree = DecisionTreeClassifier()
52
+ clf.fit(X_train, y_train)
53
+ predictions = clf.predict(X_test)
54
 
55
  def predict_survival(sex, age, fare):
56
  df = pd.DataFrame.from_dict({'Sex': [sex], 'Age': [age], 'Fare': [fare]})
57
  df = encode_sex(df)
58
  df = encode_fares(df)
59
  df = encode_ages(df)
60
+ pred = clf.predict_proba(df)[0]
61
  return {'Perishes': float(pred[0]), 'Survives': float(pred[1])}
62
 
63
  sex = gr.inputs.Radio(['female', 'male'], label="Sex")