File size: 1,422 Bytes
2b31d20
 
 
 
2648181
238c1b2
 
 
2b31d20
 
238c1b2
2b31d20
0c8aa82
2648181
2b31d20
cf7d20a
 
2648181
2b31d20
f3a8dae
2b31d20
 
 
 
 
 
 
d15ae3d
2b31d20
0c8aa82
2b31d20
44b18ec
2b31d20
 
44b18ec
2b31d20
 
5c2e636
0c8aa82
 
 
9c4dbd0
2b31d20
 
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
import streamlit as st
import joblib
import pandas as pd
import numpy as np
from statsmodels.tsa.statespace.varmax import VARMAX
import matplotlib.pyplot as plt
import statsmodels.api as sm

# Load the pre-trained model
fitted_model = joblib.load('modelling_all123.sav')

# Streamlit App
st.title("Aplikasi Prediksi Harga Bawang")

# Date Range Input
start_date = st.date_input("Pilih Tanggal Mulai", pd.to_datetime('2023-12-01'))
end_date = st.date_input("Select End Date", pd.to_datetime('2023-12-30'))

# Make predictions based on user input
predict = fitted_model.get_prediction(start=start_date, end=end_date, dynamic=True)
predictions = predict.predicted_mean
predictions['Harga Bawang'] = predictions['Harga Bawang'].round()
predictions.columns = ['Prediction Harga Bawang',
                        'Prediction T2M',
                        'Prediction WS10M_RANGE',
                        'Prediction PRECTOTCORR']
predictions = predictions.abs()
predictions = predictions.set_index(pd.date_range(start=start_date, periods=len(predictions)))
# Display Predictions Table
st.subheader("Hasil Prediksi")
st.write(predictions)

# Plotting Predictions
fig, ax = plt.subplots(figsize=(10, 6))

for column in predictions.columns:
    ax.plot(predictions.index, predictions[column], label=column)

ax.set_xlabel("Tanggal")
ax.set_ylabel("Hasil Prediksi")
ax.set_title("Prediksi")

# Show plot in Streamlit
st.pyplot(fig)