brails.imputers.knn_imputer.knn_imputer module
- class brails.imputers.knn_imputer.knn_imputer.KnnImputer
Bases:
Imputation
Imputes dataset based on k-nearest neighbors in the feature-agmented space. Sequentially generate inventory
- Attributes:
- n_pw (int):
The number of possible worlds (i.e. samples or realizations) batch_size (int):
The number of batches for sequential generation. If non-sequential, this variable is not used
- gen_method (str):
Select “sequential” or “non-sequential” (one-shot). The latter is faster but does not generate the spatial correlation
- seed (int):
For reproducibility
Methods:
- category_in_df_to_indices(bldg_properties_df, mask)
- clustering(bldg_properties_encoded, bldg_geometries_df, nbldg_per_cluster=500, seed=0)
- geospatial_knn(bldg_properties_encoded, mask, bldg_geometries_df)
- impute(input_inventory: AssetInventory, n_possible_worlds=1, create_correlation=True, exclude_features=[], seed=1, batch_size=50, k_nn=5) AssetInventory
Imputate an Asset Inventory
- Args:
input_inventory (AssetInventory): the inventory
- Returns:
AssetInventory: a new asset inventory with missing data imputed
- invetory_to_df(inventory)
Convert inventory class to df
- Args:
- inventory (AssetInventory):
the id of the asset
- sequential_imputer(sample_dic, mp_dic, bldg_impu_subset, mask_impu_subset, bldg_inde_subset, column_names, corrMat, bldg_prel_subset, bldg_geom_subset, nbrs_G, trainY_G_list, is_category, npp, gen_method='sequential')
- update_inventory(inventory, sample_dic, label_encoders, is_category)