Spaces:
Sleeping
Sleeping
| import joblib | |
| import gradio as gr | |
| import numpy as np | |
| # Load the pre-trained model | |
| model = joblib.load("house_price_model.pkl") | |
| # Define a prediction function | |
| def predict_price(area): | |
| # Convert input to the correct format | |
| area_array = np.array([[float(area)]]) # Reshape to 2D array | |
| predicted_price = model.predict(area_array) | |
| return f"The predicted price for {area} sq ft house is ${predicted_price[0]:,.2f}" | |
| # Create a Gradio interface | |
| interface = gr.Interface( | |
| fn=predict_price, # Function to call for predictions | |
| inputs=gr.Number(label="Enter Area (sq ft)"), # Input field | |
| outputs=gr.Textbox(label="Predicted Price"), # Output display | |
| title="House Price Prediction", | |
| description="Enter the area of a house (in square feet), and this application will predict its price." | |
| ) | |
| # Launch the app | |
| interface.launch() | |