Spaces:
No application file
No application file
Commit
•
664ba05
1
Parent(s):
54281e5
Upload 10 files
Browse files- .gitattributes +1 -0
- Langkah deployment huggingface.docx +3 -0
- data science.jpg +0 -0
- klasifikasi-model.py +70 -0
- model_klasifikasi_terbaik.pkl +3 -0
- model_regresi_terbaik.pkl +3 -0
- perintah deploy azure.txt +1 -0
- regresi-model.py +65 -0
- solusi streamlit.txt +7 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
Langkah[[:space:]]deployment[[:space:]]huggingface.docx filter=lfs diff=lfs merge=lfs -text
|
Langkah deployment huggingface.docx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1985069be28c22236f454b5a98e56bff6c0c05186729bdccec63231bbe193244
|
3 |
+
size 4460836
|
data science.jpg
ADDED
![]() |
klasifikasi-model.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Mengimpor library
|
2 |
+
import pandas as pd
|
3 |
+
from PIL import Image
|
4 |
+
import requests
|
5 |
+
from io import BytesIO
|
6 |
+
import streamlit as st
|
7 |
+
import pickle
|
8 |
+
|
9 |
+
# Menghilangkan warning
|
10 |
+
import warnings
|
11 |
+
warnings.filterwarnings("ignore")
|
12 |
+
|
13 |
+
# Menulis judul
|
14 |
+
st.markdown("<h1 style='text-align: center; '> Model Klasifikasi (Beli/Tidak) </h1>", unsafe_allow_html=True)
|
15 |
+
st.markdown('---'*10)
|
16 |
+
|
17 |
+
|
18 |
+
# Fungsi untuk prediksi
|
19 |
+
def final_prediction(values, model):
|
20 |
+
global prediction
|
21 |
+
prediction = model.predict(values)
|
22 |
+
return prediction
|
23 |
+
|
24 |
+
# Ini merupakan fungsi utama
|
25 |
+
def main():
|
26 |
+
|
27 |
+
# Nilai awal
|
28 |
+
usia = 25
|
29 |
+
gaji = 80000
|
30 |
+
|
31 |
+
with st.container():
|
32 |
+
col1, col2 = st.columns(2)
|
33 |
+
with col1:
|
34 |
+
usia = st.number_input('Usia', value=usia)
|
35 |
+
with col2:
|
36 |
+
gaji = st.number_input('Estimasi Gaji', value=gaji)
|
37 |
+
|
38 |
+
|
39 |
+
st.markdown('---'*10)
|
40 |
+
|
41 |
+
kelamin = st.selectbox('Jenis Kelamin', ('Laki', 'Perempuan'))
|
42 |
+
|
43 |
+
data = {
|
44 |
+
'Kelamin': kelamin,
|
45 |
+
'Usia':usia,
|
46 |
+
'EstimasiGaji': gaji
|
47 |
+
}
|
48 |
+
|
49 |
+
kolom = list(data.keys())
|
50 |
+
|
51 |
+
df_final = pd.DataFrame([data.values()],columns=kolom)
|
52 |
+
|
53 |
+
# load model
|
54 |
+
my_model = pickle.load(open('model_klasifikasi_terbaik.pkl', 'rb'))
|
55 |
+
|
56 |
+
# Predict
|
57 |
+
result = int(final_prediction(df_final, my_model))
|
58 |
+
|
59 |
+
hasil = []
|
60 |
+
if result==0:
|
61 |
+
hasil='Tidak Beli'
|
62 |
+
else:
|
63 |
+
hasil='Beli'
|
64 |
+
|
65 |
+
st.markdown('---'*10)
|
66 |
+
|
67 |
+
st.write('<center><b><h3>Predicted Beli/Tidak= ', hasil,'</b></h3>', unsafe_allow_html=True)
|
68 |
+
|
69 |
+
if __name__ == '__main__':
|
70 |
+
main()
|
model_klasifikasi_terbaik.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f7a8fdc89c90172d74e87ff3872572bd3df1362adc419e42a311a656787586d7
|
3 |
+
size 35643
|
model_regresi_terbaik.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2af9cd6f82edd214dba16a106f1b8d361ef2bd59fc9b760050dd3271a187c6e4
|
3 |
+
size 485271
|
perintah deploy azure.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
python -m streamlit run app.py --server.port 8000 --server.address 0.0.0.0
|
regresi-model.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Mengimpor library
|
2 |
+
import pandas as pd
|
3 |
+
import streamlit as st
|
4 |
+
import pickle
|
5 |
+
|
6 |
+
# Menghilangkan warning
|
7 |
+
import warnings
|
8 |
+
warnings.filterwarnings("ignore")
|
9 |
+
|
10 |
+
# Menulis judul
|
11 |
+
st.markdown("<h1 style='text-align: center; '> Model Regresi </h1>", unsafe_allow_html=True)
|
12 |
+
st.markdown('---'*10)
|
13 |
+
|
14 |
+
|
15 |
+
# Fungsi untuk prediksi
|
16 |
+
def final_prediction(values, model):
|
17 |
+
global prediction
|
18 |
+
prediction = model.predict(values)
|
19 |
+
return prediction
|
20 |
+
|
21 |
+
# Ini merupakan fungsi utama
|
22 |
+
def main():
|
23 |
+
|
24 |
+
# Nilai awal
|
25 |
+
rd = 150000.2
|
26 |
+
adm = 140000.3
|
27 |
+
mkt = 300000.1
|
28 |
+
|
29 |
+
with st.container():
|
30 |
+
col1, col2, col3 = st.columns(3)
|
31 |
+
with col1:
|
32 |
+
rd = st.number_input('R&D', value=rd)
|
33 |
+
with col2:
|
34 |
+
adm = st.number_input('Administrasi', value=adm)
|
35 |
+
with col3:
|
36 |
+
mkt = st.number_input('Marketing', value=mkt)
|
37 |
+
|
38 |
+
|
39 |
+
st.markdown('---'*10)
|
40 |
+
|
41 |
+
wly = st.selectbox('Lokasi', ('New York', 'California', 'Florida'))
|
42 |
+
|
43 |
+
data = {
|
44 |
+
'R&D': rd,
|
45 |
+
'Administrasi': adm,
|
46 |
+
'Marketing': mkt,
|
47 |
+
'Wilayah': wly,
|
48 |
+
}
|
49 |
+
|
50 |
+
kolom = list(data.keys())
|
51 |
+
|
52 |
+
df_final = pd.DataFrame([data.values()],columns=kolom)
|
53 |
+
|
54 |
+
# load model
|
55 |
+
my_model = pickle.load(open('model_regresi_terbaik.pkl', 'rb'))
|
56 |
+
|
57 |
+
# Predict
|
58 |
+
result = round(float(final_prediction(df_final, my_model)),2)
|
59 |
+
|
60 |
+
st.markdown('---'*10)
|
61 |
+
|
62 |
+
st.write('<center><b><h3>Predicted Profit= ', result,'</b></h3>', unsafe_allow_html=True)
|
63 |
+
|
64 |
+
if __name__ == '__main__':
|
65 |
+
main()
|
solusi streamlit.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
1. Cari streamlit-script.py
|
2 |
+
dia ada di folder anaconda3
|
3 |
+
|
4 |
+
2. ubah
|
5 |
+
from streamlit.cli import main
|
6 |
+
menjadi
|
7 |
+
from streamlit.web.cli import main
|