Upload 3 files
Browse files- README.md +4 -4
- app.py +50 -0
- requirements.txt +2 -5
README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
---
|
| 2 |
title: Titanic
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 3.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
|
|
|
| 1 |
---
|
| 2 |
title: Titanic
|
| 3 |
+
emoji: 💻
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 3.8.2
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
app.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
import hopsworks
|
| 4 |
+
import joblib
|
| 5 |
+
|
| 6 |
+
project = hopsworks.login()
|
| 7 |
+
fs = project.get_feature_store()
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
mr = project.get_model_registry()
|
| 11 |
+
model = mr.get_model("titanic_modal", version=1)
|
| 12 |
+
model_dir = model.download()
|
| 13 |
+
model = joblib.load(model_dir + "/titanic_model.pkl")
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def titanic(pclass, sex, age, sibsp, parch, pricerange):
|
| 17 |
+
input_list = []
|
| 18 |
+
input_list.append(pclass)
|
| 19 |
+
input_list.append(sex)
|
| 20 |
+
input_list.append(age)
|
| 21 |
+
input_list.append(sibsp)
|
| 22 |
+
input_list.append(parch)
|
| 23 |
+
input_list.append(pricerange)
|
| 24 |
+
# 'res' is a list of predictions returned as the label.
|
| 25 |
+
res = model.predict(np.asarray(input_list).reshape(1, -1))
|
| 26 |
+
if res[0]==0:
|
| 27 |
+
output = "Did not survive"
|
| 28 |
+
else:
|
| 29 |
+
output = "Survived"
|
| 30 |
+
|
| 31 |
+
return output
|
| 32 |
+
|
| 33 |
+
demo = gr.Interface(
|
| 34 |
+
fn=titanic,
|
| 35 |
+
title="Titanic Predictive Analytics",
|
| 36 |
+
description="Experiment with passenger information to predict if the passenger survived or not",
|
| 37 |
+
allow_flagging="never",
|
| 38 |
+
inputs=[
|
| 39 |
+
gr.inputs.Number(default=1, label="ticket class (1 = 1st, 2 = 2nd, 3 = 3rd)"),
|
| 40 |
+
gr.inputs.Number(default=0, label="sex (0=male, 1=female)"),
|
| 41 |
+
gr.inputs.Number(default=24, label="age (years)"),
|
| 42 |
+
gr.inputs.Number(default=1.0, label="# of siblings/spouses aboard"),
|
| 43 |
+
gr.inputs.Number(default=1.0, label="# of children/parents aboard"),
|
| 44 |
+
gr.inputs.Number(default=1.0, label="pricerange (1=cheapest, 5=most expensive)"),
|
| 45 |
+
],
|
| 46 |
+
outputs="text")
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
demo.launch()
|
| 50 |
+
|
requirements.txt
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
|
|
| 1 |
joblib
|
| 2 |
scikit-learn
|
| 3 |
-
|
| 4 |
-
xgboost
|
| 5 |
-
dataframe-image
|
| 6 |
-
modal-client
|
| 7 |
-
gradio
|
|
|
|
| 1 |
+
hopsworks
|
| 2 |
joblib
|
| 3 |
scikit-learn
|
| 4 |
+
pillow
|
|
|
|
|
|
|
|
|
|
|
|