davidkariuki's picture
Use this script to run the model - look in Suburbs.csv and Areas.csv to find the correct format for your suburb and area
1058710
import pandas as pd
from joblib import load
# Load the trained model
model = load('bestmodelyet.joblib')
# Load the label encoders
le_area = load('le_area.joblib')
le_suburb = load('le_suburb.joblib')
# Get user input
property_type = int(input("Enter the Property type (0 for Apartment, 1 for Townhouse, 2 for House): "))
area = input("Enter the Area: ")
suburb = input("Enter the Suburb: ")
bedrooms = float(input("Enter the number of Bedrooms: "))
bathrooms = float(input("Enter the number of Bathrooms: "))
garages = float(input("Enter the number of Garages: "))
ngparking = int(input("Enter the number of dedicated non-garage parking spots (if none, enter 0): "))
floor_size = int(input("Enter the floor size: "))
pool = int(input("Enter 1 if there is a Pool, 0 otherwise: "))
garden = int(input("Enter 1 if there is a Garden, 0 otherwise: "))
study = int(input("Enter 1 if there is a Study, 0 otherwise: "))
pets = int(input("Enter 1 if Pets are allowed, 0 otherwise: "))
furnished = int(input("Enter 1 if the property is Furnished, 0 otherwise: "))
fibre = int(input("Enter 1 if there is Fibre internet, 0 otherwise: "))
# Transform the user input
area_encoded = le_area.transform([area])
suburb_encoded = le_suburb.transform([suburb])
# Create a dataframe from the user input
df = pd.DataFrame({
'Property_type': [property_type],
'Area': area_encoded,
'Suburb': suburb_encoded,
'Bedrooms': [bedrooms],
'Bathrooms': [bathrooms],
'Garages': [garages],
'nGparking': [ngparking],
'floor_size': [floor_size],
'Pool': [pool],
'Garden': [garden],
'Study': [study],
'Pets': [pets],
'Furnished': [furnished],
'Fibre': [fibre]
})
# Predict the rent
predicted_rent = model.predict(df)
# Print the predicted rent
print(f"The predicted rent is: {predicted_rent[0]}")