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()