htmlutils.write_image(plt)
htmlutils.close_section()

poly_features_obj = PolynomialFeatures(app_train, app_test)
poly_features, poly_features_test, poly_target, poly_names = poly_features_obj.get_polynomial_features(
    ['EXT_SOURCE_1', 'EXT_SOURCE_2', 'EXT_SOURCE_3', 'DAYS_BIRTH'])
htmlutils.write_text(f"Polynomial features shape: {poly_features.shape}")
htmlutils.write_text(f"Polynomial features name: {poly_names[:15]}")
htmlutils.close_section()
poly_features = pd.DataFrame(poly_features, columns=poly_names)
poly_features['TARGET'] = poly_target
poly_corrs = poly_features.corr()['TARGET'].sort_values()
htmlutils.write_dataframe('Most negative correlations', poly_corrs.head(10))
htmlutils.write_dataframe('Most positive correlations', poly_corrs.tail(5))
htmlutils.close_section()
app_train_poly, app_test_poly = poly_features_obj.append_data_polynom_features(
)
htmlutils.write_text(
    f"Training data with polynomial feature shape: {app_train_poly.shape}")
htmlutils.write_text(
    f"Test data with polynomial features shape: {app_test_poly.shape}")
htmlutils.close_section()

domain_features_obj = DomainFeatures(app_train, app_test)
app_train_domain, app_test_domain = domain_features_obj.get_domain_features()
plt.figure(figsize=(12, 20))
for i, feature in enumerate([
        'CREDIT_INCOME_PERCENT', 'ANNUITY_INCOME_PERCENT', 'CREDIT_TERM',
        'DAYS_EMPLOYED_PERCENT'
]):
    plt.subplot(4, 1, i + 1)
    sns.kdeplot(app_train_domain.loc[app_train_domain['TARGET'] == 0, feature],