File size: 1,089 Bytes
df0843b 2db7de7 4b0bb56 2db7de7 df0843b 28e1c65 4b0bb56 df0843b 2db7de7 df0843b 28e1c65 2db7de7 df0843b 2db7de7 |
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 |
import gradio as gr
import joblib
from huggingface_hub import hf_hub_download
import xgboost as xgb
import numpy as np
# 从 Hugging Face 下载模型
model_path = hf_hub_download(repo_id="YDluffy/lottery_prediction", filename="lottery_xgboost_model.json")
model = xgb.XGBRegressor()
model.load_model(model_path)
# 预测函数
def predict_lottery(year, period, num1, num2, num3, num4, num5, num6, special):
features = np.array([[year, period, num1, num2, num3, num4, num5, num6, special]])
prediction = model.predict(features)
return prediction
# 创建 Gradio Web 界面
iface = gr.Interface(
fn=predict_lottery,
inputs=[
gr.Number(label="年份"), gr.Number(label="期数"),
gr.Number(label="号码1"), gr.Number(label="号码2"), gr.Number(label="号码3"),
gr.Number(label="号码4"), gr.Number(label="号码5"), gr.Number(label="号码6"),
gr.Number(label="特别号码")
],
outputs="text",
title="六合彩预测模型",
description="输入期号和历史开奖号码,预测下一期开奖"
)
iface.launch()
|