antonbn commited on
Commit
5678e7b
1 Parent(s): d598808

initial commit

Browse files
Files changed (4) hide show
  1. .gitattributes +0 -34
  2. README.md +3 -3
  3. app.py +54 -0
  4. requirements.txt +3 -0
.gitattributes DELETED
@@ -1,34 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tflite filter=lfs diff=lfs merge=lfs -text
29
- *.tgz filter=lfs diff=lfs merge=lfs -text
30
- *.wasm filter=lfs diff=lfs merge=lfs -text
31
- *.xz filter=lfs diff=lfs merge=lfs -text
32
- *.zip filter=lfs diff=lfs merge=lfs -text
33
- *.zst filter=lfs diff=lfs merge=lfs -text
34
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: Titanic
3
  emoji: 🐢
4
  colorFrom: purple
5
- colorTo: blue
6
  sdk: gradio
7
- sdk_version: 3.9.1
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
 
1
  ---
2
+ title: Iris
3
  emoji: 🐢
4
  colorFrom: purple
5
+ colorTo: green
6
  sdk: gradio
7
+ sdk_version: 3.5
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from PIL import Image
4
+ import requests
5
+
6
+ import hopsworks
7
+ import joblib
8
+
9
+ project = hopsworks.login()
10
+ fs = project.get_feature_store()
11
+
12
+
13
+ mr = project.get_model_registry()
14
+ model = mr.get_model("titanic_modal", version=1)
15
+ model_dir = model.download()
16
+ model = joblib.load(model_dir + "/titanic_model.pkl")
17
+
18
+
19
+ def titanic(pclass, sex, age, sibs, par_ch, fare, deck, embarked):
20
+ input_list = []
21
+ input_list.append(pclass)
22
+ input_list.append(sex)
23
+ input_list.append(age)
24
+ input_list.append(sibs)
25
+ input_list.append(par_ch)
26
+ input_list.append(fare)
27
+ input_list.append(deck)
28
+ input_list.append(embarked)
29
+ # 'res' is a list of predictions returned as the label.
30
+ res = model.predict(np.asarray(input_list).reshape(1, -1))
31
+ # We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
32
+ # the first element.
33
+
34
+ return res[0]
35
+
36
+ demo = gr.Interface(
37
+ fn=titanic,
38
+ title="Titanic Survival Predictive Analytics",
39
+ description="Experiment with passenger class, sex, age, siblings, parents/children, fare, deck, and embarked to predict if a hypothetical passenger survived titanic.",
40
+ allow_flagging="never",
41
+ inputs=[
42
+ gr.inputs.Number(default=0.0, label="Passenger class"),
43
+ gr.inputs.Number(default=0.0, label="Sex"),
44
+ gr.inputs.Number(default=0.0, label="Age"),
45
+ gr.inputs.Number(default=0.0, label="Siblings"),
46
+ gr.inputs.Number(default=0.0, label="Parents/Children"),
47
+ gr.inputs.Number(default=0.0, label="Fare"),
48
+ gr.inputs.Number(default=0.0, label="Deck"),
49
+ gr.inputs.Number(default=0.0, label="Embarked"),
50
+ ],
51
+ outputs=gr.inputs.Number(label="Survived"))
52
+
53
+ demo.launch()
54
+
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ hopsworks
2
+ joblib
3
+ scikit-learn