Download app.py from soni0391s/game-predection: direct link, hf CLI and curl.
- Browser
- Download file 889 Bytes
-
https://huggingface.co/soni0391s/game-predection/resolve/main/app.py
- Command line
-
hf download hf://soni0391s/game-predection/app.py
-
curl -L -o app.py https://huggingface.co/soni0391s/game-predection/resolve/main/app.py
889 Bytes
| import gradio as gr | |
| import joblib | |
| import numpy as np | |
| # Load model and scaler | |
| model = joblib.load("game_model.joblib") | |
| scaler = joblib.load("scaler.joblib") | |
| def predict_sales(na, eu, jp, other, year): | |
| # Convert inputs to numpy array | |
| X = np.array([[na, eu, jp, other, year]]) | |
| # Scale using the fitted scaler | |
| X_scaled = scaler.transform(X) | |
| # Predict | |
| prediction = model.predict(X_scaled)[0] | |
| return float(prediction) | |
| # Build UI | |
| interface = gr.Interface( | |
| fn=predict_sales, | |
| inputs=[ | |
| gr.Number(label="NA_Sales"), | |
| gr.Number(label="EU_Sales"), | |
| gr.Number(label="JP_Sales"), | |
| gr.Number(label="Other_Sales"), | |
| gr.Number(label="Year") | |
| ], | |
| outputs=gr.Number(label="Predicted Global Sales"), | |
| title="Game Sales Predictor", | |
| description="Enter game details to predict total worldwide sales." | |
| ) | |
| interface.launch() | |