|
import streamlit as st |
|
import pandas as pd |
|
import numpy as np |
|
import pickle |
|
import json |
|
|
|
|
|
|
|
|
|
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: |
|
|
|
|
|
y_pred_inf = pipeline.predict(data_inf) |
|
st.write('Hasil prediksi Model : ', y_pred_inf) |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
run() |