Spaces:
Runtime error
Runtime error
Download app.py from soni0391s/game-predection: direct link, hf CLI and curl.
- Browser
- Download file 874 Bytes
-
https://huggingface.co/spaces/soni0391s/game-predection/resolve/main/app.py
- Command line
-
hf download hf://spaces/soni0391s/game-predection/app.py
-
curl -L -o app.py https://huggingface.co/spaces/soni0391s/game-predection/resolve/main/app.py
874 Bytes
| import gradio as gr | |
| import joblib | |
| import numpy as np | |
| # Load trained model and scaler | |
| model = joblib.load("game_model.joblib") | |
| scaler = joblib.load("scaler.joblib") | |
| # Prediction function | |
| def predict_sales(na, eu, jp, other, year): | |
| X = np.array([[na, eu, jp, other, year]]) | |
| X_scaled = scaler.transform(X) | |
| pred = model.predict(X_scaled)[0] | |
| return float(pred) | |
| # Gradio 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 (KNN Model)", | |
| description="Enter sales values to predict the total global sales of a game." | |
| ) | |
| interface.launch() | |