Spaces:
Sleeping
Sleeping
File size: 855 Bytes
dd354d2 | 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 | 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()
|