import gradio as gr import joblib # Use pickle if your model is in .pkl format import numpy as np # Load the trained model model_path = "mobile_price_model.joblib" # Change to your file name if using .pkl model = joblib.load(model_path) # Define the prediction function def predict_price(battery_power, ram, px_width, px_height): """Predicts the mobile price category based on input features.""" features = np.array([[battery_power, ram, px_width, px_height]]) # Adjust as needed prediction = model.predict(features) return f"Predicted Price Category: {prediction[0]}" # Create Gradio Interface inputs = [ gr.Number(label="Battery Power (mAh)"), gr.Number(label="RAM (MB)"), gr.Number(label="Pixel Width"), gr.Number(label="Pixel Height") ] output = gr.Textbox(label="Price Category") app = gr.Interface(fn=predict_price, inputs=inputs, outputs=output, title="📱 Mobile Price Prediction") # Run the app app.launch()