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()