import gradio as gr | |
import joblib | |
# 加载训练好的模型 | |
model = joblib.load('lottery_predictor_model.pkl') # 这里假设你已经训练好并保存了模型 | |
# 定义预测函数 | |
def predict(lottery_period, date): | |
# 将期号和日期转化为模型需要的特征(这只是一个示例,实际中你需要处理数据) | |
features = [lottery_period, date] | |
prediction = model.predict([features]) # 使用模型进行预测 | |
return f"Predicted numbers for {lottery_period} on {date} are: {prediction}" | |
# 创建 Gradio 接口 | |
demo = gr.Interface(fn=predict, | |
inputs=[gr.Textbox(label="Lottery Period"), gr.Textbox(label="Date")], | |
outputs="text") | |
# 启动界面 | |
demo.launch() | |