File size: 889 Bytes
b65d0c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
34
35
36
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()