File size: 944 Bytes
4f59094
763a979
4f59094
 
 
6a2c3c8
4f59094
763a979
4f59094
 
76cef3f
4f59094
763a979
852a9d5
76cef3f
 
23d8057
 
 
 
 
 
 
6a2c3c8
4f59094
 
 
 
 
 
23d8057
7e493b4
 
4f59094
 
 
 
 
 
 
 
6a2c3c8
 
14a63f7
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
import altair

import gradio as gr
from math import sqrt
import matplotlib

matplotlib.use("Agg")

import matplotlib.pyplot as plt
import numpy as np
# import plotly.express as px
import pandas as pd

df_pre = pd.read_csv('data')
y = df_pre['audience']

filename = 'model.pkl'
loaded_rf_model = pickle.load(open(filename, 'rb'))
X_test = pd.DataFrame(
    data={'saba': [300, 200, 3030, 400], 
          'date_ymd': [20230328, 20230329, 20230330, 20230331]}
)
y_pred_ = loaded_rf_model.predict(X_test, num_iteration=gbm.best_iteration)

def outbreak(date):
  if date:
    # start_day = start_day
    # final_day = date
    # x = np.arange(start_day, final_day + 1)
    fig = plt.figure()
    plt.plot(y_pred_)
    plt.title("audience")
    plt.ylabel("audience")
    plt.xlabel("Days since Day 0")
    return fig

demo = gr.Interface(
    fn=outbreak,
    inputs='checkbox',
    outputs=gr.Plot()
)

if __name__ == "__main__":
    demo.launch()