davidkariuki
commited on
Commit
•
1058710
1
Parent(s):
dc6c9ff
Use this script to run the model - look in Suburbs.csv and Areas.csv to find the correct format for your suburb and area
Browse files
test.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
from joblib import load
|
3 |
+
|
4 |
+
# Load the trained model
|
5 |
+
model = load('bestmodelyet.joblib')
|
6 |
+
|
7 |
+
# Load the label encoders
|
8 |
+
le_area = load('le_area.joblib')
|
9 |
+
le_suburb = load('le_suburb.joblib')
|
10 |
+
|
11 |
+
# Get user input
|
12 |
+
property_type = int(input("Enter the Property type (0 for Apartment, 1 for Townhouse, 2 for House): "))
|
13 |
+
area = input("Enter the Area: ")
|
14 |
+
suburb = input("Enter the Suburb: ")
|
15 |
+
bedrooms = float(input("Enter the number of Bedrooms: "))
|
16 |
+
bathrooms = float(input("Enter the number of Bathrooms: "))
|
17 |
+
garages = float(input("Enter the number of Garages: "))
|
18 |
+
ngparking = int(input("Enter the number of dedicated non-garage parking spots (if none, enter 0): "))
|
19 |
+
floor_size = int(input("Enter the floor size: "))
|
20 |
+
pool = int(input("Enter 1 if there is a Pool, 0 otherwise: "))
|
21 |
+
garden = int(input("Enter 1 if there is a Garden, 0 otherwise: "))
|
22 |
+
study = int(input("Enter 1 if there is a Study, 0 otherwise: "))
|
23 |
+
pets = int(input("Enter 1 if Pets are allowed, 0 otherwise: "))
|
24 |
+
furnished = int(input("Enter 1 if the property is Furnished, 0 otherwise: "))
|
25 |
+
fibre = int(input("Enter 1 if there is Fibre internet, 0 otherwise: "))
|
26 |
+
|
27 |
+
# Transform the user input
|
28 |
+
area_encoded = le_area.transform([area])
|
29 |
+
suburb_encoded = le_suburb.transform([suburb])
|
30 |
+
|
31 |
+
# Create a dataframe from the user input
|
32 |
+
df = pd.DataFrame({
|
33 |
+
'Property_type': [property_type],
|
34 |
+
'Area': area_encoded,
|
35 |
+
'Suburb': suburb_encoded,
|
36 |
+
'Bedrooms': [bedrooms],
|
37 |
+
'Bathrooms': [bathrooms],
|
38 |
+
'Garages': [garages],
|
39 |
+
'nGparking': [ngparking],
|
40 |
+
'floor_size': [floor_size],
|
41 |
+
'Pool': [pool],
|
42 |
+
'Garden': [garden],
|
43 |
+
'Study': [study],
|
44 |
+
'Pets': [pets],
|
45 |
+
'Furnished': [furnished],
|
46 |
+
'Fibre': [fibre]
|
47 |
+
})
|
48 |
+
|
49 |
+
# Predict the rent
|
50 |
+
predicted_rent = model.predict(df)
|
51 |
+
|
52 |
+
# Print the predicted rent
|
53 |
+
print(f"The predicted rent is: {predicted_rent[0]}")
|