File size: 2,226 Bytes
9f47e0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import streamlit as st
import pandas as pd
import numpy as np
import pickle
import json


# Load All Files

with open('model.pkl', 'rb') as file_1:
  pipeline = pickle.load(file_1)

def run():

    st.title('Wine Quality Prediction')


    with st.form(key='form_heart_failure'):
        type = st.selectbox('Red/White Wine?', ('red','white'))
        fixed = st.number_input('Level of Fixed Acidity', min_value=3.0, max_value=20., value=5.,step=.1)
        volatile = st.number_input('Level of Volatile Acidity', min_value=.01, max_value=2., value=1.,step=.01)
        citric = st.number_input('Level of Citric Acid', min_value=.0, max_value=2., value=1.,step=.01)
        sugar = st.number_input('Level of Residual Sugar', min_value=.1, max_value=80., value=1.,step=.1)
        chlorides = st.number_input('Level of Chlorides', min_value=.001, max_value=1., value=.001,step=.001)
        free = st.number_input('Level of Free Sulfur Dioxide', min_value=1, max_value=300, value=20,step=1)
        total = st.number_input('Level of Total Sullfur Dioxide', min_value=5, max_value=450, value=100,step=1)
        density = st.number_input('Level of Density', min_value=.8, max_value=1.2, value=.9,step=.001)
        pH = st.number_input('Level of pH', min_value=2., max_value=5., value=2.5,step=.1)
        sulphates = st.number_input('Level of Sulphates', min_value=.1, max_value=3., value=1.,step=.1)
        alcohol = st.number_input('Level of Alcohol', min_value=5., max_value=20., value=10., step=.1)
        
        submitted = st.form_submit_button('Predict')


    data_inf = {
        'type': type,
        'fixed_acidity': fixed,
        'volatile_acidity': volatile,
        'citric_acid': citric,
        'residual_sugar' : sugar,
        'chlorides': chlorides,
        'free_sulfur_dioxide': free,
        'total_sulfur_dioxide': total,
        'density': density,
        'pH': pH,
        'sulphates': sulphates,
        'alcohol': alcohol 
        }

    data_inf = pd.DataFrame([data_inf])
    st.dataframe(data_inf)

    if submitted:
        # Predict using Model

        y_pred_inf = pipeline.predict(data_inf)
        st.write('Hasil prediksi Model : ', y_pred_inf)



if __name__ == '__main__':
    run()