Spaces:
Sleeping
Sleeping
Download app.py from muhammad998/PricePredictor: direct link, hf CLI and curl.
- Browser
- Download file 855 Bytes
-
https://huggingface.co/spaces/muhammad998/PricePredictor/resolve/main/app.py
- Command line
-
hf download hf://spaces/muhammad998/PricePredictor/app.py
-
curl -L -o app.py https://huggingface.co/spaces/muhammad998/PricePredictor/resolve/main/app.py
855 Bytes
| 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() | |