ntam0001 commited on
Commit
6ac6ef4
1 Parent(s): ec43e35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -30,26 +30,29 @@ property_type_mapping = {
30
  }
31
 
32
  def transform_data(size_sqm, number_of_bedrooms, number_of_bathrooms, number_of_floors, parking_space, location, property_type):
33
- # Prepare the input array
34
  x = np.zeros(len(data_columns))
 
 
35
  x[0] = size_sqm
36
  x[1] = number_of_bedrooms
37
  x[2] = number_of_bathrooms
38
  x[3] = number_of_floors
39
- x[4] = parking_space
40
 
41
  # Apply location mapping
42
  if location in location_mapping:
43
- loc_index = data_columns.index(f"Location_{location}")
44
  x[loc_index] = 1
45
 
46
  # Apply property type mapping
47
  if property_type in property_type_mapping:
48
- prop_index = data_columns.index(f"Property_Type_{property_type}")
49
  x[prop_index] = 1
50
 
51
  return np.array([x])
52
 
 
53
  def predict(size_sqm, number_of_bedrooms, number_of_bathrooms, number_of_floors, parking_space, location, property_type):
54
  # Transform input data
55
  input_data_transformed = transform_data(size_sqm, number_of_bedrooms, number_of_bathrooms, number_of_floors, parking_space, location, property_type)
@@ -66,9 +69,11 @@ inputs = [
66
  gr.Number(label="Number of Floors", value=0),
67
  gr.Number(label="Parking Space", value=0),
68
  gr.Dropdown(choices=list(location_mapping.keys()), label="Location"),
69
- gr.Dropdown(choices=list(property_type_mapping.keys()), label="Property Type")
 
70
  ]
71
 
 
72
  outputs = gr.Textbox(label="Prediction (FRW)")
73
 
74
  # Footer content
 
30
  }
31
 
32
  def transform_data(size_sqm, number_of_bedrooms, number_of_bathrooms, number_of_floors, parking_space, location, property_type):
33
+ # Prepare the input array with zeros
34
  x = np.zeros(len(data_columns))
35
+
36
+ # Assign input values to the corresponding columns
37
  x[0] = size_sqm
38
  x[1] = number_of_bedrooms
39
  x[2] = number_of_bathrooms
40
  x[3] = number_of_floors
41
+ x[5] = parking_space # Ensure that parking_space aligns with the correct index in your model
42
 
43
  # Apply location mapping
44
  if location in location_mapping:
45
+ loc_index = data_columns.index(location)
46
  x[loc_index] = 1
47
 
48
  # Apply property type mapping
49
  if property_type in property_type_mapping:
50
+ prop_index = data_columns.index(property_type)
51
  x[prop_index] = 1
52
 
53
  return np.array([x])
54
 
55
+
56
  def predict(size_sqm, number_of_bedrooms, number_of_bathrooms, number_of_floors, parking_space, location, property_type):
57
  # Transform input data
58
  input_data_transformed = transform_data(size_sqm, number_of_bedrooms, number_of_bathrooms, number_of_floors, parking_space, location, property_type)
 
69
  gr.Number(label="Number of Floors", value=0),
70
  gr.Number(label="Parking Space", value=0),
71
  gr.Dropdown(choices=list(location_mapping.keys()), label="Location"),
72
+ gr.Dropdown(choices=list(property_type_mapping.keys()), label="Property Type"),
73
+ # Add new inputs for other columns, like furnished, proximity, etc.
74
  ]
75
 
76
+
77
  outputs = gr.Textbox(label="Prediction (FRW)")
78
 
79
  # Footer content