Adding gbis to output

This commit is contained in:
Khalim Conn-Kowlessar 2024-03-16 14:51:39 +00:00
parent 6423ab2fac
commit 4e077053cd

View file

@ -3247,6 +3247,9 @@ def get_property_type_and_built_form(property_meta, ha_name):
elif ha_name == "HA49":
property_type = property_meta["Property Class"].strip()
built_form = None
elif ha_name == "HA50":
property_type = PROPERTY_TYPE_LOOKUP[ha_name].get(property_meta["Property Type"].strip())
built_form = None
elif ha_name == "HA54":
property_type = property_meta["Property Type"]
built_form = None
@ -5685,12 +5688,6 @@ def fml_analysis(loader):
fuck_this["roof_classiciation"] = fuck_this.apply(lambda x: classify_loft(x), axis=1)
# fuck_this["construction-age-band"] = fuck_this["construction-age-band"].apply(
# lambda x: EPCDataProcessor.clean_construction_age_band(x)
# )
#
# fuck_this['age_lower_bound'] = fuck_this['construction-age-band'].apply(extract_lower_bound)
had_survey = fuck_this[fuck_this["estimated"] == False]
# proportion with a survey:
@ -5716,10 +5713,6 @@ def fml_analysis(loader):
]
# Characterise no CIGA check needed
ciga_check_needed = had_survey[
had_survey["ECO Eligibility"].str.contains("subject to ciga")
].copy()
ciga_check_passed = had_survey[had_survey["ECO Eligibility"] == "eco4 - passed ciga"]
# These should be treated the same as one that have passed their ciga checks, from a detection perspective
ciga_check_passed_eligible = ciga_check_passed[
@ -5743,20 +5736,60 @@ def fml_analysis(loader):
# differ between variables; floor and wall type errors occur in ~10-15% of EPCs,
# compared with ~5% for wall insulation and glazing performance
ciga_check_needed = had_survey[
had_survey["ECO Eligibility"].str.contains("subject to ciga")
].copy()
ciga_check_needed_eligible = ciga_check_needed[
(ciga_check_needed["walls-description"].str.lower().str.contains("cavity") == True) &
(ciga_check_needed["roof_classiciation"].isin(["high", "medium"])) &
(ciga_check_needed["current-energy-efficiency"].astype(float) <= 80)
]
# Finally, characterise gbis properties. Some of the business might look like ECO4 work, whereas we then
# qualify what actually looks like gbis
gbis_identified = had_survey[
had_survey["ECO Eligibility"] == "gbis"
].copy()
gbis_looks_like_eco4 = gbis_identified[
(gbis_identified["walls-description"].isin(no_ciga_cavity_descriptions)) &
(gbis_identified["roof_classiciation"].isin(["high", "medium"])) &
(gbis_identified["current-energy-efficiency"].astype(float) <= 80) &
(
(
(gbis_identified["property-type"] == "House") &
(gbis_identified["built-form"] != "Mid-Terrace")
) | (
(gbis_identified["property-type"] == "Bungalow") &
(gbis_identified["built-form"].isin(["Detached"]))
)
)
]
gbis_qualified = gbis_identified[
(gbis_identified["walls-description"].isin(no_ciga_cavity_descriptions)) &
(gbis_identified["current-energy-efficiency"].astype(float) <= 80) &
(~gbis_identified["asset_list_row_id"].isin(gbis_looks_like_eco4["asset_list_row_id"].values))
]
ciga_check_expectation = np.round(ciga_check_needed_eligible.shape[0] * ha_ciga_pass_rate)
without_ciga_expectation = no_ciga_check_needed_eligible.shape[0]
passed_ciga_expectation = ciga_check_passed_eligible.shape[0]
identified_as_gbis_looks_like_eco4 = gbis_looks_like_eco4.shape[0]
# Need to add on the non-ciga
total_expectation = ciga_check_expectation + without_ciga_expectation + passed_ciga_expectation
total_eco4_expectation = (
ciga_check_expectation +
without_ciga_expectation +
passed_ciga_expectation +
identified_as_gbis_looks_like_eco4
)
total_gbis_expectation = no_ciga_check_needed_eligible_gbis.shape[0]
no_ciga_check_needed_actually_gbis = no_ciga_check_needed_eligible_gbis.shape[0]
gbis_qualified = gbis_qualified.shape[0]
total_gbis_expectation = no_ciga_check_needed_actually_gbis + gbis_qualified
if proportion_with_survey < 100:
# We estimate the rest
@ -5805,14 +5838,38 @@ def fml_analysis(loader):
without_survey_eco4.shape[0] * (total_gbis_expectation / no_ciga_check_needed.shape[0])
)
total_expectation = (
total_expectation +
# And gbis
without_survey_gbis = fuck_this[
(fuck_this["estimated"] == True) &
(fuck_this["ECO Eligibility"] == "gbis")
]
if without_survey_gbis.empty:
without_survey_identified_as_gbis_qualified = 0
without_survey_identified_as_gbis_eco4 = 0
else:
# We apply the same conversion rate as the properties with a survey
without_survey_identified_as_gbis_qualified = np.round(
without_survey_gbis.shape[0] * (gbis_qualified / gbis_identified.shape[0])
)
without_survey_identified_as_gbis_eco4 = np.round(
without_survey_eco4.shape[0] * (identified_as_gbis_looks_like_eco4 / gbis_identified.shape[0])
)
total_eco4_expectation = (
total_eco4_expectation +
without_survey_without_ciga_expected +
without_survey_passed_ciga_expected +
without_survey_eco4_expected
without_survey_eco4_expected +
without_survey_identified_as_gbis_eco4
)
total_gbis_expectation = total_gbis_expectation + without_survey_gbis_expected
total_gbis_expectation = (
total_gbis_expectation +
without_survey_gbis_expected +
without_survey_identified_as_gbis_qualified
)
surveys = loader.data[ha_name]["survey_list"]
sold_now = 0
@ -5829,9 +5886,8 @@ def fml_analysis(loader):
"Original ECO4 Estimate - Remaining": original_remaining,
"Postcode List - Remaining": postcode_list_remaining,
# "Of which sold": sales_since_nov,
"Of which ECO4 Eligible - Remaining": int(total_expectation),
"Of which ECO4 Eligible - Remaining": int(total_eco4_expectation),
"Of which GBIS Eligibile - Remaining": int(total_gbis_expectation),
# "Proportion with a survey": proportion_with_survey,
}
)