mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
prepared sap model dataset
This commit is contained in:
parent
8e65ac05cf
commit
d586441769
1 changed files with 19 additions and 6 deletions
|
|
@ -72,6 +72,7 @@ class SalModel:
|
||||||
self.df = pd.DataFrame(data)
|
self.df = pd.DataFrame(data)
|
||||||
self.cleaner = cleaner
|
self.cleaner = cleaner
|
||||||
|
|
||||||
|
self.model_data = None
|
||||||
self.train_x = None
|
self.train_x = None
|
||||||
self.train_y = None
|
self.train_y = None
|
||||||
self.results = None
|
self.results = None
|
||||||
|
|
@ -128,6 +129,15 @@ class SalModel:
|
||||||
how="left",
|
how="left",
|
||||||
left_on="roof-description",
|
left_on="roof-description",
|
||||||
right_on="original_description"
|
right_on="original_description"
|
||||||
|
).drop(
|
||||||
|
columns=["original_description"]
|
||||||
|
).merge(
|
||||||
|
lighting_proportions,
|
||||||
|
how="left",
|
||||||
|
left_on="lighting-description",
|
||||||
|
right_on="original_description"
|
||||||
|
).drop(
|
||||||
|
columns=["original_description"]
|
||||||
)
|
)
|
||||||
|
|
||||||
return model_data
|
return model_data
|
||||||
|
|
@ -141,13 +151,11 @@ class SalModel:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _clean_numericals(model_data):
|
def _clean_numericals(model_data):
|
||||||
|
|
||||||
for col in ["photo-supply", "multi-glaze-proportion", "low-energy-lighting"]:
|
for col in ["photo-supply", "multi-glaze-proportion", "low-energy-lighting", "number-open-fireplaces"]:
|
||||||
model_data[col] = np.where(
|
model_data[col] = np.where(
|
||||||
model_data[col] == "", "0", model_data["photo-supply"]
|
model_data[col] == "", "0", model_data["photo-supply"]
|
||||||
).astype(float)
|
).astype(float)
|
||||||
|
|
||||||
# We need to clean lighting
|
|
||||||
|
|
||||||
return model_data
|
return model_data
|
||||||
|
|
||||||
def create_dataset(self):
|
def create_dataset(self):
|
||||||
|
|
@ -176,9 +184,9 @@ class SalModel:
|
||||||
exclude_features = ["walls-description", "floor-description", "roof-description", "transaction-type"]
|
exclude_features = ["walls-description", "floor-description", "roof-description", "transaction-type"]
|
||||||
|
|
||||||
features = [
|
features = [
|
||||||
x for x in self.BASE_FEATURES +
|
x for x in self.BASE_FEATURES + self.COMPONENT_FEATURES + [
|
||||||
self.COMPONENT_FEATURES +
|
"walls_u_value", "floor_u_value", "roof_u_value", self.RESPONSE
|
||||||
["walls_u_value", "floor_u_value", "roof_u_value", self.RESPONSE] if x not in exclude_features
|
] if x not in exclude_features
|
||||||
]
|
]
|
||||||
|
|
||||||
model_data = model_data[features]
|
model_data = model_data[features]
|
||||||
|
|
@ -186,6 +194,11 @@ class SalModel:
|
||||||
for col in self.CATEGORICAL_COLS:
|
for col in self.CATEGORICAL_COLS:
|
||||||
model_data[col] = model_data[col].astype('category')
|
model_data[col] = model_data[col].astype('category')
|
||||||
|
|
||||||
|
# Convert response
|
||||||
|
self.model_data[self.RESPONSE] = self.model_data[self.RESPONSE].astype(float)
|
||||||
|
|
||||||
|
self.model_data = model_data
|
||||||
|
|
||||||
def make_training_test(self):
|
def make_training_test(self):
|
||||||
# Split into training and test
|
# Split into training and test
|
||||||
# Dummy data
|
# Dummy data
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue