import joblib import pandas as pd def predict_price(size, bedrooms, age): """Predicts house price based on input features.""" # Load the model model = joblib.load("house_price_model.pkl") # Create a DataFrame from user input input_data = pd.DataFrame({ 'Size (sq ft)': [size], 'Number of Bedrooms': [bedrooms], 'Age of House (years)': [age] }) # Predict the price using the trained model predicted_price = model.predict(input_data)[0] # Return the prediction return {"predicted_price": predicted_price}