danupurnomo commited on
Commit
c4bb1a4
1 Parent(s): 7edec04

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +84 -0
README.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - tabular-classification
4
+ - sklearn
5
+ - tensorflow
6
+ dataset:
7
+ - titanic
8
+ widget:
9
+ structuredData:
10
+ PassengerId:
11
+ - 1191
12
+ Pclass:
13
+ - 1
14
+ Name:
15
+ - Sherlock Holmes
16
+ Sex:
17
+ - male
18
+ SibSp:
19
+ - 0
20
+ Parch:
21
+ - 0
22
+ Ticket:
23
+ - C.A.29395
24
+ Fare:
25
+ - 12
26
+ Cabin:
27
+ - F44
28
+ Embarked:
29
+ - S
30
+ ---
31
+
32
+ ## Titanic (Survived/Not Survived) - Binary Classification
33
+
34
+ ### How to use
35
+
36
+ ```python
37
+ from huggingface_hub import hf_hub_url, cached_download
38
+ import joblib
39
+ import pandas as pd
40
+ import numpy as np
41
+ from tensorflow.keras.models import load_model
42
+
43
+ REPO_ID = 'danupurnomo/dummy-titanic'
44
+ PIPELINE_FILENAME = 'final_pipeline.pkl'
45
+ TF_FILENAME = 'titanic_model.h5'
46
+
47
+ model_pipeline = joblib.load(cached_download(
48
+ hf_hub_url(REPO_ID, PIPELINE_FILENAME)
49
+ ))
50
+
51
+ model_seq = load_model(cached_download(
52
+ hf_hub_url(REPO_ID, TF_FILENAME)
53
+ ))
54
+
55
+ ### Example A New Data
56
+ ```
57
+ new_data = {
58
+ 'PassengerId': 1191,
59
+ 'Pclass': 1,
60
+ 'Name': 'Sherlock Holmes',
61
+ 'Sex': 'male',
62
+ 'Age': 30,
63
+ 'SibSp': 0,
64
+ 'Parch': 0,
65
+ 'Ticket': 'C.A.29395',
66
+ 'Fare': 12,
67
+ 'Cabin': 'F44',
68
+ 'Embarked': 'S'
69
+ }
70
+ new_data = pd.DataFrame([new_data])
71
+ ```
72
+
73
+ ### Transform Inference-Set
74
+ ```
75
+ new_data_transform = model_pipeline.transform(new_data)
76
+ ```
77
+
78
+ ### Predict using Neural Networks
79
+ ```
80
+ y_pred_inf_single = model_seq.predict(new_data_transform)
81
+ y_pred_inf_single = np.where(y_pred_inf_single >= 0.5, 1, 0)
82
+ print('Result : ', y_pred_inf_single)
83
+ # [[0]]
84
+ ```