diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index d2e62ec..4ea9e5a 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
- python-version: '3.11'
+ python-version: '3.12.4'
# ADJUST THIS: install all dependencies (including pdoc)
- run: pip install pipreqs
@@ -52,4 +52,4 @@ jobs:
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
- uses: actions/deploy-pages@v2
+ uses: actions/deploy-pages@v2
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 0bc9d6d..8f94f6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -77,15 +77,11 @@ target/
# exclude real data from source control by default
/data/raw
-/data/processed
/data/interim
/data/external
-# exclude figures until the paper is not on the arxiv
-/figures
-
-# exclude for now, keep later
-/features
+# exclude reports until the paper is not on the arxiv
+/reports
# Mac OS-specific storage files
.DS_Store
@@ -101,27 +97,38 @@ target/
.idea/
cache/
-# Raw country-specific experiment results
-experiments/Dominica
-experiments/Saint Lucia
+# exclude config files but keep Example.yaml
+/config/*
+!/config/Example.yaml
-# Internal reports
-/reports
+# exclude data_preparation from source control by default
+/data_preparation/*
+!/data_preparation/Example
-# Input data preparation scripts
-/scripts
+# exclude data_preparation from source control by default
+/data/generated/*
+!/data/generated/Example
-# Exclude Dominica-specific config
-/config/Dominica.yaml
+# exclude data but keep the Example folder or file
+/data/processed/asset_impacts/*
+!/data/processed/asset_impacts/Example
-# Exclude Saint-Lucia specific config
-/config/SaintLucia.yaml
+/data/processed/household_survey/*
+!/data/processed/household_survey/Example.csv
-# Exclude Nigeria specific config
-/config/Nigeria.yaml
+data/processed/population_impacts/*
+!/data/processed/population_impacts/Example
-# Exclude reports
-/reports
+# exclude drafts folder
+/drafts
+
+# exclude notebooks but keep the Example folder
+/notebooks/*
+!/notebooks/Example
+
+# exclude results and keep only the Example folder
+/results/*
+!/results/Example
-# Exclude experiment results
-/results
\ No newline at end of file
+# exlcude todo folder
+/todo
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..dc0525a
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,93 @@
+# Contributing
+
+We welcome contributions to the Unbreakable project! Whether you're fixing bugs, adding new features, improving documentation, or providing feedback, your help is appreciated.
+
+## How to Contribute
+
+### 1. Fork the Repository
+
+- Click the **Fork** button at the top right of the [repository page](https://github.com/mikhailsirenko/unbreakable) to create your own copy of the project.
+
+### 2. Clone Your Fork
+
+- Clone your forked repository to your local machine:
+
+ ```bash
+ git clone https://github.com/your-username/unbreakable.git
+ cd unbreakable
+ ```
+
+### 3. Create a New Branch
+
+- Create a new branch for your feature or bug fix:
+
+ ```bash
+ git checkout -b my-feature-branch
+ ```
+
+### 4. Make Changes
+
+- Implement your changes in the codebase.
+- Follow the existing code style and conventions.
+- Include comments and docstrings where appropriate.
+- Update or add documentation as needed.
+
+### 5. Commit Changes
+
+- Stage your changes and commit with a descriptive message:
+
+ ```bash
+ git add .
+ git commit -m "Description of your changes"
+ ```
+
+### 6. Push to Your Fork
+
+- Push your branch to your forked repository on GitHub:
+
+ ```bash
+ git push origin my-feature-branch
+ ```
+
+### 7. Submit a Pull Request
+
+- Go to the original repository and click on **Pull Requests**, then **New Pull Request**.
+- Select your branch from the **compare** dropdown.
+- Provide a clear and descriptive title and description for your pull request.
+- Submit the pull request for review.
+
+## Reporting Issues
+
+- If you encounter a bug or have a feature request, please open an [issue](https://github.com/mikhailsirenko/unbreakable/issues) on GitHub.
+- Provide detailed information about the issue, including steps to reproduce it if applicable.
+
+## Code Style Guidelines
+
+- Follow the existing coding style and structure.
+- Use meaningful variable and function names.
+- Keep functions and classes focused and concise.
+- Write tests for new features or bug fixes when possible.
+
+## Testing
+
+- Ensure that all existing tests pass before submitting a pull request.
+- Add new tests to cover your changes.
+- Run tests using:
+
+ ```bash
+ python -m unittest discover tests
+ ```
+
+## Documentation
+
+- Update the `README.md` or relevant documentation files if your changes affect them.
+- Ensure that code is well-documented with comments and docstrings.
+
+## Communication
+
+- Feel free to contact the project maintainers for guidance.
+- Be respectful and considerate in all interactions.
+
+## License
+
+By contributing to Unbreakable, you agree that your contributions will be licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0).
diff --git a/README.md b/README.md
index 36b279e..a33457e 100644
--- a/README.md
+++ b/README.md
@@ -1,46 +1,225 @@
-# What is unbreakable?
-Unbreakable is a stochastic simulation model for assessing the resilience of households to natural disasters.
+# unbreakable
-## Background
+Unbreakable is a simulation tool that helps estimate how disasters affect households, showing how different social groups recover and how policies can reduce the damage.
-## Model Overview
+## Motivation
-## Getting Started
+Natural disasters are becoming more frequent and intense, with a significant rise in events over recent decades. According to the [UNDRR](https://www.undrr.org/media/48008/download?startDownload=20240603), the number of recorded disasters nearly doubled from 4,212 between 1980-1999 to 7,348 between 2000-2019. In 2023, extreme weather events caused massive economic losses of 280 million USD ([PreventionWeb](https://www.preventionweb.net/news/europe-spotlight-global-economic-losses-catastrophes-reach-usd-280-billion-2023)) and impacted 93.1 million people globally ([EM-DAT](https://civil-protection-knowledge-network.europa.eu/media/2023-disasters-numbers-significant-year-disaster-impact)).
+
+Disasters do not affect all populations equally. Lower-income households are more vulnerable, as they often lack adequate resources for protection and recovery ([Bangalore et al., 2016](http://hdl.handle.net/10986/25335); [Walsh & Hallegatte, 2020](https://link.springer.com/article/10.1007/s41885-019-00047-x)). Vulnerable groups like female-headed households and people with disabilities are also disproportionately impacted.
+
+Beyond economic loss, disasters affect overall well-being, which isn’t fully captured by traditional metrics. To better understand these broader impacts, we need alternative approaches.
+
+Unbreakable is a simulation tool designed to:
+
+1. Estimate disaster impacts on different social groups.
+2. Analyze effects across economic, poverty, and well-being dimensions.
+3. Explore how policy interventions can reduce these impacts.
+
+## Project Structure
-### Prerequisites
-The model is developed in Python 3.9 and relies on standard packages. The easiest way to install them is to use [Anaconda](https://www.anaconda.com/products/individual) with the `requirements.txt` file:
```bash
-conda create --name unbreakable --file requirements.txt
+unbreakable/
+├── config/ # Simulation model run configuration files
+├── data/ # Data directory
+│ ├── generated/ # Generated data, e.g., pre-computed reconstruction rates
+│ ├── processed/ # Processed data used as an input into simulation model
+│ └── raw/ # Raw data
+├── data_preparation/ # Data preprocessing notebooks
+├── docs/ # Documentation
+├── notebooks/ # Analysis notebooks
+├── unbreakable/ # Main package
+│ ├── analysis/ # Analysis modules
+│ ├── experiments/ # Experiment setup and runner
+│ ├── modules/ # Core simulation modules
+│ └── utils/ # Utility functions mainly for data preparation
+├── results/ # Simulation results
+├── tests/ # Unit tests
+├── CONTRIBUTING.md # Guidelines for contributing to the project
+├── README.md # Project overview and instructions
+├── requirements.txt # List of dependencies
+└── setup.py # Installation script
```
-### Installation
-Clone the repository from GitHub using the following:
-```bash
-git clone https://github.com/mikhailsirenko/unbreakable
+## Installation
+
+1. Clone the repository:
+
+ ```bash
+ git clone https://github.com/mikhailsirenko/unbreakable.git
+ cd unbreakable
+ ```
+
+2. Create a virtual environment with conda (optional but recommended):
+
+ ```bash
+ conda create --name unbreakable
+ conda activate unbreakable
+ ```
+
+3. Install dependencies:
+
+ ```bash
+ pip install -r requirements.txt
+ ```
+
+4. Install the package in editable mode:
+
+ ```bash
+ pip install -e .
+ ```
+
+## Basic Usage
+
+To run a simulation:
+
+```python
+python unbreakable/example.py
```
-### Repository Structure
+The `example.py` script requires specifying disaster types, their timing (immediate or at a specific year, e.g., year 5), and return periods. By default, `example.py` simulates the immediate impact of a flood with a return period of 100 years.
+You also need to specify the number of replications with `n_scenarios`. The model is stochastic, and to obtain robust results, multiple replications are necessary. In each run, the model randomly selects which households are affected and the amount of assets they lose. By default, `n_scenarios = 1,000`.
-### Usage
-You run the model from the command line with the default parameters using:
-```bash
-python unbreakable/run.py
+For a more comprehensive description, please refer to the User Manual or the detailed documentation in the `docs/` directory.
+
+## Data
+
+The model uses three main types of data:
+
+1. Household survey data (`data/processed/household_survey/`),
+2. Asset impact data (`data/processed/asset_impact/`), or
+3. Population impact data (`data/processed/population_impacts/`)
+
+Household survey data contains information on households' socio-economic attributes and dwelling materials. Asset impact data provides information about potential damage to total assets of a spatial unit (e.g., a district). Population impacts data contains information about the number of individuals affected by a disaster.
+
+The repository contains example data of all types which were generated with `unbreakable/utils/data_generator.py`.
+
+## Configuration
+
+Simulations are configured using YAML files in the `config/` directory. The `Example.yaml` file provides an example configuration. You can modify this file to set up your simulation parameters, including:
+
+- Macro-economic parameters of the case country.
+- Disaster-related parameters, including whether households would lose their income due to disaster.
+- Which household characteristics must be estimated and randomized.
+- Policy interventions, e.g., adaptive social protection.
+- Uncertainties.
+
+## Model Components
+
+The core model components are located in the `unbreakable/modules/` directory:
+
+- `disaster_impact.py`: Simulates disaster impacts on households.
+- `dwelling_vulnerability.py`: Calculates dwelling vulnerability based on construction materials.
+- `household_recovery.py`: Models household recovery processes over time.
+- `policy_interventions.py`: Implements policy interventions such as cash transfers or retrofitting.
+- `socioeconomic_impact.py`: Assesses economic, poverty, and well-being impacts.
+
+## How It Works
+
+The Unbreakable Model stored in `model.py` follows a step-by-step process to simulate disaster events and their impacts. The basic idea is that we pass the households' data frame through a set of functions representing different stages of the simulation. The pipeline works as follows:
+
+1. **Data Loading and Preparation**:
+ - Load household data, disaster impact data, and reconstruction rates.
+ - Prepare the household data, estimate missing attributes (e.g., savings) and randomize them.
+
+2. **Disaster Impact Calculation**:
+ - Calculate compound impacts if multiple disaster events are specified.
+ - Determine the years until the next event for each disaster.
+
+3. **Spatial Unit Iteration**:
+ - The model iterates over each specified spatial unit (e.g., regions, cities).
+
+4. **Disaster Event Simulation**:
+ - For each spatial unit, the model simulates multiple disaster events sequentially.
+ - Each event's impact is calculated based on either the percentage of population affected or Probable Maximum Loss (PML).
+
+5. **Household Impact Distribution**:
+ - The disaster impact is distributed among households based on their vulnerability.
+ - Households are classified as affected or unaffected.
+
+6. **Recovery Simulation**:
+ - Calculate or use precomputed household reconstruction rates.
+ - Estimate the socioeconomic impact on households, including consumption, poverty and well-being losses.
+
+7. **Policy Interventions**:
+ - The model allows for the application of policy interventions, such as adaptive social protection or retrofitting policies.
+
+8. **Cumulative Impact Tracking**:
+ - The model keeps track of cumulative impacts across multiple events.
+
+9. **Outcome Calculation**:
+ - Calculate various metrics for each spatial unit after all events have been simulated.
+
+This pipeline allows for the simulation of multiple disasters over time, assessment of cumulative impacts, and evaluation of policy interventions at various stages.
+
+```mermaid
+graph TD
+ A[Start] --> B[Load and Prepare Data]
+ B --> C[Calculate Compound Impact]
+ C --> D[Calculate Years Until Next Event]
+ D --> E[Iterate Over Spatial Units]
+ E --> F[Iterate Over Disaster Events]
+ F --> G[Simulate Disaster]
+ G --> H[Apply Policy Interventions]
+ H --> I[Estimate Socioeconomic Impact]
+ I --> J[Update Cumulative Impact]
+ J --> K{More Events?}
+ K -->|Yes| F
+ K -->|No| L[Calculate Outcomes for Spatial Unit]
+ L --> M{More Spatial Units?}
+ M -->|Yes| E
+ M -->|No| N[End]
+
+ subgraph Simulate Disaster
+ G1[Calculate Dwelling Vulnerability]
+ G2[Distribute Disaster Impact]
+ G3[Determine Affected Households]
+ G4[Calculate Reconstruction Rates]
+ G1 --> G2 --> G3 --> G4
+ end
```
-## Documentation
-Detailed model documentation, including function descriptions and usage examples, is available [here](https://mikhailsirenko.github.io/unbreakable/src.html).
+## Analysis
+
+Analysis modules in `unbreakable/analysis/` include:
+
+- `distributional_metrics.py`: Analyzes impacts across different groups
+- `economic_metrics.py`: Calculates economic impact metrics
+- `metric_calculator.py`: Analyzes household-level impacts
+- `poverty_metrics.py`: Computes poverty-related metrics
+- `resilience_metrics.py`: Calculates resilience indicators
+
+Jupyter notebooks for analysis are available in the `notebooks/` directory. These notebooks demonstrate how to interpret the simulation outcomes and visualize results.
+
+## Results
+
+Simulation results are stored in the `results/` directory. The `Example/` subdirectory contains example results.
+
+## Note for Users
+
+This model uses algorithms and data analysis techniques. While it strives for accuracy, real-world scenarios may differ. Use the results only as a guide for decision-making, always complemented by expert knowledge and local context.
## Contributing
-## Authors
-*Mikhail Sirenko* and *Bramka Arga Jafino*.
+We welcome contributions to the Unbreakable project. Please refer to our [`CONTRIBUTING.md`](CONTRIBUTING.md) for information on submitting pull requests, reporting issues, or suggesting improvements.
## License
-The project license is CC BY 3.0 IGO.
+
+This project is licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0).
+
+## Citation
+
+1. If you use this tool in your research, please cite it as:
+
+ Sirenko, M. & Jafino, B. A. (2024). Unbreakable: A Simulation Tool for Estimating Socio-Economic Impacts of Disaster on Households. GitHub repository:
Convert outcomes dict into a data frame.
\n\nArgs:\n results (tuple): The results of the experiments in the EMA Workbench format.\n add_policies (bool): Whether to add policy values to the data frame.\n add_uncertainties (bool): Whether to add uncertainty values to the data frame.
\n\nReturns:\n pd.DataFrame: Outcomes data frame.
\n", "signature": "(\tresults: tuple,\tadd_policies: bool,\tadd_uncertainties: bool) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.analyse.get_spatial_outcomes": {"fullname": "src.data.analyse.get_spatial_outcomes", "modulename": "src.data.analyse", "qualname": "get_spatial_outcomes", "kind": "function", "doc": "\n", "signature": "(\toutcomes: pandas.core.frame.DataFrame,\toutcomes_of_interest: list = [],\tcountry: str = 'Saint Lucia',\taggregation: str = 'mean') -> geopandas.geodataframe.GeoDataFrame:", "funcdef": "def"}, "src.data.analyse.get_policy_effectiveness_tab": {"fullname": "src.data.analyse.get_policy_effectiveness_tab", "modulename": "src.data.analyse", "qualname": "get_policy_effectiveness_tab", "kind": "function", "doc": "\n", "signature": "(outcomes: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare": {"fullname": "src.data.prepare", "modulename": "src.data.prepare", "kind": "module", "doc": "\n"}, "src.data.prepare.prepare_asset_damage": {"fullname": "src.data.prepare.prepare_asset_damage", "modulename": "src.data.prepare", "qualname": "prepare_asset_damage", "kind": "function", "doc": "Prepare district-level asset damage data and save it into a XLSX file.
\n", "signature": "(country: str, scale: str, return_period: int = 100) -> None:", "funcdef": "def"}, "src.data.prepare.prepare_household_survey": {"fullname": "src.data.prepare.prepare_household_survey", "modulename": "src.data.prepare", "qualname": "prepare_household_survey", "kind": "function", "doc": "Prepare data for the simulation model.
\n\ncountry : str
\n\nValueError\n If the country is not supported.
\n", "signature": "(country: str) -> None:", "funcdef": "def"}, "src.data.prepare.load_data": {"fullname": "src.data.prepare.load_data", "modulename": "src.data.prepare", "qualname": "load_data", "kind": "function", "doc": "Load the raw data.
\n", "signature": "(print_statistics: bool = True) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.start_pipeline": {"fullname": "src.data.prepare.start_pipeline", "modulename": "src.data.prepare", "qualname": "start_pipeline", "kind": "function", "doc": "Start the data processing pipeline.
\n", "signature": "(data: pandas.core.frame.DataFrame):", "funcdef": "def"}, "src.data.prepare.add_is_rural_column": {"fullname": "src.data.prepare.add_is_rural_column", "modulename": "src.data.prepare", "qualname": "add_is_rural_column", "kind": "function", "doc": "Create a new column that indicates whether the household is rural or not.
\n", "signature": "(\tdata: pandas.core.frame.DataFrame,\tprint_statistics: bool = True) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.rename_assets_column": {"fullname": "src.data.prepare.rename_assets_column", "modulename": "src.data.prepare", "qualname": "rename_assets_column", "kind": "function", "doc": "Rename the assets column to be more descriptive.
\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.rename_other_columns": {"fullname": "src.data.prepare.rename_other_columns", "modulename": "src.data.prepare", "qualname": "rename_other_columns", "kind": "function", "doc": "Rename a set of columns. See function for details.
\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.calculate_household_attributes": {"fullname": "src.data.prepare.calculate_household_attributes", "modulename": "src.data.prepare", "qualname": "calculate_household_attributes", "kind": "function", "doc": "\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.get_bank_or_credit_union": {"fullname": "src.data.prepare.get_bank_or_credit_union", "modulename": "src.data.prepare", "qualname": "get_bank_or_credit_union", "kind": "function", "doc": "\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.decode_demographic_attributes": {"fullname": "src.data.prepare.decode_demographic_attributes", "modulename": "src.data.prepare", "qualname": "decode_demographic_attributes", "kind": "function", "doc": "Decode the demographic attributes.
\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.decode_income_attributes": {"fullname": "src.data.prepare.decode_income_attributes", "modulename": "src.data.prepare", "qualname": "decode_income_attributes", "kind": "function", "doc": "Decode the income-related attributes.
\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.calculate_income_attributes": {"fullname": "src.data.prepare.calculate_income_attributes", "modulename": "src.data.prepare", "qualname": "calculate_income_attributes", "kind": "function", "doc": "\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.decode_housing_attributes": {"fullname": "src.data.prepare.decode_housing_attributes", "modulename": "src.data.prepare", "qualname": "decode_housing_attributes", "kind": "function", "doc": "Decode the housing-related attributes.
\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.add_housing_attributes": {"fullname": "src.data.prepare.add_housing_attributes", "modulename": "src.data.prepare", "qualname": "add_housing_attributes", "kind": "function", "doc": "Introduce new housing attributes.
\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.add_insurance_attributes": {"fullname": "src.data.prepare.add_insurance_attributes", "modulename": "src.data.prepare", "qualname": "add_insurance_attributes", "kind": "function", "doc": "\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.calculate_housing_attributes": {"fullname": "src.data.prepare.calculate_housing_attributes", "modulename": "src.data.prepare", "qualname": "calculate_housing_attributes", "kind": "function", "doc": "\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.calculate_poverty_attributes": {"fullname": "src.data.prepare.calculate_poverty_attributes", "modulename": "src.data.prepare", "qualname": "calculate_poverty_attributes", "kind": "function", "doc": "\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.assign_housing_vulnerability": {"fullname": "src.data.prepare.assign_housing_vulnerability", "modulename": "src.data.prepare", "qualname": "assign_housing_vulnerability", "kind": "function", "doc": "\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.subset_columns": {"fullname": "src.data.prepare.subset_columns", "modulename": "src.data.prepare", "qualname": "subset_columns", "kind": "function", "doc": "Subset columns of interest.
\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.check_columns": {"fullname": "src.data.prepare.check_columns", "modulename": "src.data.prepare", "qualname": "check_columns", "kind": "function", "doc": "\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.add_missing_columns": {"fullname": "src.data.prepare.add_missing_columns", "modulename": "src.data.prepare", "qualname": "add_missing_columns", "kind": "function", "doc": "Manually add missing columns to the data.
\n", "signature": "(\tdata: pandas.core.frame.DataFrame,\tmissing_columns: list) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.merge_districts": {"fullname": "src.data.prepare.merge_districts", "modulename": "src.data.prepare", "qualname": "merge_districts", "kind": "function", "doc": "\n", "signature": "(data: pandas.core.frame.DataFrame) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.data.prepare.exponential_regression": {"fullname": "src.data.prepare.exponential_regression", "modulename": "src.data.prepare", "qualname": "exponential_regression", "kind": "function", "doc": "\n", "signature": "(\tdata: pandas.core.frame.DataFrame,\tX_column: str,\ty_column: str,\tweights: <built-in function array> = None,\treturn_model: bool = False) -> tuple[numpy.array, float]:", "funcdef": "def"}, "src.data.prepare.polynomial_regression": {"fullname": "src.data.prepare.polynomial_regression", "modulename": "src.data.prepare", "qualname": "polynomial_regression", "kind": "function", "doc": "\n", "signature": "(\tdata: pandas.core.frame.DataFrame,\tX_column: str,\ty_column: str,\tpower: int,\tweights: <built-in function array> = None,\tX_new: <built-in function array> = None,\tX_start: int = 0,\tX_end: int = 40,\tX_num: int = 100):", "funcdef": "def"}, "src.data.prepare.linear_regression": {"fullname": "src.data.prepare.linear_regression", "modulename": "src.data.prepare", "qualname": "linear_regression", "kind": "function", "doc": "Do a linear regression on the data and return the predicted values, the coefficient and the r2 score.
\n", "signature": "(\tdata: pandas.core.frame.DataFrame,\tX_column: str,\ty_column: str,\tweights: <built-in function array> = None,\treturn_model: bool = False) -> tuple[numpy.array, float, float]:", "funcdef": "def"}, "src.data.read": {"fullname": "src.data.read", "modulename": "src.data.read", "kind": "module", "doc": "\n"}, "src.data.read.read_asset_damage": {"fullname": "src.data.read.read_asset_damage", "modulename": "src.data.read", "qualname": "read_asset_damage", "kind": "function", "doc": "Read asset damage for all districts from a XLSX file and load it into the memory.
\n", "signature": "(country) -> None:", "funcdef": "def"}, "src.data.read.get_asset_damage": {"fullname": "src.data.read.get_asset_damage", "modulename": "src.data.read", "qualname": "get_asset_damage", "kind": "function", "doc": "Get asset damage for a specific district.
\n\nArgs:\n all_damage (pd.DataFrame): Asset damage data for all districts.\n scale (str): Scale of the analysis. Only district
is supported.\n district (str): District name.\n return_period (int): Return period.\n print_statistics (bool): Print the statistics.
Returns:\n tuple: Event damage, total asset stock, expected loss fraction.
\n\nRaises:\n ValueError: If the scale is not district
.
\n ValueError: If the expected loss fraction is greater than 1.
Reads household survey from a CSV file.
\n\nArgs:\n country (str): Country name.
\n\nReturns:\n pd.DataFrame: Household survey data.
\n\nRaises:\n ValueError: If the country is not Saint Lucia
.
Add columns/outcomes of interest from affected households
to the households
dataframe.
Calculate outcomes of interest from the simulation model.
\n\nArgs:\n households (pd.DataFrame): Households data frame.\n event_damage (float): Event damage.\n total_asset_stock (float): Total asset stock.\n expected_loss_fraction (float): Expected loss fraction.\n average_productivity (float): Average productivity.\n n_years (float): Number of years to consider for calculations (same as for optimization algorithm).
\n\nReturns:\n dict: Outcomes of interest.
\n", "signature": "(\thouseholds,\tevent_damage,\ttotal_asset_stock,\texpected_loss_fraction,\taverage_productivity,\tn_years) -> dict:", "funcdef": "def"}, "src.data.write.find_poor": {"fullname": "src.data.write.find_poor", "modulename": "src.data.write", "qualname": "find_poor", "kind": "function", "doc": "Get the poor at the beginning of the simulation and the poor at the end of the simulation
\n\nArgs:\n households (pd.DataFrame): Household dataframe\n poverty_line (float): Poverty line
\n\nReturns:\n tuple: Number of poor at the beginning of the simulation, number of new poor at the end of the simulation, and the new poor dataframe
\n", "signature": "(\thouseholds: pandas.core.frame.DataFrame,\tpoverty_line: float,\tn_years: int) -> tuple:", "funcdef": "def"}, "src.data.write.get_people_by_years_in_poverty": {"fullname": "src.data.write.get_people_by_years_in_poverty", "modulename": "src.data.write", "qualname": "get_people_by_years_in_poverty", "kind": "function", "doc": "Get the number of people in poverty for each year in poverty.
\n\nArgs:\n new_poor (pd.DataFrame): New poor dataframe
\n\nReturns:\n dict: Number of people in poverty for each year in poverty
\n", "signature": "(new_poor: pandas.core.frame.DataFrame) -> dict:", "funcdef": "def"}, "src.data.write.calculate_poverty_gap": {"fullname": "src.data.write.calculate_poverty_gap", "modulename": "src.data.write", "qualname": "calculate_poverty_gap", "kind": "function", "doc": "Calculate the poverty gap at the beginning and at the end of the simulation.
\n\nArgs:\n poor_initial (pd.DataFrame): Poor at the beginning of the simulation\n new_poor (pd.DataFrame): New poor at the end of the simulation\n poverty_line (float): Poverty line\n n_years (int): Number of years of the optimization algorithm
\n\nReturns:\n tuple: Poverty gap at the beginning and at the end of the simulation
\n\nRaises:\n Exception: If the index is duplicated\n Exception: If the poverty gap is greater than 1
\n", "signature": "(\tpoor_initial: pandas.core.frame.DataFrame,\tnew_poor: pandas.core.frame.DataFrame,\tpoverty_line: float,\tn_years: int) -> tuple:", "funcdef": "def"}, "src.data.write.calculate_average_annual_consumption_loss": {"fullname": "src.data.write.calculate_average_annual_consumption_loss", "modulename": "src.data.write", "qualname": "calculate_average_annual_consumption_loss", "kind": "function", "doc": "Get the average annual consumption loss and the average annual consumption loss as a percentage of average annual consumption.
\n\nArgs:\n affected_households (pd.DataFrame): Affected households dataframe\n n_years (int): Number of years of the optimization algorithm
\n\nReturns:\n tuple: Average annual consumption loss and average annual consumption loss as a percentage of average annual consumption
\n\nRaises:\n Exception: If the average annual consumption loss is greater than 1
\n", "signature": "(affected_households: pandas.core.frame.DataFrame, n_years: int) -> tuple:", "funcdef": "def"}, "src.data.write.calculate_resilience": {"fullname": "src.data.write.calculate_resilience", "modulename": "src.data.write", "qualname": "calculate_resilience", "kind": "function", "doc": "Calculate the resilience of the affected households.
\n\nArgs:\n affected_households (pd.DataFrame): Affected households dataframe\n pml (float): Probable maximum loss
\n\nReturns:\n tuple: Resilience and number of times resilience is greater than 1
\n\nRaises:\n Exception: If the total consumption loss is 0
\n", "signature": "(affected_households: pandas.core.frame.DataFrame, pml: float) -> tuple:", "funcdef": "def"}, "src.model": {"fullname": "src.model", "modulename": "src.model", "kind": "module", "doc": "\n"}, "src.model.initialize_model": {"fullname": "src.model.initialize_model", "modulename": "src.model", "qualname": "initialize_model", "kind": "function", "doc": "Initialize the model by reading household survey and asset damage files.
\n\nArgs:\n country (str): Country name.\n min_households (int): Minimum number of households that we need to have in a sample to be representative.
\n\nReturns:\n tuple: Household survey and asset damage files.
\n", "signature": "(country: str, min_households: int) -> tuple:", "funcdef": "def"}, "src.model.run_model": {"fullname": "src.model.run_model", "modulename": "src.model", "qualname": "run_model", "kind": "function", "doc": "Run the model.
\n", "signature": "(**kwargs):", "funcdef": "def"}, "src.modules": {"fullname": "src.modules", "modulename": "src.modules", "kind": "module", "doc": "\n"}, "src.modules.households": {"fullname": "src.modules.households", "modulename": "src.modules.households", "kind": "module", "doc": "\n"}, "src.modules.households.duplicate_households": {"fullname": "src.modules.households.duplicate_households", "modulename": "src.modules.households", "qualname": "duplicate_households", "kind": "function", "doc": "Duplicates households if the number of households is less than min_households
threshold.
Args:\n household_survey (pd.DataFrame): Household survey data.\n min_households (int): Minimum number of households.
\n\nReturns:\n pd.DataFrame: Household survey data with duplicated households.
\n\nRaises:\n ValueError: If the total weights after duplication is not equal to the initial total weights.
\n", "signature": "(\thousehold_survey: pandas.core.frame.DataFrame,\tmin_households: int) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.modules.households.calculate_average_productivity": {"fullname": "src.modules.households.calculate_average_productivity", "modulename": "src.modules.households", "qualname": "calculate_average_productivity", "kind": "function", "doc": "Calculate average productivity as aeinc \\ k_house_ae.
\n\nArgs:\n households (pd.DataFrame): Household survey data.\n print_statistics (bool, optional): Whether to print the average productivity. Defaults to False.
\n\nReturns:\n float: Average productivity.
\n", "signature": "(households: pandas.core.frame.DataFrame, print_statistics: bool) -> float:", "funcdef": "def"}, "src.modules.households.adjust_assets_and_expenditure": {"fullname": "src.modules.households.adjust_assets_and_expenditure", "modulename": "src.modules.households", "qualname": "adjust_assets_and_expenditure", "kind": "function", "doc": "Adjust assets and expenditure of household to match data of asset damage file.
\n\nThere can be a mismatch between the data in the household survey and the of the asset damage.\nThe latest was created independently.
\n\nArgs:\n households (pd.DataFrame): Household survey data.\n total_asset_stock (float): Total asset stock.\n poverty_line (float): Poverty line.\n indigence_line (float): Indigence line.\n print_statistics (bool, optional): Whether to print the statistics. Defaults to False.
\n\nReturns:\n pd.DataFrame: Household survey data with adjusted assets and expenditure.
\n", "signature": "(\thouseholds: pandas.core.frame.DataFrame,\ttotal_asset_stock: float,\tpoverty_line: float,\tindigence_line: float,\tprint_statistics: bool) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.modules.households.calculate_pml": {"fullname": "src.modules.households.calculate_pml", "modulename": "src.modules.households", "qualname": "calculate_pml", "kind": "function", "doc": "Calculate probable maximum loss as a product of population weight, effective capital stock and expected loss fraction.
\n\nArgs:\n households (pd.DataFrame): Household survey data.\n expected_loss_fraction (float): Expected loss fraction.\n print_statistics (bool, optional): Whether to print the statistics. Defaults to False.
\n\nReturns:\n pd.DataFrame: Household survey data with probable maximum loss.
\n", "signature": "(\thouseholds: pandas.core.frame.DataFrame,\texpected_loss_fraction: float,\tprint_statistics: bool) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.modules.households.select_district": {"fullname": "src.modules.households.select_district", "modulename": "src.modules.households", "qualname": "select_district", "kind": "function", "doc": "Select households for a specific district.
\n", "signature": "(\thousehold_survey: pandas.core.frame.DataFrame,\tdistrict: str) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.modules.households.estimate_savings": {"fullname": "src.modules.households.estimate_savings", "modulename": "src.modules.households", "qualname": "estimate_savings", "kind": "function", "doc": "Estimate savings of households.
\n\nWe assume that savings are a product of expenditure and saving rate with Gaussian noise.
\n\nArgs:\n households (pd.DataFrame): Household survey data for a specific district.\n saving_rate (float): Saving rate.\n estimate_savings_params (dict): Parameters for estimating savings function.
\n\nReturns:\n pd.DataFrame: Household survey data with estimated savings.
\n", "signature": "(\thouseholds: pandas.core.frame.DataFrame,\tsaving_rate: float,\testimate_savings_params: dict) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.modules.households.set_vulnerability": {"fullname": "src.modules.households.set_vulnerability", "modulename": "src.modules.households", "qualname": "set_vulnerability", "kind": "function", "doc": "Set vulnerability of households.
\n\nVulnerability can be random or based on v_init
with uniform noise.
Args:\n households (pd.DataFrame): Household survey data for a specific district.\n is_vulnerability_random (bool): If True, vulnerability is random.
\n\nReturns:\n pd.DataFrame: Household survey data with assigned vulnerability.
\n\nRaises:\n ValueError: If the distribution is not supported.
\n", "signature": "(\thouseholds: pandas.core.frame.DataFrame,\tis_vulnerability_random: bool,\tset_vulnerability_params: dict) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.modules.households.calculate_exposure": {"fullname": "src.modules.households.calculate_exposure", "modulename": "src.modules.households", "qualname": "calculate_exposure", "kind": "function", "doc": "Calculate exposure of households.
\n\nExposure is a function of poverty bias, effective capital stock, \nvulnerability and probable maximum loss.
\n\nArgs:\n households (pd.DataFrame): Household survey data for a specific district.\n poverty_bias (float): Poverty bias.\n calculate_exposure_params (dict): Parameters for calculating exposure function.\n print_statistics (bool): If True, print statistics.
\n\nReturns:\n pd.DataFrame: Household survey data with calculated exposure.
\n", "signature": "(\thouseholds: pandas.core.frame.DataFrame,\tpoverty_bias: float,\tcalculate_exposure_params: dict,\tprint_statistics: bool) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.modules.households.determine_affected": {"fullname": "src.modules.households.determine_affected", "modulename": "src.modules.households", "qualname": "determine_affected", "kind": "function", "doc": "Determines affected households.
\n\nWe assume that all households have the same probability of being affected, \nbut based on fa
calculated in calculate_exposure
.
Args:\n households (pd.DataFrame): Household survey data for a specific district.\n determine_affected_params (dict): Parameters for determining affected households function.
\n\nReturns:\n tuple: Household survey data with determined affected households and asset loss for each household.
\n\nRaises:\n ValueError: If total asset is less than PML.\n ValueError: If no mask was found.
\n", "signature": "(\thouseholds: pandas.core.frame.DataFrame,\tdetermine_affected_params: dict) -> tuple:", "funcdef": "def"}, "src.modules.households.apply_individual_policy": {"fullname": "src.modules.households.apply_individual_policy", "modulename": "src.modules.households", "qualname": "apply_individual_policy", "kind": "function", "doc": "Apply a policy to a specific target group.
\n\nArgs:\n households (pd.DataFrame): Household survey data for a specific district.\n my_policy (str): Policy to apply. The structure of the policy is target_group
+top_up
in a single string. target_group
can be all
, poor
, poor_near_poor1.25
, poor_near_poor2.0
, and the top_up
0, 10, 30 or 50.
Returns:\n tuple: Household survey data with applied policy and affected households.
\n", "signature": "(households: pandas.core.frame.DataFrame, my_policy: str) -> tuple:", "funcdef": "def"}, "src.modules.optimize": {"fullname": "src.modules.optimize", "modulename": "src.modules.optimize", "kind": "module", "doc": "\n"}, "src.modules.optimize.run_optimization": {"fullname": "src.modules.optimize.run_optimization", "modulename": "src.modules.optimize", "qualname": "run_optimization", "kind": "function", "doc": "This function calculates the recovery rate for each affected household.
\n\nArgs:\n affected_households (pd.DataFrame): A data frame containing the affected households.\n consumption_utility (float): The coefficient of relative risk aversion.\n discount_rate (float): The discount rate.\n average_productivity (float): The average productivity.\n optimization_timestep (float): The timestep for the optimization.\n n_years (int): The number of years in the optimization algorithm.
\n\nReturns:\n pd.DataFrame: A data frame containing the affected households with the recovery rate.
\n", "signature": "(\taffected_households: pandas.core.frame.DataFrame,\tconsumption_utility: float,\tdiscount_rate: float,\taverage_productivity: float,\toptimization_timestep: float,\tn_years: int) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, "src.modules.optimize.optimize_recovery_rate": {"fullname": "src.modules.optimize.optimize_recovery_rate", "modulename": "src.modules.optimize", "qualname": "optimize_recovery_rate", "kind": "function", "doc": "\n", "signature": "(\tx,\toptimization_results: pandas.core.frame.DataFrame,\tconsumption_utility: float,\tdiscount_rate: float,\taverage_productivity: float,\toptimization_timestep: float,\tn_years: int) -> float:", "funcdef": "def"}, "src.modules.optimize.integrate_wellbeing": {"fullname": "src.modules.optimize.integrate_wellbeing", "modulename": "src.modules.optimize", "qualname": "integrate_wellbeing", "kind": "function", "doc": "\n", "signature": "(\taffected_households: pandas.core.frame.DataFrame,\tconsumption_utility: float,\tdiscount_rate: float,\tincome_and_expenditure_growth: float,\taverage_productivity: float,\tpoverty_line: float,\tn_years: int,\tadd_income_loss: bool,\tcash_transfer: dict = {}) -> pandas.core.frame.DataFrame:", "funcdef": "def"}}, "docInfo": {"src": {"qualname": 0, "fullname": 1, "annotation": 0, "default_value": 0, "signature": 0, "bases": 0, "doc": 3}, "src.data": {"qualname": 0, "fullname": 2, "annotation": 0, "default_value": 0, "signature": 0, "bases": 0, "doc": 3}, "src.data.analyse": {"qualname": 0, "fullname": 3, "annotation": 0, "default_value": 0, "signature": 0, "bases": 0, "doc": 3}, "src.data.analyse.prepare_outcomes": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 59, "bases": 0, "doc": 62}, "src.data.analyse.get_spatial_outcomes": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 110, "bases": 0, "doc": 3}, "src.data.analyse.get_policy_effectiveness_tab": {"qualname": 4, "fullname": 7, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 3}, "src.data.prepare": {"qualname": 0, "fullname": 3, "annotation": 0, "default_value": 0, "signature": 0, "bases": 0, "doc": 3}, "src.data.prepare.prepare_asset_damage": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 47, "bases": 0, "doc": 16}, "src.data.prepare.prepare_household_survey": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 19, "bases": 0, "doc": 30}, "src.data.prepare.load_data": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 42, "bases": 0, "doc": 7}, "src.data.prepare.start_pipeline": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 31, "bases": 0, "doc": 8}, "src.data.prepare.add_is_rural_column": {"qualname": 4, "fullname": 7, "annotation": 0, "default_value": 0, "signature": 69, "bases": 0, "doc": 16}, "src.data.prepare.rename_assets_column": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 11}, "src.data.prepare.rename_other_columns": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 12}, "src.data.prepare.calculate_household_attributes": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 3}, "src.data.prepare.get_bank_or_credit_union": {"qualname": 5, "fullname": 8, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 3}, "src.data.prepare.decode_demographic_attributes": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 7}, "src.data.prepare.decode_income_attributes": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 8}, "src.data.prepare.calculate_income_attributes": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 3}, "src.data.prepare.decode_housing_attributes": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 8}, "src.data.prepare.add_housing_attributes": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 7}, "src.data.prepare.add_insurance_attributes": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 3}, "src.data.prepare.calculate_housing_attributes": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 3}, "src.data.prepare.calculate_poverty_attributes": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 3}, "src.data.prepare.assign_housing_vulnerability": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 3}, "src.data.prepare.subset_columns": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 7}, "src.data.prepare.check_columns": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 3}, "src.data.prepare.add_missing_columns": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 62, "bases": 0, "doc": 10}, "src.data.prepare.merge_districts": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 49, "bases": 0, "doc": 3}, "src.data.prepare.exponential_regression": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 132, "bases": 0, "doc": 3}, "src.data.prepare.polynomial_regression": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 199, "bases": 0, "doc": 3}, "src.data.prepare.linear_regression": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 138, "bases": 0, "doc": 21}, "src.data.read": {"qualname": 0, "fullname": 3, "annotation": 0, "default_value": 0, "signature": 0, "bases": 0, "doc": 3}, "src.data.read.read_asset_damage": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 14, "bases": 0, "doc": 19}, "src.data.read.get_asset_damage": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 82, "bases": 0, "doc": 94}, "src.data.read.read_household_survey": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 34, "bases": 0, "doc": 42}, "src.data.visualise": {"qualname": 0, "fullname": 3, "annotation": 0, "default_value": 0, "signature": 0, "bases": 0, "doc": 3}, "src.data.visualise.rainclouds": {"qualname": 1, "fullname": 4, "annotation": 0, "default_value": 0, "signature": 143, "bases": 0, "doc": 3}, "src.data.visualise.bivariate_choropleth": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 51, "bases": 0, "doc": 3}, "src.data.visualise.nine_quadrants_plot": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 33, "bases": 0, "doc": 3}, "src.data.visualise.get_colors": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 11, "bases": 0, "doc": 3}, "src.data.visualise.bin_data": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 39, "bases": 0, "doc": 3}, "src.data.write": {"qualname": 0, "fullname": 3, "annotation": 0, "default_value": 0, "signature": 0, "bases": 0, "doc": 3}, "src.data.write.add_columns": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 77, "bases": 0, "doc": 18}, "src.data.write.get_outcomes": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 52, "bases": 0, "doc": 74}, "src.data.write.find_poor": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 59, "bases": 0, "doc": 63}, "src.data.write.get_people_by_years_in_poverty": {"qualname": 6, "fullname": 9, "annotation": 0, "default_value": 0, "signature": 35, "bases": 0, "doc": 40}, "src.data.write.calculate_poverty_gap": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 87, "bases": 0, "doc": 96}, "src.data.write.calculate_average_annual_consumption_loss": {"qualname": 5, "fullname": 8, "annotation": 0, "default_value": 0, "signature": 46, "bases": 0, "doc": 78}, "src.data.write.calculate_resilience": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 45, "bases": 0, "doc": 52}, "src.model": {"qualname": 0, "fullname": 2, "annotation": 0, "default_value": 0, "signature": 0, "bases": 0, "doc": 3}, "src.model.initialize_model": {"qualname": 2, "fullname": 4, "annotation": 0, "default_value": 0, "signature": 30, "bases": 0, "doc": 53}, "src.model.run_model": {"qualname": 2, "fullname": 4, "annotation": 0, "default_value": 0, "signature": 13, "bases": 0, "doc": 6}, "src.modules": {"qualname": 0, "fullname": 2, "annotation": 0, "default_value": 0, "signature": 0, "bases": 0, "doc": 3}, "src.modules.households": {"qualname": 0, "fullname": 3, "annotation": 0, "default_value": 0, "signature": 0, "bases": 0, "doc": 3}, "src.modules.households.duplicate_households": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 63, "bases": 0, "doc": 69}, "src.modules.households.calculate_average_productivity": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 45, "bases": 0, "doc": 44}, "src.modules.households.adjust_assets_and_expenditure": {"qualname": 4, "fullname": 7, "annotation": 0, "default_value": 0, "signature": 99, "bases": 0, "doc": 100}, "src.modules.households.calculate_pml": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 75, "bases": 0, "doc": 65}, "src.modules.households.select_district": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 62, "bases": 0, "doc": 9}, "src.modules.households.estimate_savings": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 75, "bases": 0, "doc": 68}, "src.modules.households.set_vulnerability": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 76, "bases": 0, "doc": 72}, "src.modules.households.calculate_exposure": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 87, "bases": 0, "doc": 76}, "src.modules.households.determine_affected": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 48, "bases": 0, "doc": 95}, "src.modules.households.apply_individual_policy": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 45, "bases": 0, "doc": 99}, "src.modules.optimize": {"qualname": 0, "fullname": 3, "annotation": 0, "default_value": 0, "signature": 0, "bases": 0, "doc": 3}, "src.modules.optimize.run_optimization": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 111, "bases": 0, "doc": 91}, "src.modules.optimize.optimize_recovery_rate": {"qualname": 3, "fullname": 6, "annotation": 0, "default_value": 0, "signature": 102, "bases": 0, "doc": 3}, "src.modules.optimize.integrate_wellbeing": {"qualname": 2, "fullname": 5, "annotation": 0, "default_value": 0, "signature": 157, "bases": 0, "doc": 3}}, "length": 69, "save": true}, "index": {"qualname": {"root": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.prepare.prepare_household_survey": {"tf": 1}}, "df": 3}}}}}, "o": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.households.calculate_average_productivity": {"tf": 1}}, "df": 1}}}}}}}}}}}, "o": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "y": {"docs": {"src.data.analyse.get_policy_effectiveness_tab": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 2}}}, "y": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.prepare.polynomial_regression": {"tf": 1}}, "df": 1}}}}}}}}, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.data.prepare.calculate_poverty_attributes": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}}, "df": 3}}}}}, "o": {"docs": {}, "df": 0, "r": {"docs": {"src.data.write.find_poor": {"tf": 1}}, "df": 1}}}, "i": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.start_pipeline": {"tf": 1}}, "df": 1}}}}}}}, "l": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "t": {"docs": {"src.data.visualise.nine_quadrants_plot": {"tf": 1}}, "df": 1}}}, "e": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.get_people_by_years_in_poverty": {"tf": 1}}, "df": 1}}}}}, "m": {"docs": {}, "df": 0, "l": {"docs": {"src.modules.households.calculate_pml": {"tf": 1}}, "df": 1}}}, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}}, "df": 3}}}}}}}, "t": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {"src.data.prepare.rename_other_columns": {"tf": 1}}, "df": 1}}}}, "r": {"docs": {"src.data.prepare.get_bank_or_credit_union": {"tf": 1}}, "df": 1}, "p": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "z": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}}, "df": 1}}}}}, "e": {"docs": {"src.modules.optimize.optimize_recovery_rate": {"tf": 1}}, "df": 1}}}}}}}}, "g": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.analyse.get_policy_effectiveness_tab": {"tf": 1}, "src.data.prepare.get_bank_or_credit_union": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.visualise.get_colors": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}}, "df": 7}}, "a": {"docs": {}, "df": 0, "p": {"docs": {"src.data.write.calculate_poverty_gap": {"tf": 1}}, "df": 1}}}, "s": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}}, "df": 1}}}}}}, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "y": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}}, "df": 2}}}}, "b": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.subset_columns": {"tf": 1}}, "df": 1}}}}}, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.start_pipeline": {"tf": 1}}, "df": 1}}}}, "e": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.select_district": {"tf": 1}}, "df": 1}}}}, "t": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1}}, "df": 1}}, "a": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "s": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}}, "df": 1}}}}}}}, "e": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.get_policy_effectiveness_tab": {"tf": 1}}, "df": 1}}}}}}}}}}}}, "x": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}}, "df": 1}}}}}}}, "s": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.calculate_exposure": {"tf": 1}}, "df": 1}}}}}, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}}}}}}}}, "s": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}}, "df": 1}}}}}}}}, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "b": {"docs": {"src.data.analyse.get_policy_effectiveness_tab": {"tf": 1}}, "df": 1}}}, "a": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}}, "df": 3, "s": {"docs": {"src.data.prepare.rename_assets_column": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 2}}}, "i": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.assign_housing_vulnerability": {"tf": 1}}, "df": 1}}}}}, "d": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}, "src.data.prepare.add_insurance_attributes": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}}, "df": 5}, "j": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}}}, "t": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.prepare.calculate_household_attributes": {"tf": 1}, "src.data.prepare.decode_demographic_attributes": {"tf": 1}, "src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.calculate_income_attributes": {"tf": 1}, "src.data.prepare.decode_housing_attributes": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}, "src.data.prepare.add_insurance_attributes": {"tf": 1}, "src.data.prepare.calculate_housing_attributes": {"tf": 1}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1}}, "df": 9}}}}}}}}}, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}}, "df": 2}}}}}}, "n": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}}, "df": 1}}}}, "d": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}, "f": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}}}}}}}, "p": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}}}}}, "d": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}}, "df": 3}}}}, "t": {"docs": {}, "df": 0, "a": {"docs": {"src.data.prepare.load_data": {"tf": 1}, "src.data.visualise.bin_data": {"tf": 1}}, "df": 2}}}, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.decode_demographic_attributes": {"tf": 1}, "src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.decode_housing_attributes": {"tf": 1}}, "df": 3}}}}, "m": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {"src.data.prepare.decode_demographic_attributes": {"tf": 1}}, "df": 1}}}}}}}}}, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}}}}}}}}, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.select_district": {"tf": 1}}, "df": 1, "s": {"docs": {"src.data.prepare.merge_districts": {"tf": 1}}, "df": 1}}}}}}}}, "u": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.duplicate_households": {"tf": 1}}, "df": 1}}}}}}}}}, "h": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.prepare.calculate_household_attributes": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}}, "df": 3, "s": {"docs": {"src.modules.households.duplicate_households": {"tf": 1}}, "df": 1}}}}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.data.prepare.decode_housing_attributes": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}, "src.data.prepare.calculate_housing_attributes": {"tf": 1}, "src.data.prepare.assign_housing_vulnerability": {"tf": 1}}, "df": 4}}}}}}}, "l": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.load_data": {"tf": 1}}, "df": 1}}, "s": {"docs": {}, "df": 0, "s": {"docs": {"src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}}, "df": 1}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {"src.data.prepare.linear_regression": {"tf": 1}}, "df": 1}}}}}}, "i": {"docs": {}, "df": 0, "s": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}}, "df": 1}, "n": {"docs": {"src.data.write.get_people_by_years_in_poverty": {"tf": 1}}, "df": 1, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.calculate_income_attributes": {"tf": 1}}, "df": 2}}}}, "s": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.add_insurance_attributes": {"tf": 1}}, "df": 1}}}}}}}, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "z": {"docs": {}, "df": 0, "e": {"docs": {"src.model.initialize_model": {"tf": 1}}, "df": 1}}}}}}}}, "d": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}}}}}}}}, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 1}}}}}}}}}, "r": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}}, "df": 1}}}, "n": {"docs": {"src.model.run_model": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 2}}, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.rename_assets_column": {"tf": 1}, "src.data.prepare.rename_other_columns": {"tf": 1}}, "df": 2}}}}, "g": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}}, "df": 3}}}}}}}}, "a": {"docs": {}, "df": 0, "d": {"docs": {"src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}}, "df": 2}}, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.calculate_resilience": {"tf": 1}}, "df": 1}}}}}}}}, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.optimize.optimize_recovery_rate": {"tf": 1}}, "df": 1}}}}}}}, "a": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "s": {"docs": {"src.data.visualise.rainclouds": {"tf": 1}}, "df": 1}}}}}}}}, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.optimize.optimize_recovery_rate": {"tf": 1}}, "df": 1}}}}, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.rename_assets_column": {"tf": 1}}, "df": 2, "s": {"docs": {"src.data.prepare.rename_other_columns": {"tf": 1}, "src.data.prepare.subset_columns": {"tf": 1}, "src.data.prepare.check_columns": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}}, "df": 5}}}}, "o": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "s": {"docs": {"src.data.visualise.get_colors": {"tf": 1}}, "df": 1}}}}, "n": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}}, "df": 1}}}}}}}}}}, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.calculate_household_attributes": {"tf": 1}, "src.data.prepare.calculate_income_attributes": {"tf": 1}, "src.data.prepare.calculate_housing_attributes": {"tf": 1}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}}, "df": 10}}}}}}}}, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.get_bank_or_credit_union": {"tf": 1}}, "df": 1}}}}}, "h": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "k": {"docs": {"src.data.prepare.check_columns": {"tf": 1}}, "df": 1}}}, "o": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "h": {"docs": {"src.data.visualise.bivariate_choropleth": {"tf": 1}}, "df": 1}}}}}}}}}}, "b": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "k": {"docs": {"src.data.prepare.get_bank_or_credit_union": {"tf": 1}}, "df": 1}}}, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.data.visualise.bivariate_choropleth": {"tf": 1}}, "df": 1}}}}}}}, "n": {"docs": {"src.data.visualise.bin_data": {"tf": 1}}, "df": 1}}, "y": {"docs": {"src.data.write.get_people_by_years_in_poverty": {"tf": 1}}, "df": 1}}, "u": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.get_bank_or_credit_union": {"tf": 1}}, "df": 1}}}}}, "v": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.data.prepare.assign_housing_vulnerability": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}}, "df": 2}}}}}}}}}}}}}, "m": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.data.prepare.add_missing_columns": {"tf": 1}}, "df": 1}}}}}}, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.merge_districts": {"tf": 1}}, "df": 1}}}}, "o": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "l": {"docs": {"src.model.initialize_model": {"tf": 1}, "src.model.run_model": {"tf": 1}}, "df": 2}}}}}, "n": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {"src.data.visualise.nine_quadrants_plot": {"tf": 1}}, "df": 1}}}}, "q": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "s": {"docs": {"src.data.visualise.nine_quadrants_plot": {"tf": 1}}, "df": 1}}}}}}}}}, "f": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "d": {"docs": {"src.data.write.find_poor": {"tf": 1}}, "df": 1}}}}, "y": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "s": {"docs": {"src.data.write.get_people_by_years_in_poverty": {"tf": 1}}, "df": 1}}}}}, "w": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 1}}}}}}}}}}}, "fullname": {"root": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "c": {"docs": {"src": {"tf": 1}, "src.data": {"tf": 1}, "src.data.analyse": {"tf": 1}, "src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.analyse.get_policy_effectiveness_tab": {"tf": 1}, "src.data.prepare": {"tf": 1}, "src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.prepare.load_data": {"tf": 1}, "src.data.prepare.start_pipeline": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.rename_assets_column": {"tf": 1}, "src.data.prepare.rename_other_columns": {"tf": 1}, "src.data.prepare.calculate_household_attributes": {"tf": 1}, "src.data.prepare.get_bank_or_credit_union": {"tf": 1}, "src.data.prepare.decode_demographic_attributes": {"tf": 1}, "src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.calculate_income_attributes": {"tf": 1}, "src.data.prepare.decode_housing_attributes": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}, "src.data.prepare.add_insurance_attributes": {"tf": 1}, "src.data.prepare.calculate_housing_attributes": {"tf": 1}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1}, "src.data.prepare.assign_housing_vulnerability": {"tf": 1}, "src.data.prepare.subset_columns": {"tf": 1}, "src.data.prepare.check_columns": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.prepare.merge_districts": {"tf": 1}, "src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.read": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.visualise": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}, "src.data.visualise.bivariate_choropleth": {"tf": 1}, "src.data.visualise.nine_quadrants_plot": {"tf": 1}, "src.data.visualise.get_colors": {"tf": 1}, "src.data.visualise.bin_data": {"tf": 1}, "src.data.write": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.model": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.model.run_model": {"tf": 1}, "src.modules": {"tf": 1}, "src.modules.households": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.select_district": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 69}}, "p": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}}, "df": 1}}}}}}, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "y": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}}, "df": 2}}}}, "b": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.subset_columns": {"tf": 1}}, "df": 1}}}}}, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.start_pipeline": {"tf": 1}}, "df": 1}}}}, "e": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.select_district": {"tf": 1}}, "df": 1}}}}, "t": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1}}, "df": 1}}, "a": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "s": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}}, "df": 1}}}}}}}, "d": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "a": {"docs": {"src.data": {"tf": 1}, "src.data.analyse": {"tf": 1}, "src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.analyse.get_policy_effectiveness_tab": {"tf": 1}, "src.data.prepare": {"tf": 1}, "src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.prepare.load_data": {"tf": 1.4142135623730951}, "src.data.prepare.start_pipeline": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.rename_assets_column": {"tf": 1}, "src.data.prepare.rename_other_columns": {"tf": 1}, "src.data.prepare.calculate_household_attributes": {"tf": 1}, "src.data.prepare.get_bank_or_credit_union": {"tf": 1}, "src.data.prepare.decode_demographic_attributes": {"tf": 1}, "src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.calculate_income_attributes": {"tf": 1}, "src.data.prepare.decode_housing_attributes": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}, "src.data.prepare.add_insurance_attributes": {"tf": 1}, "src.data.prepare.calculate_housing_attributes": {"tf": 1}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1}, "src.data.prepare.assign_housing_vulnerability": {"tf": 1}, "src.data.prepare.subset_columns": {"tf": 1}, "src.data.prepare.check_columns": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.prepare.merge_districts": {"tf": 1}, "src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.read": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.visualise": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}, "src.data.visualise.bivariate_choropleth": {"tf": 1}, "src.data.visualise.nine_quadrants_plot": {"tf": 1}, "src.data.visualise.get_colors": {"tf": 1}, "src.data.visualise.bin_data": {"tf": 1.4142135623730951}, "src.data.write": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}}, "df": 49}}, "m": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}}, "df": 3}}}}}, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.decode_demographic_attributes": {"tf": 1}, "src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.decode_housing_attributes": {"tf": 1}}, "df": 3}}}}, "m": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {"src.data.prepare.decode_demographic_attributes": {"tf": 1}}, "df": 1}}}}}}}}}, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}}}}}}}}, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.select_district": {"tf": 1}}, "df": 1, "s": {"docs": {"src.data.prepare.merge_districts": {"tf": 1}}, "df": 1}}}}}}}}, "u": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.duplicate_households": {"tf": 1}}, "df": 1}}}}}}}}}, "a": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "y": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {"src.data.analyse": {"tf": 1}, "src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.analyse.get_policy_effectiveness_tab": {"tf": 1}}, "df": 4}}}}}, "n": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}}, "df": 1}}}}, "d": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}, "s": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}}, "df": 3, "s": {"docs": {"src.data.prepare.rename_assets_column": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 2}}}, "i": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.assign_housing_vulnerability": {"tf": 1}}, "df": 1}}}}}, "d": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}, "src.data.prepare.add_insurance_attributes": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}}, "df": 5}, "j": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}}}, "t": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.prepare.calculate_household_attributes": {"tf": 1}, "src.data.prepare.decode_demographic_attributes": {"tf": 1}, "src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.calculate_income_attributes": {"tf": 1}, "src.data.prepare.decode_housing_attributes": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}, "src.data.prepare.add_insurance_attributes": {"tf": 1}, "src.data.prepare.calculate_housing_attributes": {"tf": 1}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1}}, "df": 9}}}}}}}}}, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}}, "df": 2}}}}}}, "f": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}}}}}}}, "p": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}}}}}, "p": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.prepare": {"tf": 1}, "src.data.prepare.prepare_asset_damage": {"tf": 1.4142135623730951}, "src.data.prepare.prepare_household_survey": {"tf": 1.4142135623730951}, "src.data.prepare.load_data": {"tf": 1}, "src.data.prepare.start_pipeline": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.rename_assets_column": {"tf": 1}, "src.data.prepare.rename_other_columns": {"tf": 1}, "src.data.prepare.calculate_household_attributes": {"tf": 1}, "src.data.prepare.get_bank_or_credit_union": {"tf": 1}, "src.data.prepare.decode_demographic_attributes": {"tf": 1}, "src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.calculate_income_attributes": {"tf": 1}, "src.data.prepare.decode_housing_attributes": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}, "src.data.prepare.add_insurance_attributes": {"tf": 1}, "src.data.prepare.calculate_housing_attributes": {"tf": 1}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1}, "src.data.prepare.assign_housing_vulnerability": {"tf": 1}, "src.data.prepare.subset_columns": {"tf": 1}, "src.data.prepare.check_columns": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.prepare.merge_districts": {"tf": 1}, "src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}}, "df": 27}}}}}, "o": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.households.calculate_average_productivity": {"tf": 1}}, "df": 1}}}}}}}}}}}, "o": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "y": {"docs": {"src.data.analyse.get_policy_effectiveness_tab": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 2}}}, "y": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.prepare.polynomial_regression": {"tf": 1}}, "df": 1}}}}}}}}, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.data.prepare.calculate_poverty_attributes": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}}, "df": 3}}}}}, "o": {"docs": {}, "df": 0, "r": {"docs": {"src.data.write.find_poor": {"tf": 1}}, "df": 1}}}, "i": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.start_pipeline": {"tf": 1}}, "df": 1}}}}}}}, "l": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "t": {"docs": {"src.data.visualise.nine_quadrants_plot": {"tf": 1}}, "df": 1}}}, "e": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.get_people_by_years_in_poverty": {"tf": 1}}, "df": 1}}}}}, "m": {"docs": {}, "df": 0, "l": {"docs": {"src.modules.households.calculate_pml": {"tf": 1}}, "df": 1}}}, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}}, "df": 3}}}}}}}, "t": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {"src.data.prepare.rename_other_columns": {"tf": 1}}, "df": 1}}}}, "r": {"docs": {"src.data.prepare.get_bank_or_credit_union": {"tf": 1}}, "df": 1}, "p": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "z": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.optimize": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1.4142135623730951}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 4}, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}}, "df": 1}}}}}}}}}}}}, "g": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.analyse.get_policy_effectiveness_tab": {"tf": 1}, "src.data.prepare.get_bank_or_credit_union": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.visualise.get_colors": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}}, "df": 7}}, "a": {"docs": {}, "df": 0, "p": {"docs": {"src.data.write.calculate_poverty_gap": {"tf": 1}}, "df": 1}}}, "e": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.get_policy_effectiveness_tab": {"tf": 1}}, "df": 1}}}}}}}}}}}}, "x": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}}, "df": 1}}}}}}}, "s": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.calculate_exposure": {"tf": 1}}, "df": 1}}}}}, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}}}}}}}}, "s": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}}, "df": 1}}}}}}}}, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "b": {"docs": {"src.data.analyse.get_policy_effectiveness_tab": {"tf": 1}}, "df": 1}}}, "h": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.prepare.calculate_household_attributes": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}}, "df": 3, "s": {"docs": {"src.modules.households": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.select_district": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 11}}}}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.data.prepare.decode_housing_attributes": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}, "src.data.prepare.calculate_housing_attributes": {"tf": 1}, "src.data.prepare.assign_housing_vulnerability": {"tf": 1}}, "df": 4}}}}}}}, "l": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.load_data": {"tf": 1}}, "df": 1}}, "s": {"docs": {}, "df": 0, "s": {"docs": {"src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}}, "df": 1}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {"src.data.prepare.linear_regression": {"tf": 1}}, "df": 1}}}}}}, "i": {"docs": {}, "df": 0, "s": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}}, "df": 1}, "n": {"docs": {"src.data.write.get_people_by_years_in_poverty": {"tf": 1}}, "df": 1, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.calculate_income_attributes": {"tf": 1}}, "df": 2}}}}, "s": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.add_insurance_attributes": {"tf": 1}}, "df": 1}}}}}}}, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "z": {"docs": {}, "df": 0, "e": {"docs": {"src.model.initialize_model": {"tf": 1}}, "df": 1}}}}}}}}, "d": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}}}}}}}}, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 1}}}}}}}}}, "r": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}}, "df": 1}}}, "n": {"docs": {"src.model.run_model": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 2}}, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.rename_assets_column": {"tf": 1}, "src.data.prepare.rename_other_columns": {"tf": 1}}, "df": 2}}}}, "g": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}}, "df": 3}}}}}}}}, "a": {"docs": {}, "df": 0, "d": {"docs": {"src.data.read": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1.4142135623730951}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1.4142135623730951}}, "df": 4}}, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.calculate_resilience": {"tf": 1}}, "df": 1}}}}}}}}, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.optimize.optimize_recovery_rate": {"tf": 1}}, "df": 1}}}}}}}, "a": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "s": {"docs": {"src.data.visualise.rainclouds": {"tf": 1}}, "df": 1}}}}}}}}, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.optimize.optimize_recovery_rate": {"tf": 1}}, "df": 1}}}}, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.rename_assets_column": {"tf": 1}}, "df": 2, "s": {"docs": {"src.data.prepare.rename_other_columns": {"tf": 1}, "src.data.prepare.subset_columns": {"tf": 1}, "src.data.prepare.check_columns": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}}, "df": 5}}}}, "o": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "s": {"docs": {"src.data.visualise.get_colors": {"tf": 1}}, "df": 1}}}}, "n": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}}, "df": 1}}}}}}}}}}, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.calculate_household_attributes": {"tf": 1}, "src.data.prepare.calculate_income_attributes": {"tf": 1}, "src.data.prepare.calculate_housing_attributes": {"tf": 1}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}}, "df": 10}}}}}}}}, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.get_bank_or_credit_union": {"tf": 1}}, "df": 1}}}}}, "h": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "k": {"docs": {"src.data.prepare.check_columns": {"tf": 1}}, "df": 1}}}, "o": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "h": {"docs": {"src.data.visualise.bivariate_choropleth": {"tf": 1}}, "df": 1}}}}}}}}}}, "b": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "k": {"docs": {"src.data.prepare.get_bank_or_credit_union": {"tf": 1}}, "df": 1}}}, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.data.visualise.bivariate_choropleth": {"tf": 1}}, "df": 1}}}}}}}, "n": {"docs": {"src.data.visualise.bin_data": {"tf": 1}}, "df": 1}}, "y": {"docs": {"src.data.write.get_people_by_years_in_poverty": {"tf": 1}}, "df": 1}}, "u": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.get_bank_or_credit_union": {"tf": 1}}, "df": 1}}}}}, "v": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.data.prepare.assign_housing_vulnerability": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}}, "df": 2}}}}}}}}}}}}, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {"src.data.visualise": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}, "src.data.visualise.bivariate_choropleth": {"tf": 1}, "src.data.visualise.nine_quadrants_plot": {"tf": 1}, "src.data.visualise.get_colors": {"tf": 1}, "src.data.visualise.bin_data": {"tf": 1}}, "df": 6}}}}}}}}}, "m": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.data.prepare.add_missing_columns": {"tf": 1}}, "df": 1}}}}}}, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.merge_districts": {"tf": 1}}, "df": 1}}}}, "o": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "l": {"docs": {"src.model": {"tf": 1}, "src.model.initialize_model": {"tf": 1.4142135623730951}, "src.model.run_model": {"tf": 1.4142135623730951}}, "df": 3}}, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.modules": {"tf": 1}, "src.modules.households": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.select_district": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 16}}}}}}}, "n": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {"src.data.visualise.nine_quadrants_plot": {"tf": 1}}, "df": 1}}}}, "q": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "s": {"docs": {"src.data.visualise.nine_quadrants_plot": {"tf": 1}}, "df": 1}}}}}}}}}, "w": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}}, "df": 8}}}}, "e": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 1}}}}}}}}}, "f": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "d": {"docs": {"src.data.write.find_poor": {"tf": 1}}, "df": 1}}}}, "y": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "s": {"docs": {"src.data.write.get_people_by_years_in_poverty": {"tf": 1}}, "df": 1}}}}}}}, "annotation": {"root": {"docs": {}, "df": 0}}, "default_value": {"root": {"docs": {}, "df": 0}}, "signature": {"root": {"0": {"docs": {"src.data.prepare.polynomial_regression": {"tf": 1}}, "df": 1}, "1": {"0": {"0": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}}, "df": 2}, "docs": {}, "df": 0}, "docs": {}, "df": 0}, "3": {"9": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 2}, "src.data.visualise.rainclouds": {"tf": 1.4142135623730951}}, "df": 2}, "docs": {}, "df": 0}, "4": {"0": {"docs": {"src.data.prepare.polynomial_regression": {"tf": 1}}, "df": 1}, "docs": {}, "df": 0}, "docs": {"src.data.analyse.prepare_outcomes": {"tf": 6.855654600401044}, "src.data.analyse.get_spatial_outcomes": {"tf": 9.327379053088816}, "src.data.analyse.get_policy_effectiveness_tab": {"tf": 6.324555320336759}, "src.data.prepare.prepare_asset_damage": {"tf": 6.164414002968976}, "src.data.prepare.prepare_household_survey": {"tf": 4}, "src.data.prepare.load_data": {"tf": 5.830951894845301}, "src.data.prepare.start_pipeline": {"tf": 5.0990195135927845}, "src.data.prepare.add_is_rural_column": {"tf": 7.483314773547883}, "src.data.prepare.rename_assets_column": {"tf": 6.324555320336759}, "src.data.prepare.rename_other_columns": {"tf": 6.324555320336759}, "src.data.prepare.calculate_household_attributes": {"tf": 6.324555320336759}, "src.data.prepare.get_bank_or_credit_union": {"tf": 6.324555320336759}, "src.data.prepare.decode_demographic_attributes": {"tf": 6.324555320336759}, "src.data.prepare.decode_income_attributes": {"tf": 6.324555320336759}, "src.data.prepare.calculate_income_attributes": {"tf": 6.324555320336759}, "src.data.prepare.decode_housing_attributes": {"tf": 6.324555320336759}, "src.data.prepare.add_housing_attributes": {"tf": 6.324555320336759}, "src.data.prepare.add_insurance_attributes": {"tf": 6.324555320336759}, "src.data.prepare.calculate_housing_attributes": {"tf": 6.324555320336759}, "src.data.prepare.calculate_poverty_attributes": {"tf": 6.324555320336759}, "src.data.prepare.assign_housing_vulnerability": {"tf": 6.324555320336759}, "src.data.prepare.subset_columns": {"tf": 6.324555320336759}, "src.data.prepare.check_columns": {"tf": 6.324555320336759}, "src.data.prepare.add_missing_columns": {"tf": 7.0710678118654755}, "src.data.prepare.merge_districts": {"tf": 6.324555320336759}, "src.data.prepare.exponential_regression": {"tf": 10.246950765959598}, "src.data.prepare.polynomial_regression": {"tf": 12.529964086141668}, "src.data.prepare.linear_regression": {"tf": 10.488088481701515}, "src.data.read.read_asset_damage": {"tf": 3.4641016151377544}, "src.data.read.get_asset_damage": {"tf": 8.06225774829855}, "src.data.read.read_household_survey": {"tf": 5.291502622129181}, "src.data.visualise.rainclouds": {"tf": 10.723805294763608}, "src.data.visualise.bivariate_choropleth": {"tf": 6.164414002968976}, "src.data.visualise.nine_quadrants_plot": {"tf": 5.0990195135927845}, "src.data.visualise.get_colors": {"tf": 3.1622776601683795}, "src.data.visualise.bin_data": {"tf": 5.477225575051661}, "src.data.write.add_columns": {"tf": 7.874007874011811}, "src.data.write.get_outcomes": {"tf": 6.164414002968976}, "src.data.write.find_poor": {"tf": 6.855654600401044}, "src.data.write.get_people_by_years_in_poverty": {"tf": 5.291502622129181}, "src.data.write.calculate_poverty_gap": {"tf": 8.246211251235321}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 6}, "src.data.write.calculate_resilience": {"tf": 6}, "src.model.initialize_model": {"tf": 4.898979485566356}, "src.model.run_model": {"tf": 3.4641016151377544}, "src.modules.households.duplicate_households": {"tf": 7.0710678118654755}, "src.modules.households.calculate_average_productivity": {"tf": 6}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 8.774964387392123}, "src.modules.households.calculate_pml": {"tf": 7.681145747868608}, "src.modules.households.select_district": {"tf": 7.0710678118654755}, "src.modules.households.estimate_savings": {"tf": 7.681145747868608}, "src.modules.households.set_vulnerability": {"tf": 7.681145747868608}, "src.modules.households.calculate_exposure": {"tf": 8.246211251235321}, "src.modules.households.determine_affected": {"tf": 6.164414002968976}, "src.modules.households.apply_individual_policy": {"tf": 6}, "src.modules.optimize.run_optimization": {"tf": 9.273618495495704}, "src.modules.optimize.optimize_recovery_rate": {"tf": 8.888194417315589}, "src.modules.optimize.integrate_wellbeing": {"tf": 10.954451150103322}}, "df": 58, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}}, "df": 2}}}}}, "t": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.visualise.bivariate_choropleth": {"tf": 1}}, "df": 5}}}}}, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 4}}, "n": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1}}, "df": 1}}}}}}, "t": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 11}}}}, "r": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.load_data": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}, "src.data.visualise.nine_quadrants_plot": {"tf": 1}, "src.data.visualise.bin_data": {"tf": 1}}, "df": 5}}, "a": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {"src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 1}}}}}}}, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.visualise.rainclouds": {"tf": 1}}, "df": 1}}}}, "m": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "p": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}}, "df": 2}}}}}}}, "a": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {"src.data.visualise.bivariate_choropleth": {"tf": 1}}, "df": 1}}}}, "o": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 2}}}}}, "a": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "d": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1.4142135623730951}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 2}}, "g": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}}, "df": 1}}}}}}}}}}, "r": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "y": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1.4142135623730951}, "src.data.prepare.polynomial_regression": {"tf": 1.4142135623730951}, "src.data.prepare.linear_regression": {"tf": 1.4142135623730951}}, "df": 3}}}}, "l": {"docs": {}, "df": 0, "l": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}}, "df": 1}}, "f": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.data.write.add_columns": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 6}}}}}}}, "s": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 2}}}}, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 4}}}}}}, "n": {"docs": {}, "df": 0, "d": {"docs": {"src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 1}}}, "p": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}}, "df": 1}}}, "y": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}}}}, "w": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {"src.data.prepare.polynomial_regression": {"tf": 1}}, "df": 1}}}, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.data.visualise.rainclouds": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 6}}}}}, "o": {"docs": {}, "df": 0, "r": {"docs": {"src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}}, "df": 2}}}, "a": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.analyse.get_policy_effectiveness_tab": {"tf": 1.4142135623730951}, "src.data.prepare.load_data": {"tf": 1}, "src.data.prepare.start_pipeline": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1.4142135623730951}, "src.data.prepare.rename_assets_column": {"tf": 1.4142135623730951}, "src.data.prepare.rename_other_columns": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_household_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.get_bank_or_credit_union": {"tf": 1.4142135623730951}, "src.data.prepare.decode_demographic_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.decode_income_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_income_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.decode_housing_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.add_housing_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.add_insurance_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_housing_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.assign_housing_vulnerability": {"tf": 1.4142135623730951}, "src.data.prepare.subset_columns": {"tf": 1.4142135623730951}, "src.data.prepare.check_columns": {"tf": 1.4142135623730951}, "src.data.prepare.add_missing_columns": {"tf": 1.4142135623730951}, "src.data.prepare.merge_districts": {"tf": 1.4142135623730951}, "src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}, "src.data.write.add_columns": {"tf": 1.7320508075688772}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.select_district": {"tf": 1.4142135623730951}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1.4142135623730951}}, "df": 48}}}}, "l": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.data.visualise.rainclouds": {"tf": 1}}, "df": 1}}}}}, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "s": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 4}}}}}, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}}, "df": 2}}}}}, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.load_data": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.visualise.bin_data": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}}, "df": 8}}}, "o": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 4}}}}}}}}}}}, "l": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "t": {"docs": {"src.data.visualise.rainclouds": {"tf": 1}}, "df": 1}}}, "m": {"docs": {}, "df": 0, "l": {"docs": {"src.data.write.calculate_resilience": {"tf": 1}}, "df": 1}}}, "b": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "l": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1.4142135623730951}, "src.data.prepare.load_data": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1.7320508075688772}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 13}}}, "u": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1.4142135623730951}, "src.data.prepare.linear_regression": {"tf": 1}}, "df": 3}}}}, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "s": {"docs": {"src.modules.households.calculate_exposure": {"tf": 1}}, "df": 1}}}}, "u": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}}, "df": 1}}}}}}}}}}}}, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 3}}}}}}}, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.analyse.get_policy_effectiveness_tab": {"tf": 1.4142135623730951}, "src.data.prepare.load_data": {"tf": 1}, "src.data.prepare.start_pipeline": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1.4142135623730951}, "src.data.prepare.rename_assets_column": {"tf": 1.4142135623730951}, "src.data.prepare.rename_other_columns": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_household_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.get_bank_or_credit_union": {"tf": 1.4142135623730951}, "src.data.prepare.decode_demographic_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.decode_income_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_income_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.decode_housing_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.add_housing_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.add_insurance_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_housing_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.assign_housing_vulnerability": {"tf": 1.4142135623730951}, "src.data.prepare.subset_columns": {"tf": 1.4142135623730951}, "src.data.prepare.check_columns": {"tf": 1.4142135623730951}, "src.data.prepare.add_missing_columns": {"tf": 1.4142135623730951}, "src.data.prepare.merge_districts": {"tf": 1.4142135623730951}, "src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}, "src.data.write.add_columns": {"tf": 1.7320508075688772}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.select_district": {"tf": 1.4142135623730951}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1.4142135623730951}}, "df": 48}}, "u": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "y": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.model.initialize_model": {"tf": 1}}, "df": 6}}}}}, "l": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1.4142135623730951}, "src.data.prepare.polynomial_regression": {"tf": 1.4142135623730951}, "src.data.prepare.linear_regression": {"tf": 1.4142135623730951}}, "df": 3, "s": {"docs": {"src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}}, "df": 2}}}}, "o": {"docs": {}, "df": 0, "r": {"docs": {"src.data.visualise.rainclouds": {"tf": 1}}, "df": 1}}}, "n": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 3}}}}}}}}}}, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.calculate_exposure": {"tf": 1}}, "df": 1}}}}}}}, "s": {"docs": {}, "df": 0, "h": {"docs": {"src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 1}}}}, "f": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.analyse.get_policy_effectiveness_tab": {"tf": 1.4142135623730951}, "src.data.prepare.load_data": {"tf": 1}, "src.data.prepare.start_pipeline": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1.4142135623730951}, "src.data.prepare.rename_assets_column": {"tf": 1.4142135623730951}, "src.data.prepare.rename_other_columns": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_household_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.get_bank_or_credit_union": {"tf": 1.4142135623730951}, "src.data.prepare.decode_demographic_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.decode_income_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_income_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.decode_housing_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.add_housing_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.add_insurance_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_housing_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.assign_housing_vulnerability": {"tf": 1.4142135623730951}, "src.data.prepare.subset_columns": {"tf": 1.4142135623730951}, "src.data.prepare.check_columns": {"tf": 1.4142135623730951}, "src.data.prepare.add_missing_columns": {"tf": 1.4142135623730951}, "src.data.prepare.merge_districts": {"tf": 1.4142135623730951}, "src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}, "src.data.write.add_columns": {"tf": 1.7320508075688772}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.select_district": {"tf": 1.4142135623730951}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1.4142135623730951}}, "df": 48}}, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}}, "df": 2}}}}}}}, "u": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1.4142135623730951}, "src.data.prepare.linear_regression": {"tf": 1}}, "df": 3}}}}}}}, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}}, "df": 3}}}}, "l": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1.4142135623730951}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.7320508075688772}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 2}, "src.modules.optimize.optimize_recovery_rate": {"tf": 2.23606797749979}, "src.modules.optimize.integrate_wellbeing": {"tf": 2.23606797749979}}, "df": 13}}}}, "i": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "z": {"docs": {}, "df": 0, "e": {"docs": {"src.data.visualise.bivariate_choropleth": {"tf": 1}}, "df": 1}}}}}}}, "d": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "a": {"docs": {"src.data.prepare.start_pipeline": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.rename_assets_column": {"tf": 1}, "src.data.prepare.rename_other_columns": {"tf": 1}, "src.data.prepare.calculate_household_attributes": {"tf": 1}, "src.data.prepare.get_bank_or_credit_union": {"tf": 1}, "src.data.prepare.decode_demographic_attributes": {"tf": 1}, "src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.calculate_income_attributes": {"tf": 1}, "src.data.prepare.decode_housing_attributes": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}, "src.data.prepare.add_insurance_attributes": {"tf": 1}, "src.data.prepare.calculate_housing_attributes": {"tf": 1}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1}, "src.data.prepare.assign_housing_vulnerability": {"tf": 1}, "src.data.prepare.subset_columns": {"tf": 1}, "src.data.prepare.check_columns": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.prepare.merge_districts": {"tf": 1}, "src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.visualise.bivariate_choropleth": {"tf": 1}, "src.data.visualise.nine_quadrants_plot": {"tf": 1}, "src.data.visualise.get_colors": {"tf": 1}, "src.data.visualise.bin_data": {"tf": 1}}, "df": 26, "f": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.analyse.get_policy_effectiveness_tab": {"tf": 1.4142135623730951}, "src.data.prepare.load_data": {"tf": 1}, "src.data.prepare.start_pipeline": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1.4142135623730951}, "src.data.prepare.rename_assets_column": {"tf": 1.4142135623730951}, "src.data.prepare.rename_other_columns": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_household_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.get_bank_or_credit_union": {"tf": 1.4142135623730951}, "src.data.prepare.decode_demographic_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.decode_income_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_income_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.decode_housing_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.add_housing_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.add_insurance_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_housing_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1.4142135623730951}, "src.data.prepare.assign_housing_vulnerability": {"tf": 1.4142135623730951}, "src.data.prepare.subset_columns": {"tf": 1.4142135623730951}, "src.data.prepare.check_columns": {"tf": 1.4142135623730951}, "src.data.prepare.add_missing_columns": {"tf": 1.4142135623730951}, "src.data.prepare.merge_districts": {"tf": 1.4142135623730951}, "src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}, "src.data.write.add_columns": {"tf": 1.7320508075688772}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.select_district": {"tf": 1.4142135623730951}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1.4142135623730951}}, "df": 48}}}}}}}, "m": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}}, "df": 2}}}}}, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}, "src.modules.households.select_district": {"tf": 1}}, "df": 2}}}}}, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 3}}}}}}, "c": {"docs": {}, "df": 0, "t": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 7}}}, "e": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}}}}}}}}}, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1.4142135623730951}, "src.data.analyse.get_policy_effectiveness_tab": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}}, "df": 3}}}}}}}, "f": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}}, "df": 1}, "p": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "z": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1.4142135623730951}}, "df": 2}}}}}}}}}}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1.4142135623730951}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}}, "df": 4, "t": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 2}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 11, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}}, "df": 1}}}}}}, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.write.calculate_poverty_gap": {"tf": 1}}, "df": 1}}}}}, "d": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}}}}}, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.optimize.integrate_wellbeing": {"tf": 1.4142135623730951}}, "df": 1}}}}}, "s": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1}}, "df": 1}}, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1.4142135623730951}}, "df": 3}}, "n": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.find_poor": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 4}}}, "u": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}}, "df": 1}}}}, "t": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1.4142135623730951}, "src.data.prepare.linear_regression": {"tf": 1}}, "df": 3}, "a": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "l": {"docs": {"src.data.visualise.bivariate_choropleth": {"tf": 1.4142135623730951}}, "df": 1}}}}, "o": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 3}}}}, "s": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "r": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1.4142135623730951}, "src.data.prepare.prepare_asset_damage": {"tf": 1.4142135623730951}, "src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.prepare.exponential_regression": {"tf": 1.4142135623730951}, "src.data.prepare.polynomial_regression": {"tf": 1.4142135623730951}, "src.data.prepare.linear_regression": {"tf": 1.4142135623730951}, "src.data.read.get_asset_damage": {"tf": 1.4142135623730951}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.select_district": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 12}, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "s": {"docs": {"src.data.prepare.load_data": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.visualise.bin_data": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}}, "df": 8}}}}}}}, "r": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.polynomial_regression": {"tf": 1}}, "df": 1}}}, "o": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "k": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 2}}}}, "a": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}}, "df": 1}}}, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "s": {"docs": {"src.data.visualise.rainclouds": {"tf": 1}}, "df": 1}}}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}}, "df": 1, "s": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}}, "df": 1}}}}}}, "c": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.visualise.bivariate_choropleth": {"tf": 1}, "src.data.visualise.nine_quadrants_plot": {"tf": 1}, "src.data.visualise.bin_data": {"tf": 1}}, "df": 5}}}}, "e": {"docs": {}, "df": 0, "t": {"2": {"docs": {"src.data.visualise.rainclouds": {"tf": 1}}, "df": 1}, "docs": {"src.modules.households.set_vulnerability": {"tf": 1}}, "df": 1}}, "h": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "x": {"docs": {"src.data.visualise.rainclouds": {"tf": 1}}, "df": 1}}}}}, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.select_district": {"tf": 1}}, "df": 2}}}}}}, "m": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "n": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}}, "df": 1}}}, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.data.prepare.add_missing_columns": {"tf": 1}}, "df": 1}}}}}, "n": {"docs": {"src.model.initialize_model": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}}, "df": 2}}, "o": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "l": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}}, "df": 2}}}}, "y": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}}, "g": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1}}, "df": 1}}}}}}, "d": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.analyse.get_spatial_outcomes": {"tf": 1.4142135623730951}}, "df": 1}}}}}}}}}}}, "t": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1.4142135623730951}, "src.data.prepare.linear_regression": {"tf": 1}}, "df": 3}, "r": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "w": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "h": {"docs": {"src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 1}}}}}}, "n": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 7, "o": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1.4142135623730951}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}}, "df": 6}}}, "u": {"docs": {}, "df": 0, "m": {"docs": {"src.data.prepare.polynomial_regression": {"tf": 1}}, "df": 1, "p": {"docs": {}, "df": 0, "y": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}}, "df": 2}}}}, "e": {"docs": {}, "df": 0, "w": {"docs": {"src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}}, "df": 3}}, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.visualise.bivariate_choropleth": {"tf": 1.4142135623730951}, "src.data.visualise.nine_quadrants_plot": {"tf": 1.4142135623730951}, "src.data.visualise.bin_data": {"tf": 1.4142135623730951}}, "df": 3}}}}, "x": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 2.23606797749979}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.visualise.rainclouds": {"tf": 1.4142135623730951}, "src.data.visualise.bivariate_choropleth": {"tf": 1.4142135623730951}, "src.data.visualise.nine_quadrants_plot": {"tf": 1}, "src.data.visualise.bin_data": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}}, "df": 8}, "y": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.visualise.bivariate_choropleth": {"tf": 1.4142135623730951}, "src.data.visualise.nine_quadrants_plot": {"tf": 1}, "src.data.visualise.bin_data": {"tf": 1}}, "df": 6, "e": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "s": {"docs": {"src.data.visualise.rainclouds": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 8}}}}}, "w": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "s": {"docs": {"src.data.prepare.exponential_regression": {"tf": 1}, "src.data.prepare.polynomial_regression": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}}, "df": 3}}}}}}}, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.polynomial_regression": {"tf": 1}}, "df": 1}}, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {"src.data.write.get_outcomes": {"tf": 1}}, "df": 1}}}}, "x": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}}, "df": 2}}}}, "n": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 1}}}}}}}}, "o": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.calculate_exposure": {"tf": 1}}, "df": 1}}}}}}}, "s": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}}, "df": 1}}}}}}}}, "h": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "d": {"docs": {"src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.select_district": {"tf": 1}}, "df": 2, "s": {"docs": {"src.data.write.add_columns": {"tf": 1.4142135623730951}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}, "src.modules.optimize.integrate_wellbeing": {"tf": 1}}, "df": 17}}}}}}}}}}, "k": {"docs": {}, "df": 0, "w": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "s": {"docs": {"src.model.run_model": {"tf": 1}}, "df": 1}}}}}}, "v": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}}, "df": 1}}}}}}}}}}}}}}}, "bases": {"root": {"docs": {}, "df": 0}}, "doc": {"root": {"0": {"docs": {"src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1.4142135623730951}}, "df": 2}, "1": {"0": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}, "docs": {"src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}}, "df": 4}, "2": {"5": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}, "docs": {}, "df": 0}, "3": {"0": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}, "docs": {}, "df": 0}, "5": {"0": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}, "docs": {}, "df": 0}, "docs": {"src": {"tf": 1.7320508075688772}, "src.data": {"tf": 1.7320508075688772}, "src.data.analyse": {"tf": 1.7320508075688772}, "src.data.analyse.prepare_outcomes": {"tf": 3.4641016151377544}, "src.data.analyse.get_spatial_outcomes": {"tf": 1.7320508075688772}, "src.data.analyse.get_policy_effectiveness_tab": {"tf": 1.7320508075688772}, "src.data.prepare": {"tf": 1.7320508075688772}, "src.data.prepare.prepare_asset_damage": {"tf": 1.7320508075688772}, "src.data.prepare.prepare_household_survey": {"tf": 3.605551275463989}, "src.data.prepare.load_data": {"tf": 1.7320508075688772}, "src.data.prepare.start_pipeline": {"tf": 1.7320508075688772}, "src.data.prepare.add_is_rural_column": {"tf": 1.7320508075688772}, "src.data.prepare.rename_assets_column": {"tf": 1.7320508075688772}, "src.data.prepare.rename_other_columns": {"tf": 1.7320508075688772}, "src.data.prepare.calculate_household_attributes": {"tf": 1.7320508075688772}, "src.data.prepare.get_bank_or_credit_union": {"tf": 1.7320508075688772}, "src.data.prepare.decode_demographic_attributes": {"tf": 1.7320508075688772}, "src.data.prepare.decode_income_attributes": {"tf": 1.7320508075688772}, "src.data.prepare.calculate_income_attributes": {"tf": 1.7320508075688772}, "src.data.prepare.decode_housing_attributes": {"tf": 1.7320508075688772}, "src.data.prepare.add_housing_attributes": {"tf": 1.7320508075688772}, "src.data.prepare.add_insurance_attributes": {"tf": 1.7320508075688772}, "src.data.prepare.calculate_housing_attributes": {"tf": 1.7320508075688772}, "src.data.prepare.calculate_poverty_attributes": {"tf": 1.7320508075688772}, "src.data.prepare.assign_housing_vulnerability": {"tf": 1.7320508075688772}, "src.data.prepare.subset_columns": {"tf": 1.7320508075688772}, "src.data.prepare.check_columns": {"tf": 1.7320508075688772}, "src.data.prepare.add_missing_columns": {"tf": 1.7320508075688772}, "src.data.prepare.merge_districts": {"tf": 1.7320508075688772}, "src.data.prepare.exponential_regression": {"tf": 1.7320508075688772}, "src.data.prepare.polynomial_regression": {"tf": 1.7320508075688772}, "src.data.prepare.linear_regression": {"tf": 1.7320508075688772}, "src.data.read": {"tf": 1.7320508075688772}, "src.data.read.read_asset_damage": {"tf": 1.7320508075688772}, "src.data.read.get_asset_damage": {"tf": 4.795831523312719}, "src.data.read.read_household_survey": {"tf": 3.872983346207417}, "src.data.visualise": {"tf": 1.7320508075688772}, "src.data.visualise.rainclouds": {"tf": 1.7320508075688772}, "src.data.visualise.bivariate_choropleth": {"tf": 1.7320508075688772}, "src.data.visualise.nine_quadrants_plot": {"tf": 1.7320508075688772}, "src.data.visualise.get_colors": {"tf": 1.7320508075688772}, "src.data.visualise.bin_data": {"tf": 1.7320508075688772}, "src.data.write": {"tf": 1.7320508075688772}, "src.data.write.add_columns": {"tf": 2.6457513110645907}, "src.data.write.get_outcomes": {"tf": 3.872983346207417}, "src.data.write.find_poor": {"tf": 2.8284271247461903}, "src.data.write.get_people_by_years_in_poverty": {"tf": 2.8284271247461903}, "src.data.write.calculate_poverty_gap": {"tf": 3.605551275463989}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 3.3166247903554}, "src.data.write.calculate_resilience": {"tf": 3.3166247903554}, "src.model": {"tf": 1.7320508075688772}, "src.model.initialize_model": {"tf": 3.3166247903554}, "src.model.run_model": {"tf": 1.7320508075688772}, "src.modules": {"tf": 1.7320508075688772}, "src.modules.households": {"tf": 1.7320508075688772}, "src.modules.households.duplicate_households": {"tf": 4}, "src.modules.households.calculate_average_productivity": {"tf": 3.4641016151377544}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 4.123105625617661}, "src.modules.households.calculate_pml": {"tf": 3.4641016151377544}, "src.modules.households.select_district": {"tf": 1.7320508075688772}, "src.modules.households.estimate_savings": {"tf": 3.872983346207417}, "src.modules.households.set_vulnerability": {"tf": 4.358898943540674}, "src.modules.households.calculate_exposure": {"tf": 4}, "src.modules.households.determine_affected": {"tf": 4.58257569495584}, "src.modules.households.apply_individual_policy": {"tf": 5.0990195135927845}, "src.modules.optimize": {"tf": 1.7320508075688772}, "src.modules.optimize.run_optimization": {"tf": 3.872983346207417}, "src.modules.optimize.optimize_recovery_rate": {"tf": 1.7320508075688772}, "src.modules.optimize.integrate_wellbeing": {"tf": 1.7320508075688772}}, "df": 69, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "t": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}}, "df": 1}}}}, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {"src.data.write.get_outcomes": {"tf": 1}}, "df": 1}}}}, "u": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.write.calculate_average_annual_consumption_loss": {"tf": 2.6457513110645907}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 3}}}}}}}}, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 1}}}}}}}}, "u": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "y": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1.4142135623730951}, "src.data.read.read_household_survey": {"tf": 1.7320508075688772}, "src.model.initialize_model": {"tf": 1.4142135623730951}}, "df": 3}}}}}, "l": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.rename_assets_column": {"tf": 1}}, "df": 2, "s": {"docs": {"src.data.prepare.rename_other_columns": {"tf": 1}, "src.data.prepare.subset_columns": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}}, "df": 3, "/": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.write.add_columns": {"tf": 1}}, "df": 1}}}}}}}}}}}}}}, "e": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.linear_regression": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 2}}}}}}}}}}, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}}, "df": 1, "d": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}}}}, "s": {"docs": {}, "df": 0, "v": {"docs": {"src.data.read.read_household_survey": {"tf": 1}}, "df": 1}}, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 7, "d": {"docs": {"src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 2}, "s": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}}, "df": 1}}, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "s": {"docs": {"src.data.write.get_outcomes": {"tf": 1}}, "df": 1}}}, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.modules.households.calculate_exposure": {"tf": 1}}, "df": 1}}}}}}}}}, "n": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 3}, "p": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}}, "df": 2}}}}}}}, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1.4142135623730951}, "src.data.write.get_outcomes": {"tf": 1.4142135623730951}}, "df": 2}}}}}}}, "f": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.prepare.rename_other_columns": {"tf": 1}, "src.data.prepare.subset_columns": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1.7320508075688772}, "src.data.write.find_poor": {"tf": 2.449489742783178}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1.4142135623730951}, "src.data.write.calculate_poverty_gap": {"tf": 2.449489742783178}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 2}, "src.data.write.calculate_resilience": {"tf": 1.4142135623730951}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.7320508075688772}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 21}, "r": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 3}, "n": {"docs": {"src.data.prepare.linear_regression": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 3, "l": {"docs": {}, "df": 0, "y": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}}, "df": 1}}}, "p": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "z": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1.7320508075688772}}, "df": 4}}}}}}}}, "o": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}}, "df": 3}}}}}}}}, "d": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 6}}, "s": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 2.23606797749979}, "src.modules.households.select_district": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 8, "s": {"docs": {"src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}}, "df": 2}}}, "b": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1}}, "df": 1}}}}}}}}}, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 1}}}}}}}, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "a": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 2}, "src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.prepare.load_data": {"tf": 1}, "src.data.prepare.start_pipeline": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 2}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1.4142135623730951}, "src.modules.households.apply_individual_policy": {"tf": 1.4142135623730951}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 20, "f": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 1.7320508075688772}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1.4142135623730951}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1.4142135623730951}, "src.data.write.calculate_resilience": {"tf": 1.4142135623730951}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 20}}}}}}}, "m": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 2}, "src.data.write.get_outcomes": {"tf": 1.4142135623730951}, "src.model.initialize_model": {"tf": 1.4142135623730951}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}}, "df": 6}}}}}, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.rename_assets_column": {"tf": 1}}, "df": 1}}}}}}}}}, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "s": {"docs": {"src.data.prepare.rename_other_columns": {"tf": 1}}, "df": 1}}}}, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1, "s": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}, "d": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}}}}}}}}}, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.decode_demographic_attributes": {"tf": 1}, "src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.decode_housing_attributes": {"tf": 1}}, "df": 3}}}}, "m": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {"src.data.prepare.decode_demographic_attributes": {"tf": 1}}, "df": 1}}}}}}}}}, "f": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "s": {"docs": {"src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}}, "df": 3}}}}}}}, "o": {"docs": {"src.data.prepare.linear_regression": {"tf": 1}}, "df": 1}, "u": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.data.write.calculate_poverty_gap": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}}, "df": 2}, "s": {"docs": {"src.modules.households.duplicate_households": {"tf": 1}}, "df": 1}}, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.modules.households.duplicate_households": {"tf": 1}}, "df": 1}}}}}}}}}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 2}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 7, "t": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 6, "o": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}}, "df": 3}, "r": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.add_housing_attributes": {"tf": 1}}, "df": 1}}}}}}, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.subset_columns": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1.4142135623730951}}, "df": 3}}}}}}, "d": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}}, "df": 1}}}}}, "g": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}}, "df": 1}}}}}}, "e": {"docs": {}, "df": 0, "x": {"docs": {"src.data.write.calculate_poverty_gap": {"tf": 1}}, "df": 1}, "p": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}}}}}}}}}, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.decode_income_attributes": {"tf": 1}}, "df": 1}}}}, "i": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1}}, "df": 1, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.write.calculate_poverty_gap": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}}, "df": 2, "i": {"docs": {}, "df": 0, "z": {"docs": {}, "df": 0, "e": {"docs": {"src.model.initialize_model": {"tf": 1}}, "df": 1}}}}}}}}}, "t": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}}, "df": 2}, "f": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1.4142135623730951}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1.4142135623730951}}, "df": 10}, "s": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1.7320508075688772}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1.4142135623730951}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.7320508075688772}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 12}}, "a": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.rename_other_columns": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1.4142135623730951}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.select_district": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 2}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 19, "r": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 20}}, "e": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}}, "df": 1}}, "d": {"docs": {}, "df": 0, "d": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 2}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}}, "df": 3}, "j": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}}}}}, "s": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1.4142135623730951}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}}, "df": 4, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1.7320508075688772}, "src.data.write.get_outcomes": {"tf": 1.4142135623730951}, "src.model.initialize_model": {"tf": 1.4142135623730951}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 2}, "src.modules.households.determine_affected": {"tf": 1.4142135623730951}}, "df": 7, "s": {"docs": {"src.data.prepare.rename_assets_column": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}}, "df": 2}}}, "u": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 2}}}, "i": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1}}, "df": 1}}}}}}}, "n": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 1.4142135623730951}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.write.find_poor": {"tf": 1.4142135623730951}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1.4142135623730951}, "src.data.write.calculate_resilience": {"tf": 1}, "src.model.initialize_model": {"tf": 1.4142135623730951}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.7320508075688772}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1.4142135623730951}}, "df": 14}, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "y": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "s": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}}, "df": 1}}}}}}, "n": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.write.calculate_average_annual_consumption_loss": {"tf": 2.6457513110645907}}, "df": 1}}}}}, "t": {"docs": {"src.data.write.find_poor": {"tf": 2}, "src.data.write.calculate_poverty_gap": {"tf": 2.449489742783178}}, "df": 2, "t": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.prepare.decode_demographic_attributes": {"tf": 1}, "src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.decode_housing_attributes": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}}, "df": 4}}}}}}}}}, "l": {"docs": {}, "df": 0, "l": {"docs": {"src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 4}, "g": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "m": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 4}}}}}}}}, "f": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.data.write.add_columns": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1.4142135623730951}, "src.data.write.calculate_resilience": {"tf": 1.7320508075688772}, "src.modules.households.determine_affected": {"tf": 2.23606797749979}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 2}}, "df": 6}}}}}}, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {"src.modules.households.duplicate_households": {"tf": 1}}, "df": 1}}}}, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.get_outcomes": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 2.6457513110645907}, "src.modules.households.calculate_average_productivity": {"tf": 1.7320508075688772}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 4}}}, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}}, "df": 1}}}}}}}, "e": {"docs": {"src.modules.households.calculate_average_productivity": {"tf": 1}}, "df": 1, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {"src.modules.households.calculate_average_productivity": {"tf": 1}}, "df": 1}}}}, "p": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1.4142135623730951}}, "df": 1}, "i": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}}}}}}}, "f": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 2}, "src.data.write.get_outcomes": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 3}}, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.read.get_asset_damage": {"tf": 1.4142135623730951}, "src.data.write.get_outcomes": {"tf": 1.4142135623730951}, "src.modules.households.calculate_pml": {"tf": 1.7320508075688772}}, "df": 3}}}}}}, "o": {"docs": {}, "df": 0, "m": {"docs": {"src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}}, "df": 4}}}, "o": {"docs": {}, "df": 0, "r": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.prepare.rename_other_columns": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1.4142135623730951}, "src.data.write.get_outcomes": {"tf": 1.4142135623730951}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1.4142135623730951}, "src.modules.households.select_district": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1.7320508075688772}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 13, "m": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}}, "df": 1}}}}, "u": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "d": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}}}}, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 4, "s": {"docs": {"src.model.initialize_model": {"tf": 1.4142135623730951}}, "df": 1}}}}, "u": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.rename_other_columns": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 5}}}}}}}, "l": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {"src.data.write.get_outcomes": {"tf": 2.23606797749979}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.7320508075688772}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 2}}, "df": 10}}}}, "a": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1, "l": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}}, "df": 3}}}}}, "r": {"2": {"docs": {"src.data.prepare.linear_regression": {"tf": 1}}, "df": 1}, "docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1.4142135623730951}}, "df": 1}}}}, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.calculate_resilience": {"tf": 1.7320508075688772}}, "df": 1}}}}}}}}, "t": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.linear_regression": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1.4142135623730951}}, "df": 2, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 20}}}}}, "n": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.rename_assets_column": {"tf": 1}, "src.data.prepare.rename_other_columns": {"tf": 1}}, "df": 2}}}}, "l": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.decode_housing_attributes": {"tf": 1}}, "df": 2}}, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}}, "df": 1}}}}}}, "g": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.linear_regression": {"tf": 1}}, "df": 1}}}}}}}}, "a": {"docs": {}, "df": 0, "d": {"docs": {"src.data.read.read_asset_damage": {"tf": 1}}, "df": 1, "s": {"docs": {"src.data.read.read_household_survey": {"tf": 1}}, "df": 1}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.model.initialize_model": {"tf": 1}}, "df": 1}}}}}, "p": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {"src.model.initialize_model": {"tf": 1}}, "df": 1}}}}}}}}}}}}, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 1}}}}}}}, "a": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 9}}}}, "w": {"docs": {"src.data.prepare.load_data": {"tf": 1}}, "df": 1}, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.estimate_savings": {"tf": 1.7320508075688772}, "src.modules.optimize.run_optimization": {"tf": 2}}, "df": 2}}, "n": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "m": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1.7320508075688772}}, "df": 1}}}}}, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}}, "df": 1}}}, "n": {"docs": {"src.model.run_model": {"tf": 1}}, "df": 1}}, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "k": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}}, "df": 1}}}}, "t": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 9}}}}, "h": {"docs": {}, "df": 0, "e": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 2.23606797749979}, "src.data.prepare.prepare_household_survey": {"tf": 1.4142135623730951}, "src.data.prepare.load_data": {"tf": 1}, "src.data.prepare.start_pipeline": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.rename_assets_column": {"tf": 1}, "src.data.prepare.decode_demographic_attributes": {"tf": 1}, "src.data.prepare.decode_income_attributes": {"tf": 1}, "src.data.prepare.decode_housing_attributes": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.prepare.linear_regression": {"tf": 2}, "src.data.read.read_asset_damage": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 2}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 3.3166247903554}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 3.7416573867739413}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 2}, "src.data.write.calculate_resilience": {"tf": 1.7320508075688772}, "src.model.initialize_model": {"tf": 1}, "src.model.run_model": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.7320508075688772}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 2.449489742783178}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1.7320508075688772}, "src.modules.optimize.run_optimization": {"tf": 3.3166247903554}}, "df": 31, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}, "a": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 4}, "n": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 6}}, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "d": {"docs": {"src.modules.households.duplicate_households": {"tf": 1}}, "df": 1}}}}}}}, "i": {"docs": {}, "df": 0, "s": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}}, "df": 1}}}, "o": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 2}, "src.data.prepare.rename_assets_column": {"tf": 1}, "src.data.prepare.add_missing_columns": {"tf": 1}, "src.data.write.add_columns": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.model.initialize_model": {"tf": 1.4142135623730951}, "src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1.4142135623730951}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.7320508075688772}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.apply_individual_policy": {"tf": 1.4142135623730951}}, "df": 11, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1.4142135623730951}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 6}}}, "p": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1.4142135623730951}}, "df": 1}}, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.write.calculate_resilience": {"tf": 1}}, "df": 1, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "p": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 1}}}}}}}, "r": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}}, "df": 2}}}, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1.7320508075688772}}, "df": 1}}}}}}, "e": {"docs": {}, "df": 0, "x": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}}, "df": 1}}}}}}}, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.data.read.get_asset_damage": {"tf": 1.4142135623730951}, "src.data.write.get_outcomes": {"tf": 1.4142135623730951}, "src.modules.households.calculate_pml": {"tf": 1.7320508075688772}}, "df": 3}}}}, "n": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.households.estimate_savings": {"tf": 1}}, "df": 2}}}}}}}}, "o": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.calculate_exposure": {"tf": 2.23606797749979}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 2}}}}}}, "c": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}}, "df": 3}}}}}}}}, "m": {"docs": {}, "df": 0, "a": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}}, "df": 1}}, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1.4142135623730951}}, "df": 2}}}}, "n": {"docs": {}, "df": 0, "d": {"docs": {"src.data.write.find_poor": {"tf": 1.4142135623730951}, "src.data.write.calculate_poverty_gap": {"tf": 1.7320508075688772}}, "df": 2}}, "a": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "h": {"docs": {"src.data.write.get_people_by_years_in_poverty": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 3}}}, "q": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {"src.modules.households.duplicate_households": {"tf": 1}}, "df": 1}}}}, "f": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}}, "df": 2}}}}}}}}, "s": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.estimate_savings": {"tf": 1.4142135623730951}}, "df": 1, "d": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}}, "df": 1}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}}, "df": 1}}}}}}}}}}, "w": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "k": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "h": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}}, "df": 1}}}}}}}}, "h": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1.4142135623730951}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}}, "df": 5}}}}}}, "e": {"docs": {"src.model.initialize_model": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 3, "i": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "h": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.calculate_pml": {"tf": 1}}, "df": 1, "s": {"docs": {"src.modules.households.duplicate_households": {"tf": 1.4142135623730951}}, "df": 1}}}}}}, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "h": {"docs": {"src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 9}}}, "a": {"docs": {}, "df": 0, "s": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 2}}}, "p": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}}, "df": 1}}}, "y": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 2.23606797749979}}, "df": 2}}}}, "o": {"docs": {}, "df": 0, "r": {"1": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}, "2": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}, "docs": {"src.data.write.find_poor": {"tf": 2.23606797749979}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1.4142135623730951}, "src.data.write.calculate_poverty_gap": {"tf": 2}, "src.modules.households.apply_individual_policy": {"tf": 1.7320508075688772}}, "df": 4}}, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.data.write.find_poor": {"tf": 1.4142135623730951}, "src.data.write.get_people_by_years_in_poverty": {"tf": 2}, "src.data.write.calculate_poverty_gap": {"tf": 2.23606797749979}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.7320508075688772}}, "df": 5}}}}}, "p": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.modules.households.calculate_pml": {"tf": 1}}, "df": 1}}}}}}}}}, "d": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 19}, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.prepare.prepare_household_survey": {"tf": 1}}, "df": 2}}}}, "d": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.linear_regression": {"tf": 1}}, "df": 1}}}}}}}, "o": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.data.prepare.start_pipeline": {"tf": 1}}, "df": 1}}}}}}}, "d": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}}, "df": 2, "i": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.data.write.get_outcomes": {"tf": 1.4142135623730951}, "src.modules.households.calculate_average_productivity": {"tf": 1.7320508075688772}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 3}}}}}}}}}, "b": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1}}, "df": 3}}, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}}}}}}}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {"src.data.read.get_asset_damage": {"tf": 1.4142135623730951}, "src.modules.households.calculate_average_productivity": {"tf": 1.4142135623730951}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}}, "df": 5}}}}, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "s": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 4}}}}}, "s": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 3}}}}}, "i": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.start_pipeline": {"tf": 1}}, "df": 1}}}}}}}, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "d": {"docs": {"src.data.read.get_asset_damage": {"tf": 1.4142135623730951}}, "df": 1}}}, "c": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.calculate_average_annual_consumption_loss": {"tf": 1.4142135623730951}}, "df": 1}}}}}}}}, "o": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.get_people_by_years_in_poverty": {"tf": 1.4142135623730951}}, "df": 1}}}}}, "m": {"docs": {}, "df": 0, "l": {"docs": {"src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 2}}}, "b": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "l": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1.4142135623730951}, "src.data.read.get_asset_damage": {"tf": 1}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}}, "df": 7}}}, "e": {"docs": {"src.data.prepare.rename_assets_column": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 5, "g": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.data.write.find_poor": {"tf": 1.4142135623730951}, "src.data.write.calculate_poverty_gap": {"tf": 1.7320508075688772}}, "df": 2}}}}}}}, "t": {"docs": {}, "df": 0, "w": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "n": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}}}}, "y": {"docs": {"src.model.initialize_model": {"tf": 1}}, "df": 1}, "a": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 2}}}}, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "s": {"docs": {"src.modules.households.calculate_exposure": {"tf": 1.7320508075688772}}, "df": 1}}}, "u": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}}}, "v": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1}}, "df": 1, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1.4142135623730951}, "src.data.prepare.linear_regression": {"tf": 1}}, "df": 2}, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "r": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1.4142135623730951}, "src.data.read.read_household_survey": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1.4142135623730951}}, "df": 6}}}}}}}}}, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.households.set_vulnerability": {"tf": 2.23606797749979}, "src.modules.households.calculate_exposure": {"tf": 1}}, "df": 2}}}}}}}}}}}}}, "u": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}}, "df": 1}}}, "y": {"docs": {"src.data.analyse.prepare_outcomes": {"tf": 1}}, "df": 1}}}}}}}}}, "i": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "m": {"docs": {"src.modules.households.set_vulnerability": {"tf": 1}}, "df": 1}}}}}}, "p": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1.4142135623730951}}, "df": 1}, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "y": {"docs": {"src.modules.optimize.run_optimization": {"tf": 1}}, "df": 1}}}}}}}, "l": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "l": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}}, "df": 1}}}, "s": {"docs": {}, "df": 0, "s": {"docs": {"src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 2}}}, "o": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.load_data": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}}, "df": 2}}, "s": {"docs": {}, "df": 0, "s": {"docs": {"src.data.read.get_asset_damage": {"tf": 1.4142135623730951}, "src.data.write.get_outcomes": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 2.23606797749979}, "src.data.write.calculate_resilience": {"tf": 1.4142135623730951}, "src.modules.households.calculate_pml": {"tf": 2.23606797749979}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 7}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.find_poor": {"tf": 1.4142135623730951}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 2}}, "df": 3, "a": {"docs": {}, "df": 0, "r": {"docs": {"src.data.prepare.linear_regression": {"tf": 1}}, "df": 1}}}}}, "u": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {"src.data.read.read_household_survey": {"tf": 1}}, "df": 1}}}}, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}}}}, "s": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}}, "df": 1}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.modules.households.estimate_savings": {"tf": 1.7320508075688772}}, "df": 1, "s": {"docs": {"src.modules.households.estimate_savings": {"tf": 2.23606797749979}}, "df": 1}}}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "t": {"docs": {"src.data.read.read_household_survey": {"tf": 1}}, "df": 1}}}, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 2}, "p": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {"src.model.initialize_model": {"tf": 1}}, "df": 1}}}}}, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "n": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 2}, "src.data.write.calculate_poverty_gap": {"tf": 2}}, "df": 4}}}}}}}}, "n": {"docs": {}, "df": 0, "g": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}}}}}, "t": {"docs": {}, "df": 0, "r": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1.4142135623730951}, "src.data.read.read_household_survey": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 5, "u": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}}}}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}}}}, "a": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.start_pipeline": {"tf": 1}}, "df": 1}}, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "s": {"docs": {"src.data.read.get_asset_damage": {"tf": 1.4142135623730951}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}}, "df": 5}}}}}}}}, "o": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "k": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1.4142135623730951}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.4142135623730951}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}}, "df": 5}}}}, "u": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "p": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}}, "df": 3}}}}}}}, "b": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.subset_columns": {"tf": 1}}, "df": 1}}}}, "r": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "y": {"docs": {"src.data.read.read_household_survey": {"tf": 1.4142135623730951}, "src.model.initialize_model": {"tf": 1.4142135623730951}, "src.modules.households.duplicate_households": {"tf": 1.7320508075688772}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1.7320508075688772}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1.4142135623730951}, "src.modules.households.apply_individual_policy": {"tf": 1.4142135623730951}}, "df": 11}}}}}, "e": {"docs": {}, "df": 0, "t": {"docs": {"src.data.prepare.rename_other_columns": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}}, "df": 2}, "e": {"docs": {"src.data.prepare.rename_other_columns": {"tf": 1}}, "df": 1}, "l": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "t": {"docs": {"src.modules.households.select_district": {"tf": 1}}, "df": 1}}}}}, "c": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.linear_regression": {"tf": 1}}, "df": 1}}}, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "e": {"docs": {"src.data.read.get_asset_damage": {"tf": 1.7320508075688772}}, "df": 1}}}}, "p": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "f": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "c": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}, "src.modules.households.select_district": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}, "src.modules.households.calculate_exposure": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}, "src.modules.households.apply_individual_policy": {"tf": 1.4142135623730951}}, "df": 7}}}}}}}}, "x": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "x": {"docs": {"src.data.prepare.prepare_asset_damage": {"tf": 1}, "src.data.read.read_asset_damage": {"tf": 1}}, "df": 2}}}}, "m": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "d": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "l": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.write.get_outcomes": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.model.run_model": {"tf": 1}}, "df": 4}}}, "r": {"docs": {}, "df": 0, "e": {"docs": {"src.data.prepare.rename_assets_column": {"tf": 1}}, "df": 1}}}, "a": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "y": {"docs": {"src.data.prepare.add_missing_columns": {"tf": 1}}, "df": 1}}}}}}, "x": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "m": {"docs": {"src.data.write.calculate_resilience": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1}}, "df": 3}}}}}, "t": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "h": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}, "s": {"docs": {}, "df": 0, "k": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1}}}, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.data.prepare.add_missing_columns": {"tf": 1}}, "df": 1}}}}, "m": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "c": {"docs": {}, "df": 0, "h": {"docs": {"src.modules.households.adjust_assets_and_expenditure": {"tf": 1}}, "df": 1}}}}}}, "n": {"docs": {"src.model.initialize_model": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}}, "df": 2, "i": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "m": {"docs": {"src.model.initialize_model": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}}, "df": 2}}}}}}, "e": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "r": {"docs": {}, "df": 0, "y": {"docs": {"src.data.read.read_asset_damage": {"tf": 1}}, "df": 1}}}}}, "y": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1}}, "df": 1}}, "n": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 4, "o": {"docs": {"src.modules.households.determine_affected": {"tf": 1}}, "df": 1, "t": {"docs": {"src.data.prepare.prepare_household_survey": {"tf": 1}, "src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}}, "df": 6}, "i": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}, "src.modules.households.set_vulnerability": {"tf": 1}}, "df": 2}}}}, "e": {"docs": {}, "df": 0, "w": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}, "src.data.write.find_poor": {"tf": 1.4142135623730951}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1.4142135623730951}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}}, "df": 5}, "e": {"docs": {}, "df": 0, "d": {"docs": {"src.model.initialize_model": {"tf": 1}}, "df": 1}}, "a": {"docs": {}, "df": 0, "r": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1.4142135623730951}}, "df": 1}}}, "a": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "e": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1}, "src.model.initialize_model": {"tf": 1}}, "df": 3}}}, "u": {"docs": {}, "df": 0, "m": {"docs": {}, "df": 0, "b": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {"src.data.write.get_outcomes": {"tf": 1}, "src.data.write.find_poor": {"tf": 1.4142135623730951}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1.4142135623730951}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}, "src.model.initialize_model": {"tf": 1}, "src.modules.households.duplicate_households": {"tf": 1.4142135623730951}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 9}}}}}}, "h": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "e": {"docs": {"src.modules.households.calculate_average_productivity": {"tf": 1}}, "df": 1, "h": {"docs": {}, "df": 0, "o": {"docs": {}, "df": 0, "l": {"docs": {}, "df": 0, "d": {"docs": {"src.data.prepare.add_is_rural_column": {"tf": 1}, "src.data.read.read_household_survey": {"tf": 1.4142135623730951}, "src.data.write.find_poor": {"tf": 1}, "src.model.initialize_model": {"tf": 1.4142135623730951}, "src.modules.households.duplicate_households": {"tf": 1.7320508075688772}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 2}, "src.modules.households.calculate_pml": {"tf": 1.4142135623730951}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 1.7320508075688772}, "src.modules.households.apply_individual_policy": {"tf": 1.4142135623730951}, "src.modules.optimize.run_optimization": {"tf": 1}}, "df": 14, "s": {"docs": {"src.data.write.add_columns": {"tf": 1.4142135623730951}, "src.data.write.get_outcomes": {"tf": 1.4142135623730951}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1.4142135623730951}, "src.data.write.calculate_resilience": {"tf": 1.7320508075688772}, "src.model.initialize_model": {"tf": 1.4142135623730951}, "src.modules.households.duplicate_households": {"tf": 2.449489742783178}, "src.modules.households.calculate_average_productivity": {"tf": 1}, "src.modules.households.adjust_assets_and_expenditure": {"tf": 1}, "src.modules.households.calculate_pml": {"tf": 1}, "src.modules.households.select_district": {"tf": 1}, "src.modules.households.estimate_savings": {"tf": 1.4142135623730951}, "src.modules.households.set_vulnerability": {"tf": 1.4142135623730951}, "src.modules.households.calculate_exposure": {"tf": 1.4142135623730951}, "src.modules.households.determine_affected": {"tf": 2.23606797749979}, "src.modules.households.apply_individual_policy": {"tf": 1.4142135623730951}, "src.modules.optimize.run_optimization": {"tf": 1.7320508075688772}}, "df": 17}}}}}}, "i": {"docs": {}, "df": 0, "n": {"docs": {}, "df": 0, "g": {"docs": {"src.data.prepare.decode_housing_attributes": {"tf": 1}, "src.data.prepare.add_housing_attributes": {"tf": 1}}, "df": 2}}}}}}, "a": {"docs": {}, "df": 0, "v": {"docs": {}, "df": 0, "e": {"docs": {"src.model.initialize_model": {"tf": 1}, "src.modules.households.determine_affected": {"tf": 1}}, "df": 2}}}}, "g": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "t": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.find_poor": {"tf": 1}, "src.data.write.get_people_by_years_in_poverty": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}}, "df": 4}}, "r": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "t": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "r": {"docs": {"src.data.read.get_asset_damage": {"tf": 1}, "src.data.write.calculate_poverty_gap": {"tf": 1}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1}, "src.data.write.calculate_resilience": {"tf": 1}}, "df": 4}}}}}, "o": {"docs": {}, "df": 0, "u": {"docs": {}, "df": 0, "p": {"docs": {"src.modules.households.apply_individual_policy": {"tf": 1.7320508075688772}}, "df": 1}}}}, "a": {"docs": {}, "df": 0, "p": {"docs": {"src.data.write.calculate_poverty_gap": {"tf": 1.7320508075688772}}, "df": 1}, "u": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "s": {"docs": {}, "df": 0, "i": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "n": {"docs": {"src.modules.households.estimate_savings": {"tf": 1}}, "df": 1}}}}}}}}, "y": {"docs": {}, "df": 0, "e": {"docs": {}, "df": 0, "a": {"docs": {}, "df": 0, "r": {"docs": {"src.data.write.get_people_by_years_in_poverty": {"tf": 1.4142135623730951}}, "df": 1, "s": {"docs": {"src.data.write.get_outcomes": {"tf": 1.4142135623730951}, "src.data.write.calculate_poverty_gap": {"tf": 1.4142135623730951}, "src.data.write.calculate_average_annual_consumption_loss": {"tf": 1.4142135623730951}, "src.modules.optimize.run_optimization": {"tf": 1.4142135623730951}}, "df": 4}}}}}, "k": {"docs": {"src.modules.households.calculate_average_productivity": {"tf": 1}}, "df": 1}}}}, "pipeline": ["trimmer"], "_isPrebuiltIndex": true}; - - // mirrored in build-search-index.js (part 1) - // Also split on html tags. this is a cheap heuristic, but good enough. - elasticlunr.tokenizer.setSeperator(/[\s\-.;&_'"=,()]+|<[^>]*>/); - - let searchIndex; - if (docs._isPrebuiltIndex) { - console.info("using precompiled search index"); - searchIndex = elasticlunr.Index.load(docs); - } else { - console.time("building search index"); - // mirrored in build-search-index.js (part 2) - searchIndex = elasticlunr(function () { - this.pipeline.remove(elasticlunr.stemmer); - this.pipeline.remove(elasticlunr.stopWordFilter); - this.addField("qualname"); - this.addField("fullname"); - this.addField("annotation"); - this.addField("default_value"); - this.addField("signature"); - this.addField("bases"); - this.addField("doc"); - this.setRef("fullname"); - }); - for (let doc of docs) { - searchIndex.addDoc(doc); - } - console.timeEnd("building search index"); - } - - return (term) => searchIndex.search(term, { - fields: { - qualname: {boost: 4}, - fullname: {boost: 2}, - annotation: {boost: 2}, - default_value: {boost: 2}, - signature: {boost: 2}, - bases: {boost: 2}, - doc: {boost: 1}, - }, - expand: true - }); -})(); \ No newline at end of file diff --git a/docs/src.html b/docs/src.html deleted file mode 100644 index 3383478..0000000 --- a/docs/src.html +++ /dev/null @@ -1,234 +0,0 @@ - - - - - - -1# Prepare the results of the experiments for the analysis. - 2 - 3import pandas as pd - 4import numpy as np - 5import ast - 6import geopandas as gpd - 7from ema_workbench import load_results - 8 - 9 - 10def prepare_outcomes(results: tuple, add_policies: bool, add_uncertainties: bool) -> pd.DataFrame: - 11 '''Convert outcomes dict into a data frame. - 12 - 13 Args: - 14 results (tuple): The results of the experiments in the EMA Workbench format. - 15 add_policies (bool): Whether to add policy values to the data frame. - 16 add_uncertainties (bool): Whether to add uncertainty values to the data frame. - 17 - 18 Returns: - 19 pd.DataFrame: Outcomes data frame. - 20 ''' - 21 # * Note that we specify all outcomes in `get_outcomes` function in `write.py` - 22 # * Here we just read them in the same sequence that they are written - 23 outcome_names = [ - 24 'total_population', - 25 'total_asset_loss', - 26 'total_consumption_loss', - 27 'event_damage', - 28 'total_asset_stock', - 29 'average_productivity', - 30 'total_asset_in_survey', - 31 'expected_loss_fraction', - 32 'n_affected_people', - 33 'annual_average_consumption', - 34 'poverty_line_adjusted', - 35 'pml', - 36 'n_poor_initial', - 37 'n_poor_affected', - 38 'n_new_poor', - 39 'initial_poverty_gap', - 40 'new_poverty_gap', - 41 'annual_average_consumption_loss', - 42 'annual_average_consumption_loss_pct', - 43 'r', - 44 'recovery_rate', - 45 'years_in_poverty', - 46 ] - 47 - 48 uncertainty_names = ['consumption_utility', - 49 'discount_rate', - 50 'income_and_expenditure_growth', - 51 'poverty_bias'] - 52 - 53 experiments, _ = results - 54 experiments['random_seed'] = experiments['random_seed'].astype(int) - 55 experiments['scenario'] = experiments['scenario'].astype(int) - 56 if len(experiments['random_seed'].unique()) != experiments['scenario'].max() - experiments['scenario'].min() + 1: - 57 # print(experiments['random_seed'].value_counts()) - 58 print('WARNING! Random seeds are not unique.') - 59 # raise ValueError('Random seeds are not unique') - 60 - 61 policy_names = ['my_policy'] - 62 - 63 if add_policies: - 64 if add_uncertainties: - 65 columns = ['scenario', 'policy', 'district', 'random_seed'] + \ - 66 policy_names + uncertainty_names + outcome_names - 67 else: - 68 columns = ['scenario', 'policy', 'district', 'random_seed'] + \ - 69 policy_names + outcome_names - 70 else: - 71 if add_uncertainties: - 72 columns = ['scenario', 'policy', 'district', 'random_seed'] + \ - 73 uncertainty_names + outcome_names - 74 else: - 75 columns = ['scenario', 'policy', 'district', - 76 'random_seed'] + outcome_names - 77 - 78 scenarios = results[0]['scenario'].values - 79 n_scenarios = results[0]['scenario'].unique().size - 80 policies = results[0]['policy'].values - 81 random_seeds = results[0]['random_seed'].values - 82 n_policies = results[0]['policy'].unique().size - 83 n_districts = len(results[1].keys()) - 84 - 85 if add_policies: - 86 policy_values = results[0][policy_names].values - 87 - 88 if add_uncertainties: - 89 uncertainty_values = results[0][uncertainty_names].values - 90 - 91 n_columns = len(columns) - 92 n_rows = n_scenarios * n_policies * n_districts - 93 outcomes = np.zeros((n_rows, n_columns), dtype=object) - 94 - 95 i = 0 # To iterate over rows = scenarios * policies * districts - 96 for district, district_outcomes in results[1].items(): - 97 # To iterate over rows = scenarios * policies (experiments dataframe) - 98 k = 0 - 99 # We reset k every time we change district -100 for arr in district_outcomes: -101 # The first 3 rows for scenario, policy and district -102 outcomes[i, 0] = scenarios[k] -103 outcomes[i, 1] = policies[k] -104 outcomes[i, 2] = district -105 outcomes[i, 3] = random_seeds[k] -106 -107 if add_policies: -108 if add_uncertainties: -109 # Add policy values -110 # From 4 to 4 + len(policy_names) policy values -111 for j, name in enumerate(policy_names): -112 outcomes[i, 4 + j] = policy_values[k, j] -113 -114 # Add uncertainty values -115 # From 4 + len(policy_names) to 4 + len(policy_names) + len(uncertainty_names) uncertainty values -116 for j, name in enumerate(uncertainty_names): -117 outcomes[i, 4 + len(policy_names) + j] = uncertainty_values[k, j] -118 -119 # Add outcomes -120 # From 4 + len(policy_names) + len(uncertainty_names) to 4 + len(policy_names) + len(uncertainty_names) + len(outcome_names) outcomes -121 l = 4 + len(policy_names) + len(uncertainty_names) -122 for v, name in zip(arr, outcome_names): -123 if name == 'years_in_poverty': -124 outcomes[i, l] = ast.literal_eval(v) -125 else: -126 outcomes[i, l] = v -127 l += 1 -128 else: -129 # Add policy values -130 # From 4 to 4 + len(policy_names) policy values -131 for j, name in enumerate(policy_names): -132 outcomes[i, 4 + j] = policy_values[k, j] -133 -134 # Add outcomes -135 # From 4 + len(policy_names) to 4 + len(policy_names) + len(outcome_names) outcomes -136 l = 4 + len(policy_names) -137 for v, name in zip(arr, outcome_names): -138 if name == 'years_in_poverty': -139 outcomes[i, l] = ast.literal_eval(v) -140 else: -141 outcomes[i, l] = v -142 l += 1 -143 else: -144 if add_uncertainties: -145 # Add uncertainty values -146 # From 4 to 4 + len(uncertainty_names) uncertainty values -147 for j, name in enumerate(uncertainty_names): -148 outcomes[i, 4 + j] = uncertainty_values[k, j] -149 -150 # Add outcomes -151 # From 4 + len(uncertainty_names) to 4 + len(uncertainty_names) + len(outcome_names) outcomes -152 l = 4 + len(uncertainty_names) -153 for v, name in zip(arr, outcome_names): -154 if name == 'years_in_poverty': -155 outcomes[i, l] = ast.literal_eval(v) -156 else: -157 outcomes[i, l] = v -158 l += 1 -159 else: -160 # Add outcomes -161 # From 4 to 4 + len(outcome_names) outcomes -162 l = 4 -163 for v, name in zip(arr, outcome_names): -164 if name == 'years_in_poverty': -165 outcomes[i, l] = ast.literal_eval(v) -166 else: -167 outcomes[i, l] = v -168 l += 1 -169 k += 1 # increase row index to get next experiment for the current district -170 i += 1 # increase row index of the outcomes dataframe -171 outcomes = pd.DataFrame(outcomes, columns=columns) -172 -173 # Convert numeric columns to numeric -174 if add_policies: -175 numeric_columns = outcomes.columns[5:-1].tolist() -176 outcomes[numeric_columns] = outcomes[numeric_columns].apply( -177 pd.to_numeric) -178 else: -179 numeric_columns = outcomes.columns[4:-1].tolist() -180 outcomes[numeric_columns] = outcomes[numeric_columns].apply( -181 pd.to_numeric) -182 -183 # Rename a district -184 outcomes['district'].replace( -185 {'AnseLaRayeCanaries': 'Anse-La-Raye & Canaries'}, inplace=True) -186 -187 # Convert pct columns to percentage -188 outcomes['annual_average_consumption_loss_pct'] = outcomes['annual_average_consumption_loss_pct'] * 100 -189 outcomes['initial_poverty_gap'] = outcomes['initial_poverty_gap'] * 100 -190 outcomes['new_poverty_gap'] = outcomes['new_poverty_gap'] * 100 -191 -192 # Calculate the percentage of new poor -193 outcomes = outcomes.assign(n_new_poor_increase_pct=outcomes['n_new_poor'].div( -194 outcomes['total_population']).multiply(100)) -195 -196 # outcomes['pct_poor_before'] = outcomes['n_poor_initial'].div( -197 # outcomes['total_population']) -198 # outcomes['pct_poor_after'] = outcomes['n_new_poor'].add( -199 # outcomes['n_poor_initial']).div(outcomes['total_population']) -200 # outcomes['pct_poor_increase'] = outcomes['pct_poor_after'].sub( -201 # outcomes['pct_poor_before']) -202 -203 # Move years_in_poverty column to the end of the data frame -204 outcomes = outcomes[[c for c in outcomes if c not in [ -205 'years_in_poverty']] + ['years_in_poverty']] -206 -207 return outcomes -208 -209 -210def get_spatial_outcomes(outcomes: pd.DataFrame, outcomes_of_interest: list = [], country: str = 'Saint Lucia', aggregation: str = 'mean') -> gpd.GeoDataFrame: -211 # Load country shapefile -212 country = 'Saint Lucia' -213 gdf = gpd.read_file( -214 f'../data/raw/shapefiles/{country}/gadm36_LCA_shp/gadm36_LCA_1.shp') -215 -216 # Align district names with the ones in the outcomes -217 gdf['NAME_1'].replace( -218 {'Soufrière': 'Soufriere', 'Vieux Fort': 'Vieuxfort'}, inplace=True) -219 -220 # Merge Anse-la-Raye and Canaries into a single geometry -221 geometry = gdf[gdf['NAME_1'].isin( -222 ['Anse-la-Raye', 'Canaries'])].unary_union -223 -224 # Add it to the dataframe -225 gdf.loc[len(gdf)] = [None, None, 'LCA.11_1', 'Anse-La-Raye & Canaries', -226 None, None, None, None, None, None, geometry] -227 gdf = gdf[gdf['NAME_1'].isin(outcomes['district'].unique())] -228 -229 if len(outcomes_of_interest) == 0: -230 outcomes_of_interest = ['total_asset_loss', -231 'total_consumption_loss', -232 'n_affected_people', -233 'n_new_poor', -234 'new_poverty_gap', -235 'annual_average_consumption_loss', -236 'annual_average_consumption_loss_pct', -237 'n_new_poor_increase_pct', -238 'r'] -239 -240 # Aggregate outcomes -241 if aggregation == 'mean': -242 aggregated = outcomes[['district'] + -243 outcomes_of_interest].groupby('district').mean() -244 elif aggregation == 'median': -245 aggregated = outcomes[['district'] + -246 outcomes_of_interest].groupby('district').median() -247 else: -248 raise ValueError('Aggregation must be either mean or median') -249 -250 # Merge with the shapefile -251 gdf = pd.merge(gdf, aggregated, left_on='NAME_1', right_index=True) -252 gdf.reset_index(inplace=True, drop=True) -253 return gdf -254 -255 -256def get_policy_effectiveness_tab(outcomes: pd.DataFrame) -> pd.DataFrame: -257 policy_name_mapper = {'all+0': 'None', -258 'all+10': '10% to all', -259 'all+30': '30% to all', -260 'all+50': '50% to all', -261 'all+100': '100% to all', -262 'poor+0': 'None', -263 'poor+10': '10% to poor', -264 'poor+30': '30% to poor', -265 'poor+50': '50% to poor', -266 'poor+100': '100% to poor', -267 'poor_near_poor1.25+0': 'None', -268 'poor_near_poor1.25+10': '10% to poor and near poor (1.25)', -269 'poor_near_poor1.25+30': '30% to poor and near poor (1.25)', -270 'poor_near_poor1.25+50': '50% to poor and near poor (1.25)', -271 'poor_near_poor1.25+100': '100% to poor and near poor (1.25)', -272 'poor_near_poor2.0+0': 'None', -273 'poor_near_poor2.0+10': '10% to poor and near poor (2.0)', -274 'poor_near_poor2.0+30': '30% to poor and near poor (2.0)', -275 'poor_near_poor2.0+50': '50% to poor and near poor (2.0)', -276 'poor_near_poor2.0+100': '100% to poor and near poor (2.0)'} -277 df = outcomes.copy() -278 df['my_policy'] = df['my_policy'].replace(policy_name_mapper) -279 df['my_policy'] = pd.Categorical(df['my_policy'], categories=['None', '10% to all', '30% to all', '50% to all', '100% to all', -280 '10% to poor', '30% to poor', '50% to poor', '100% to poor', -281 '10% to poor and near poor (1.25)', '30% to poor and near poor (1.25)', '50% to poor and near poor (1.25)', '100% to poor and near poor (1.25)', -282 '10% to poor and near poor (2.0)', '30% to poor and near poor (2.0)', '50% to poor and near poor (2.0)', '100% to poor and near poor (2.0)'], ordered=True) -283 df.rename(columns={'my_policy': 'Policy', -284 'district': 'District'}, inplace=True) -285 df.rename(columns={'annual_average_consumption_loss_pct': 'Annual average consumption loss (%)', -286 'n_new_poor': 'Number of new poor'}, -287 inplace=True) -288 df['Policy ID'] = df['Policy'].cat.codes -289 return df -
11def prepare_outcomes(results: tuple, add_policies: bool, add_uncertainties: bool) -> pd.DataFrame: - 12 '''Convert outcomes dict into a data frame. - 13 - 14 Args: - 15 results (tuple): The results of the experiments in the EMA Workbench format. - 16 add_policies (bool): Whether to add policy values to the data frame. - 17 add_uncertainties (bool): Whether to add uncertainty values to the data frame. - 18 - 19 Returns: - 20 pd.DataFrame: Outcomes data frame. - 21 ''' - 22 # * Note that we specify all outcomes in `get_outcomes` function in `write.py` - 23 # * Here we just read them in the same sequence that they are written - 24 outcome_names = [ - 25 'total_population', - 26 'total_asset_loss', - 27 'total_consumption_loss', - 28 'event_damage', - 29 'total_asset_stock', - 30 'average_productivity', - 31 'total_asset_in_survey', - 32 'expected_loss_fraction', - 33 'n_affected_people', - 34 'annual_average_consumption', - 35 'poverty_line_adjusted', - 36 'pml', - 37 'n_poor_initial', - 38 'n_poor_affected', - 39 'n_new_poor', - 40 'initial_poverty_gap', - 41 'new_poverty_gap', - 42 'annual_average_consumption_loss', - 43 'annual_average_consumption_loss_pct', - 44 'r', - 45 'recovery_rate', - 46 'years_in_poverty', - 47 ] - 48 - 49 uncertainty_names = ['consumption_utility', - 50 'discount_rate', - 51 'income_and_expenditure_growth', - 52 'poverty_bias'] - 53 - 54 experiments, _ = results - 55 experiments['random_seed'] = experiments['random_seed'].astype(int) - 56 experiments['scenario'] = experiments['scenario'].astype(int) - 57 if len(experiments['random_seed'].unique()) != experiments['scenario'].max() - experiments['scenario'].min() + 1: - 58 # print(experiments['random_seed'].value_counts()) - 59 print('WARNING! Random seeds are not unique.') - 60 # raise ValueError('Random seeds are not unique') - 61 - 62 policy_names = ['my_policy'] - 63 - 64 if add_policies: - 65 if add_uncertainties: - 66 columns = ['scenario', 'policy', 'district', 'random_seed'] + \ - 67 policy_names + uncertainty_names + outcome_names - 68 else: - 69 columns = ['scenario', 'policy', 'district', 'random_seed'] + \ - 70 policy_names + outcome_names - 71 else: - 72 if add_uncertainties: - 73 columns = ['scenario', 'policy', 'district', 'random_seed'] + \ - 74 uncertainty_names + outcome_names - 75 else: - 76 columns = ['scenario', 'policy', 'district', - 77 'random_seed'] + outcome_names - 78 - 79 scenarios = results[0]['scenario'].values - 80 n_scenarios = results[0]['scenario'].unique().size - 81 policies = results[0]['policy'].values - 82 random_seeds = results[0]['random_seed'].values - 83 n_policies = results[0]['policy'].unique().size - 84 n_districts = len(results[1].keys()) - 85 - 86 if add_policies: - 87 policy_values = results[0][policy_names].values - 88 - 89 if add_uncertainties: - 90 uncertainty_values = results[0][uncertainty_names].values - 91 - 92 n_columns = len(columns) - 93 n_rows = n_scenarios * n_policies * n_districts - 94 outcomes = np.zeros((n_rows, n_columns), dtype=object) - 95 - 96 i = 0 # To iterate over rows = scenarios * policies * districts - 97 for district, district_outcomes in results[1].items(): - 98 # To iterate over rows = scenarios * policies (experiments dataframe) - 99 k = 0 -100 # We reset k every time we change district -101 for arr in district_outcomes: -102 # The first 3 rows for scenario, policy and district -103 outcomes[i, 0] = scenarios[k] -104 outcomes[i, 1] = policies[k] -105 outcomes[i, 2] = district -106 outcomes[i, 3] = random_seeds[k] -107 -108 if add_policies: -109 if add_uncertainties: -110 # Add policy values -111 # From 4 to 4 + len(policy_names) policy values -112 for j, name in enumerate(policy_names): -113 outcomes[i, 4 + j] = policy_values[k, j] -114 -115 # Add uncertainty values -116 # From 4 + len(policy_names) to 4 + len(policy_names) + len(uncertainty_names) uncertainty values -117 for j, name in enumerate(uncertainty_names): -118 outcomes[i, 4 + len(policy_names) + j] = uncertainty_values[k, j] -119 -120 # Add outcomes -121 # From 4 + len(policy_names) + len(uncertainty_names) to 4 + len(policy_names) + len(uncertainty_names) + len(outcome_names) outcomes -122 l = 4 + len(policy_names) + len(uncertainty_names) -123 for v, name in zip(arr, outcome_names): -124 if name == 'years_in_poverty': -125 outcomes[i, l] = ast.literal_eval(v) -126 else: -127 outcomes[i, l] = v -128 l += 1 -129 else: -130 # Add policy values -131 # From 4 to 4 + len(policy_names) policy values -132 for j, name in enumerate(policy_names): -133 outcomes[i, 4 + j] = policy_values[k, j] -134 -135 # Add outcomes -136 # From 4 + len(policy_names) to 4 + len(policy_names) + len(outcome_names) outcomes -137 l = 4 + len(policy_names) -138 for v, name in zip(arr, outcome_names): -139 if name == 'years_in_poverty': -140 outcomes[i, l] = ast.literal_eval(v) -141 else: -142 outcomes[i, l] = v -143 l += 1 -144 else: -145 if add_uncertainties: -146 # Add uncertainty values -147 # From 4 to 4 + len(uncertainty_names) uncertainty values -148 for j, name in enumerate(uncertainty_names): -149 outcomes[i, 4 + j] = uncertainty_values[k, j] -150 -151 # Add outcomes -152 # From 4 + len(uncertainty_names) to 4 + len(uncertainty_names) + len(outcome_names) outcomes -153 l = 4 + len(uncertainty_names) -154 for v, name in zip(arr, outcome_names): -155 if name == 'years_in_poverty': -156 outcomes[i, l] = ast.literal_eval(v) -157 else: -158 outcomes[i, l] = v -159 l += 1 -160 else: -161 # Add outcomes -162 # From 4 to 4 + len(outcome_names) outcomes -163 l = 4 -164 for v, name in zip(arr, outcome_names): -165 if name == 'years_in_poverty': -166 outcomes[i, l] = ast.literal_eval(v) -167 else: -168 outcomes[i, l] = v -169 l += 1 -170 k += 1 # increase row index to get next experiment for the current district -171 i += 1 # increase row index of the outcomes dataframe -172 outcomes = pd.DataFrame(outcomes, columns=columns) -173 -174 # Convert numeric columns to numeric -175 if add_policies: -176 numeric_columns = outcomes.columns[5:-1].tolist() -177 outcomes[numeric_columns] = outcomes[numeric_columns].apply( -178 pd.to_numeric) -179 else: -180 numeric_columns = outcomes.columns[4:-1].tolist() -181 outcomes[numeric_columns] = outcomes[numeric_columns].apply( -182 pd.to_numeric) -183 -184 # Rename a district -185 outcomes['district'].replace( -186 {'AnseLaRayeCanaries': 'Anse-La-Raye & Canaries'}, inplace=True) -187 -188 # Convert pct columns to percentage -189 outcomes['annual_average_consumption_loss_pct'] = outcomes['annual_average_consumption_loss_pct'] * 100 -190 outcomes['initial_poverty_gap'] = outcomes['initial_poverty_gap'] * 100 -191 outcomes['new_poverty_gap'] = outcomes['new_poverty_gap'] * 100 -192 -193 # Calculate the percentage of new poor -194 outcomes = outcomes.assign(n_new_poor_increase_pct=outcomes['n_new_poor'].div( -195 outcomes['total_population']).multiply(100)) -196 -197 # outcomes['pct_poor_before'] = outcomes['n_poor_initial'].div( -198 # outcomes['total_population']) -199 # outcomes['pct_poor_after'] = outcomes['n_new_poor'].add( -200 # outcomes['n_poor_initial']).div(outcomes['total_population']) -201 # outcomes['pct_poor_increase'] = outcomes['pct_poor_after'].sub( -202 # outcomes['pct_poor_before']) -203 -204 # Move years_in_poverty column to the end of the data frame -205 outcomes = outcomes[[c for c in outcomes if c not in [ -206 'years_in_poverty']] + ['years_in_poverty']] -207 -208 return outcomes -
Convert outcomes dict into a data frame.
- -Args: - results (tuple): The results of the experiments in the EMA Workbench format. - add_policies (bool): Whether to add policy values to the data frame. - add_uncertainties (bool): Whether to add uncertainty values to the data frame.
- -Returns: - pd.DataFrame: Outcomes data frame.
-211def get_spatial_outcomes(outcomes: pd.DataFrame, outcomes_of_interest: list = [], country: str = 'Saint Lucia', aggregation: str = 'mean') -> gpd.GeoDataFrame: -212 # Load country shapefile -213 country = 'Saint Lucia' -214 gdf = gpd.read_file( -215 f'../data/raw/shapefiles/{country}/gadm36_LCA_shp/gadm36_LCA_1.shp') -216 -217 # Align district names with the ones in the outcomes -218 gdf['NAME_1'].replace( -219 {'Soufrière': 'Soufriere', 'Vieux Fort': 'Vieuxfort'}, inplace=True) -220 -221 # Merge Anse-la-Raye and Canaries into a single geometry -222 geometry = gdf[gdf['NAME_1'].isin( -223 ['Anse-la-Raye', 'Canaries'])].unary_union -224 -225 # Add it to the dataframe -226 gdf.loc[len(gdf)] = [None, None, 'LCA.11_1', 'Anse-La-Raye & Canaries', -227 None, None, None, None, None, None, geometry] -228 gdf = gdf[gdf['NAME_1'].isin(outcomes['district'].unique())] -229 -230 if len(outcomes_of_interest) == 0: -231 outcomes_of_interest = ['total_asset_loss', -232 'total_consumption_loss', -233 'n_affected_people', -234 'n_new_poor', -235 'new_poverty_gap', -236 'annual_average_consumption_loss', -237 'annual_average_consumption_loss_pct', -238 'n_new_poor_increase_pct', -239 'r'] -240 -241 # Aggregate outcomes -242 if aggregation == 'mean': -243 aggregated = outcomes[['district'] + -244 outcomes_of_interest].groupby('district').mean() -245 elif aggregation == 'median': -246 aggregated = outcomes[['district'] + -247 outcomes_of_interest].groupby('district').median() -248 else: -249 raise ValueError('Aggregation must be either mean or median') -250 -251 # Merge with the shapefile -252 gdf = pd.merge(gdf, aggregated, left_on='NAME_1', right_index=True) -253 gdf.reset_index(inplace=True, drop=True) -254 return gdf -
257def get_policy_effectiveness_tab(outcomes: pd.DataFrame) -> pd.DataFrame: -258 policy_name_mapper = {'all+0': 'None', -259 'all+10': '10% to all', -260 'all+30': '30% to all', -261 'all+50': '50% to all', -262 'all+100': '100% to all', -263 'poor+0': 'None', -264 'poor+10': '10% to poor', -265 'poor+30': '30% to poor', -266 'poor+50': '50% to poor', -267 'poor+100': '100% to poor', -268 'poor_near_poor1.25+0': 'None', -269 'poor_near_poor1.25+10': '10% to poor and near poor (1.25)', -270 'poor_near_poor1.25+30': '30% to poor and near poor (1.25)', -271 'poor_near_poor1.25+50': '50% to poor and near poor (1.25)', -272 'poor_near_poor1.25+100': '100% to poor and near poor (1.25)', -273 'poor_near_poor2.0+0': 'None', -274 'poor_near_poor2.0+10': '10% to poor and near poor (2.0)', -275 'poor_near_poor2.0+30': '30% to poor and near poor (2.0)', -276 'poor_near_poor2.0+50': '50% to poor and near poor (2.0)', -277 'poor_near_poor2.0+100': '100% to poor and near poor (2.0)'} -278 df = outcomes.copy() -279 df['my_policy'] = df['my_policy'].replace(policy_name_mapper) -280 df['my_policy'] = pd.Categorical(df['my_policy'], categories=['None', '10% to all', '30% to all', '50% to all', '100% to all', -281 '10% to poor', '30% to poor', '50% to poor', '100% to poor', -282 '10% to poor and near poor (1.25)', '30% to poor and near poor (1.25)', '50% to poor and near poor (1.25)', '100% to poor and near poor (1.25)', -283 '10% to poor and near poor (2.0)', '30% to poor and near poor (2.0)', '50% to poor and near poor (2.0)', '100% to poor and near poor (2.0)'], ordered=True) -284 df.rename(columns={'my_policy': 'Policy', -285 'district': 'District'}, inplace=True) -286 df.rename(columns={'annual_average_consumption_loss_pct': 'Annual average consumption loss (%)', -287 'n_new_poor': 'Number of new poor'}, -288 inplace=True) -289 df['Policy ID'] = df['Policy'].cat.codes -290 return df -
1from sklearn.linear_model import LinearRegression - 2import numpy.polynomial.polynomial as poly - 3from sklearn.preprocessing import FunctionTransformer - 4import pandas as pd - 5import matplotlib.pyplot as plt - 6import numpy as np - 7 - 8 - 9# ---------------------------------------------------------------------------- # - 10# Asset damage data preparation # - 11# ---------------------------------------------------------------------------- # - 12 - 13def prepare_asset_damage(country: str, scale: str, return_period: int = 100) -> None: - 14 '''Prepare district-level asset damage data and save it into a XLSX file.''' - 15 if country == 'Saint Lucia': - 16 if scale == 'district': - 17 # Load raw data - 18 df = pd.read_excel( - 19 '../../data/raw/asset_damage/Saint Lucia/St Lucia 2015 exposure summary.xlsx', sheet_name='total by parish', skiprows=1) - 20 # Remove redundant columns - 21 df.drop(df.columns[0], axis=1, inplace=True) - 22 # Even though the data is by `parish``, let's call the corresponding column `district`` - 23 df.rename(columns={'Unnamed: 1': 'district'}, inplace=True) - 24 # !: Check whether rp is = 100 given the data - 25 df['rp'] = 100 - 26 df.rename( - 27 columns={'Combined Total': 'exposed_value'}, inplace=True) - 28 - 29 # !: Replace with the real data - 30 # Let's assume that PML is equal to AAL % by district * by the PML for the whole country - 31 # These values are from PML Results 19022016 SaintLucia FinalSummary2.xlsx - 32 total_pml = {10: 351733.75, # 3,517,337.50 - 33 50: 23523224.51, # 2,352,322,451.00 - 34 100: 59802419.04, # 5,980,241,904.00 - 35 250: 147799213.30, # 14,779,921,330.00 - 36 500: 248310895.20, # 24,831,089,520.00 - 37 1000: 377593847.00} # 37,759,384,700.00 - 38 aal = pd.read_excel( - 39 '../../data/processed/asset_damage/Saint Lucia/AAL Results 19022016 StLucia FinalSummary2 adjusted.xlsx', sheet_name='AAL St. Lucia Province') - 40 aal.set_index('Name', inplace=True) - 41 aal = aal[['AAL as % of Total AAL']] - 42 aal.columns = ['pml'] - 43 aal = aal[aal.index.notnull()] - 44 pml = aal.multiply(total_pml[return_period]) - 45 df = pd.merge(df, pml, left_on='district', right_index=True) - 46 df.to_excel( - 47 f'../../data/processed/asset_damage/{country}/{country}.xlsx', index=False) - 48 else: - 49 raise ValueError( - 50 'Only `district` scale is supported for Saint Lucia.') - 51 else: - 52 raise ValueError('Only `Saint Lucia` is supported.') - 53 - 54 - 55# ---------------------------------------------------------------------------- # - 56# Household data preparation # - 57# ---------------------------------------------------------------------------- # - 58 - 59# Prepare Saint Lucia data as an input into simulation model. - 60 - 61# There are 5 inputs into the simulation model: - 62# * 14 parameters in `parameters.xlsx` (incl. constants, uncertainties, simulation, scenario and policy parameters); - 63# * 3 assest damage parameters from the assest damage file (e.g. `Saint Lucia.xlsx`); - 64# * N model's algorithms parameters in `algorithms_parameters.xlsx`; - 65# * Average capital productivity (computed based on some values of household survey data); - 66# * A household survey (e.g. `saint_lucia.csv`). - 67 - 68# Here we going to prepare the latest - the household survey. - 69# Each row of the data is a household and each column is an attribute. - 70# We need to prepare it to match the format of the simulation model. - 71# Here is the list of columns that we need to have: - 72 - 73# * `hhid` - household id, - 74# * `popwgt` - float: [0,inf] (?: Maybe put a cap on this?), - 75# * `hhsize` - household size, - 76# * `hhweight` - household weight, - 77# * `state` - state, str - 78# * `aeexp`- float: [0,inf] (?: Maybe put a cap on this?) - 79# * `hhexp` - float: [0,inf] (?: Maybe put a cap on this?) - 80# * `is_poor` - boolean: False or True, - 81# * `aeinc` - float: [0,inf] (?: Maybe put a cap on this?) - 82# * `aesoc` - float: [0,inf] (?: Maybe put a cap on this?) - 83# * `k_house_ae` - float: [0,inf (?: Maybe put a cap on this?)] - 84# * `v_init` - initial vulnerability, float: [0,1] - 85# * `inc_safetynet_frac` - float: [0,1] - 86# * `delta_tax_safety` - float - 87# * `houses_owned` - int: [0,inf] (?: Maybe put a cap on this?) - 88# * `own_rent` - string: "own" or "rent" - 89# * `aeexp_house` - float - 90# * `percentile` - int: [1,100] - 91# * `decile` - int: [1,10] - 92# * `quintile` - int: [1,5] - 93 - 94# Here is the list of what we have at the very end. - 95# V - we have it, X - we don't have it, ! - we must have it, ? - we don't know what it is. - 96# hhid V - 97# popwgt V - 98# hhsize -> hhsize_ae ? - 99# hhweight -> hhwgt ? -100# state X -101# aaexp V -102# hhexp X -103# ispoor V -104# aeinc V -105# aesoc V -106# k_house_ae V -107# v_init V -108# inc_safetynet_frac X -109# delta_tax_safety X ! -110# houses_owned X -111# own_rent V -112# aaexp_house V -113# percentile X -114# decile V -115# quintile V -116 -117def prepare_household_survey(country: str) -> None: -118 '''Prepare data for the simulation model. -119 -120 Parameters -121 ---------- -122 country : str -123 -124 Raises -125 ------ -126 ValueError -127 If the country is not supported. -128 -129 ''' -130 # Data preprocessing description: -131 # 0. Load raw data -132 # 1. Change `parentid1` to `hhid` -133 # 2. Add `is_rural` column. 0 if `urban` is URBAN, if `urban` is RURAL then 1. -134 # 3. Rename `tvalassets` to `kreported`. -135 # 4. Rename a set of columns. -136 # 5. Calculate some household attributes. Need to figure out what they mean. -137 # 6. Add `financial_inst` column which has info on bank or credit union. -138 # 7. Decode income attributes. -139 # 8. Calculate some income attributes. Need to figure out what they mean. -140 # 9. Decode housing attributes. -141 # 10. Add new housing attributes. Need to figure out what they mean. -142 # 11. Add new insurance attributes. Need to figure out what they mean. -143 # 12. Calculate some housing attributes. Need to figure out what they mean. -144 # 13. Calculate povery attributes. Need to figure out what they mean. -145 # 14. Assign vulnerability by type of house. -146 # 15. Subset columns of interest. -147 # 16. Check which columns do we have and which do we miss. -148 # 17. Add missing columns. -149 # 18. Merge districts. -150 # 19. Save data. -151 -152 if country != 'Saint Lucia': -153 raise ValueError('Currently only Saint Lucia is supported.') -154 -155 print_statistics = True -156 data = load_data(print_statistics=print_statistics) -157 -158 # * Note that the sequence of the functions is important -159 result = (start_pipeline(data) -160 .pipe(add_is_rural_column, print_statistics=print_statistics) -161 .pipe(rename_assets_column) -162 .pipe(rename_other_columns) -163 .pipe(calculate_household_attributes) -164 .pipe(get_bank_or_credit_union) -165 .pipe(decode_demographic_attributes) -166 .pipe(decode_income_attributes) -167 .pipe(calculate_income_attributes) -168 .pipe(decode_housing_attributes) -169 .pipe(add_housing_attributes) -170 .pipe(add_insurance_attributes) -171 .pipe(calculate_housing_attributes) -172 .pipe(calculate_poverty_attributes) -173 .pipe(assign_housing_vulnerability) -174 .pipe(subset_columns) -175 .pipe(check_columns) -176 .pipe(add_missing_columns, missing_columns=['delta_tax_safety']) -177 .pipe(merge_districts) -178 ) -179 -180 result.to_csv( -181 f'../../data/processed/household_survey/{country}/{country}.csv ') -182 -183 -184def load_data(print_statistics: bool = True) -> pd.DataFrame: -185 """Load the raw data.""" -186 # Read the raw data -187 # * This dataset is the combined version of the household and persons files on parentid1 -188 data = pd.read_csv( -189 '../../data/raw/household_survey/Saint Lucia/SLCHBS2016PersonV12_Housing.csv', low_memory=False) -190 data.rename(columns={'parentid1': 'hhid'}, inplace=True) -191 -192 # Set the index to the household id -193 data.set_index('hhid', inplace=True) -194 -195 if print_statistics: -196 print('Number of rows: ', data.shape[0]) -197 print('Number of columns: ', data.shape[1]) -198 print('Number of duplicates based on index: ', -199 data.index.duplicated().sum()) -200 -201 return data -202 -203 -204def start_pipeline(data: pd.DataFrame): -205 """Start the data processing pipeline.""" -206 return data.copy() -207 -208 -209def add_is_rural_column(data: pd.DataFrame, print_statistics: bool = True) -> pd.DataFrame: -210 """Create a new column that indicates whether the household is rural or not.""" -211 data['is_rural'] = 0 -212 data.loc[data['urban'] == 'RURAL', 'is_rural'] = 1 -213 if print_statistics: -214 print('Number of rural households: ', data['is_rural'].sum()) -215 print('Number of urban households: ', -216 data.shape[0] - data['is_rural'].sum()) -217 return data -218 -219 -220def rename_assets_column(data: pd.DataFrame) -> pd.DataFrame: -221 """Rename the assets column to be more descriptive.""" -222 data.rename(columns={'tvalassets': 'kreported'}, inplace=True) -223 return data -224 -225 -226def rename_other_columns(data: pd.DataFrame) -> pd.DataFrame: -227 '''Rename a set of columns. See function for details.''' -228 data = data.rename(columns={'DISTRICT_NAME': 'district', -229 'persons': 'hhsize', -230 'totexp.x': 'hhexp', -231 'pcexpae.x': 'aeexp', -232 'hincome': 'hhinc', -233 'WT.x': 'pwgt', -234 'food.x': 'hhexp_food'}) -235 return data -236 -237# ? What does it mean? -238# hhwgt = WT.y from full_df with group by parentid1 or WT from House data -239# pwgt = WT.x from full_df or WT from Person data -240 -241# hhsize = number of people in a household -242 -243# ? What does it mean -244# ! Data doesn't have this column -245# pcinc = annual consumption per head -246 -247# ! That's quite an assumption -248# hhinc = pcinc * hhsize -249 -250# p4_23 is monthly income -251# p4_1 is months worked -252# pincome is monthly income -253# pincome_oth is annual other income -254# aincome is pincome * p4_1 + pincome_oth -255 -256# ! Data doesn't have this column -257# hincome is the sum of aincome -258 -259 -260def calculate_household_attributes(data: pd.DataFrame) -> pd.DataFrame: -261 lower = 1 -262 fill_na = 1 -263 data['popwgt'] = data.groupby('hhid')['pwgt'].transform('sum') -264 data['hhwgt'] = data['popwgt'] / data['hhsize'] -265 data['hhsize_ae'] = (data['hhexp'] / data['aeexp'] -266 ).fillna(fill_na).clip(lower=lower) -267 data['aewgt'] = data['pwgt']*(data['hhsize_ae'] / data['hhsize']) -268 return data -269 -270 -271def get_bank_or_credit_union(data: pd.DataFrame) -> pd.DataFrame: -272 data['financial_inst'] = 0 -273 data.loc[data['p1_11__3'] == 'yes - bank', 'financial_inst'] = 1 -274 data.loc[data['p1_11__2'] == 'yes - bank', 'financial_inst'] = 1 -275 data.loc[data['p1_11__2'] == 'yes - credit union', 'financial_inst'] = 1 -276 data.loc[data['p1_11__1'] == 'yes - bank', 'financial_inst'] = 1 -277 data.loc[data['p1_11__1'] == 'yes - credit union', 'financial_inst'] = 1 -278 return data -279 -280 -281def decode_demographic_attributes(data: pd.DataFrame) -> pd.DataFrame: -282 '''Decode the demographic attributes.''' -283 data = data.rename(columns={'p1_1': 'role', -284 'p1_2': 'sex', -285 'p1_3': 'age', -286 'p1_4': 'race', -287 'p1_5': 'religion', -288 'p1_6': 'marital_status', -289 'p1_7': 'cellphone'}) -290 return data -291 -292 -293def decode_income_attributes(data: pd.DataFrame) -> pd.DataFrame: -294 '''Decode the income-related attributes.''' -295 data = data.rename(columns={ -296 # 'p1_11':'bank_account', -297 'p4_1': 'months_worked', -298 'inc2231002': 'other_entrepreneurial', -299 'inc2331001': 'remits_intl', -300 'inc2341001': 'rental_income', -301 'inc2351001': 'dividends', # other -302 'inc2361001': 'interest', # other -303 'inc2361002': 'other_investment_income', # other -304 'inc2371001': 'pension_public', # UCT -305 'inc2371002': 'pension_private_LCA', # pension private -306 'inc2371003': 'pension_private_int', # pension private -307 'inc2371004': 'social_security', # UCT -308 # 'inc2381001':'annuity', # other -309 'inc2381002': 'public_assistance', # CCT -310 'inc2381003': 'child_support', # other -311 'inc2391001': 'scholarships', # other -312 'inc2391002': 'financial_aid', # other -313 'inc2391003': 'alimony', # other -314 'inc2391099': 'mystery' -315 }) -316 return data -317 -318 -319def calculate_income_attributes(data: pd.DataFrame) -> pd.DataFrame: -320 data['remits_dom'] = 0 -321 -322 # Primary job income -323 data['primary_income'] = data[['months_worked', 'pincome']].prod(axis=1) -324 -325 # Secondary income -326 data['cct'] = data['public_assistance'].copy() -327 data['uct'] = data[['pension_public', 'social_security']].sum(axis=1) -328 data['remits'] = data[['remits_intl', 'remits_dom']].sum(axis=1) -329 data['other_sources'] = data[['dividends', 'interest', 'child_support', 'alimony', 'financial_aid', -330 'scholarships', 'pension_private_LCA', 'pension_private_int', 'other_investment_income', 'mystery']].sum(axis=1) -331 data['secondary_income'] = data[['other_entrepreneurial', 'cct', -332 'uct', 'remits', 'rental_income', 'other_sources']].sum(axis=1) -333 -334 # Total income -335 data['total_income'] = data[[ -336 'primary_income', 'secondary_income']].sum(axis=1) -337 -338 return data -339 -340 -341def decode_housing_attributes(data: pd.DataFrame) -> pd.DataFrame: -342 '''Decode the housing-related attributes.''' -343 data = data.rename(columns={'s2': 'own_rent', -344 # owner-occupied -345 'c1900105': 'mortgage_monthly', -346 'c1900104': 'domicile_value', -347 'c1900101': 'new_home_purchase_price', -348 'c1900103': 'new_home_mortgage_monthly', -349 'c1800501': 'rental_income_furnished', -350 'c1800502': 'rental_income_unfurnished', -351 'c1800503': 'rental_income_business', -352 'c0421101': 'imputed_rent_monthly', -353 'c1252101': 'insurance_premium', -354 # rental -355 'c0411100': 'actual_rent_monthly', -356 # condition & construction -357 's9q1': 'had_shock', -358 'h1_2': 'walls', -359 'h1_3': 'roof', -360 'h1_13': 'yr_house_built'}) -361 return data -362 -363 -364def add_housing_attributes(data: pd.DataFrame) -> pd.DataFrame: -365 '''Introduce new housing attributes.''' -366 # ! An assumption -367 data['own_rent'] = data['own_rent'].replace({'own or rent free': 'own'}) -368 data['home_insured'] = data['insurance_premium'] > 0 -369 return data -370 -371 -372def add_insurance_attributes(data: pd.DataFrame) -> pd.DataFrame: -373 # ? What does it mean? -374 # National insurance corporation (unemployment) -375 data['NIC_enrolled'] = data['p4_18'].isin(['employer', 'self-employed']) -376 data['NIC_recipient'] = data['p4_17'].isin(['yes, from the nic']) -377 -378 # Health insurance -379 data = data.rename(columns={'p2_5': 'health_insurance'}) -380 return data -381 -382 -383def calculate_housing_attributes(data: pd.DataFrame) -> pd.DataFrame: -384 # Predict domicile value for hh that rent -385 data['k_house'] = data['domicile_value'].copy().fillna(0) -386 # total rent per capita per year -387 data['hhexp_house'] = 12 * data['imputed_rent_monthly'].copy() -388 data['hhexp_house'].update(12 * data['actual_rent_monthly']) -389 data['hhexp_house'] = data['hhexp_house'].clip(lower=0).fillna(0) -390 -391 # Urban population -392 training_slc = (data['domicile_value'] > 10 * data['imputed_rent_monthly'] -393 ) & (data['domicile_value'] < 1E6) & (data['is_rural'] == 0) -394 urban_predictor = linear_regression(data.loc[training_slc].dropna( -395 subset=['domicile_value', 'imputed_rent_monthly']), 'imputed_rent_monthly', 'domicile_value', return_model=True) -396 -397 prediction_slc = (data['own_rent'] == 'rent') & ( -398 data['is_rural'] == 0) & (data['actual_rent_monthly'] is not None) -399 data.loc[prediction_slc, 'k_house'] = urban_predictor.predict( -400 data.loc[prediction_slc, 'actual_rent_monthly'].values.reshape(-1, 1)) -401 -402 # Rural population -403 training_slc = (data['domicile_value'] > 10 * data['imputed_rent_monthly'] -404 ) & (data['domicile_value'] < 1E6) & (data['is_rural'] == 1) -405 rural_predictor = linear_regression(data.loc[training_slc].dropna( -406 subset=['domicile_value', 'imputed_rent_monthly']), 'imputed_rent_monthly', 'domicile_value', return_model=True) -407 -408 prediction_slc = (data['own_rent'] == 'rent') & ( -409 data['is_rural'] == 1) & (data['actual_rent_monthly'] is not None) -410 data.loc[prediction_slc, 'k_house'] = rural_predictor.predict( -411 data.loc[prediction_slc, 'actual_rent_monthly'].values.reshape(-1, 1)) -412 -413 # Correct for the households that reported unreasonably low domicile value -414 prediction_slc = (data['own_rent'] == 'own') & (data['is_rural'] == 0) & ( -415 data['k_house'] <= 10*data['imputed_rent_monthly']) -416 data.loc[prediction_slc, 'k_house'] = urban_predictor.predict( -417 data.loc[prediction_slc, 'imputed_rent_monthly'].values.reshape(-1, 1)) -418 -419 prediction_slc = (data['own_rent'] == 'own') & (data['is_rural'] == 1) & ( -420 data['k_house'] <= 10*data['imputed_rent_monthly']) -421 data.loc[prediction_slc, 'k_house'] = rural_predictor.predict( -422 data.loc[prediction_slc, 'imputed_rent_monthly'].values.reshape(-1, 1)) -423 -424 data['k_house'] = data['k_house'].clip(lower=0).fillna(0) -425 -426 return data -427 -428 -429def calculate_poverty_attributes(data: pd.DataFrame) -> pd.DataFrame: -430 # Data has four poverty levels: -431 # (1) $1.90/day = 1345 (ipline190 in dataset) -432 # (2) $4.00/day = 2890, -433 # (3) indigence line based on food is 2123 (indline in dataset), -434 # (4) relative poverty line for food and non-food items is 6443 (povline in dataset) -435 # Saint Lucia's poverty line is 1.90 * 365 = $689.7 US Dollars per year, -436 # discounting using the PPP exchange rate of 1.952 -437 # the international poverty line for Saint Lucia is 1.90 * 1.952 * 365 = EC $1, 354 (0.7% in doc have 0.66%) -438 # US $4 a day PPP is 4 * 1.952 * 365 = EC $2,890 (4.4% in doc have 4%) -439 # poverty highest in Dennery and Vieux-Fort -440 -441 # Domestic lines -442 # !: Do not hardcode these values -443 # !: Check with Bramka -444 data['pov_line'] = 6443 -445 data['vul_line'] = 8053.75 -446 data['is_poor'] = data['aeexp'] <= data['pov_line'] -447 -448 # Load PMT data -449 # ? What is PMT? -450 # TODO: Merge PMT with data -451 # !: I don't have this dataset -452 # pmt = pd.read_stata(inputs + 'SLNET_16April.dta') -453 -454 # Consumption quintiles and deciles -455 data = data.rename(columns={'quintile.y': 'quintile', -456 'decile.y': 'decile'}) -457 -458 # print('income = {} mil. EC$'.format(round(1E-6*dfout[['aewgt','aeinc']].prod(axis=1).sum(),1))) -459 # print(' = {} EC$/cap'.format(round(dfout[['aewgt','aeinc']].prod(axis=1).sum()/dfout['pwgt'].sum(),1))) -460 -461 # Individual income -462 for _i in ['primary_income_ae', 'cct_ae', 'uct_ae', 'remits_ae', 'other_sources_ae']: -463 data[_i] = data.groupby('hhid')[_i.replace('_ae', '')].transform( -464 'sum').multiply(1/data['hhsize_ae']) -465 -466 # Household consumption -467 data['imputed_rent_monthly'] = data['imputed_rent_monthly'].fillna(0) -468 data['housing_service_ae'] = data.groupby( -469 'hhid')['imputed_rent_monthly'].transform('mean').multiply(12./data['hhsize_ae']) -470 data['aeexp_house'] = data['hhexp_house'] / data['hhsize_ae'] -471 data['aeexp_food'] = data['hhexp_food'] / data['hhsize_ae'] -472 data['aeexp_other'] = data['aeexp'] - \ -473 data[['aeexp_house', 'aeexp_food']].sum(axis=1) -474 -475 # sum to households -476 data['aesoc'] = data['cct_ae'].copy() -477 data['aeinc'] = data[['primary_income_ae', 'cct_ae', 'uct_ae', -478 'remits_ae', 'other_sources_ae', 'housing_service_ae']].sum(axis=1) -479 -480 data['k_house_ae'] = data['k_house']/data['hhsize_ae'] -481 return data -482 -483 -484def assign_housing_vulnerability(data: pd.DataFrame) -> pd.DataFrame: -485 # !: This is quite random! -486 # TODO: Do not hard code parameters here. Move them to a config file. -487 data['walls'].fillna('others', inplace=True) -488 data['v_walls'] = 0.1 -489 data.loc[data['walls'].isin( -490 ['brick/blocks', 'concrete/concrete blocks']), 'v_walls'] = 0.35 -491 data.loc[data['walls'].isin(['wood & concrete']), 'v_walls'] = 0.5 -492 data.loc[data['walls'].isin(['wood/timber']), 'v_walls'] = 0.6 -493 data.loc[data['walls'].isin(['plywood']), 'v_walls'] = 0.7 -494 data.loc[data['walls'].isin( -495 ['makeshift', 'others', 'other/dont know']), 'v_walls'] = 0.8 -496 data['roof'].fillna('others', inplace=True) -497 data['v_roof'] = 0.75 -498 data.loc[data['roof'].isin( -499 ['sheet metal (galvanize, galvalume)']), 'v_roof'] = 0.5 -500 data['v_init'] = 0.5 * data['v_roof'] + 0.5 * data['v_walls'] -501 return data -502 -503 -504def subset_columns(data: pd.DataFrame) -> pd.DataFrame: -505 '''Subset columns of interest.''' -506 columns_of_interest = ['district', -507 'is_rural', -508 'hhwgt', -509 'hhsize_ae', -510 'popwgt', -511 'aeinc', -512 'aesoc', -513 'k_house_ae', -514 'own_rent', -515 'aeexp', -516 'aeexp_house', -517 'aeexp_food', -518 'aeexp_other', -519 'is_poor', -520 'v_init', -521 'v_walls', -522 'v_roof', -523 'walls', -524 'roof', -525 'quintile', -526 'decile', -527 'primary_income_ae', -528 'cct_ae', -529 'uct_ae', 'remits_ae', -530 'other_sources_ae', -531 'housing_service_ae', -532 'pov_line', -533 'vul_line'] -534 result = data.loc[~data.index.duplicated( -535 keep='first'), columns_of_interest] -536 result['aewgt'] = data['aewgt'].groupby(level='hhid').sum() -537 -538 # Keep characteristics of head of household -539 household_head_columns = ['sex', -540 'age', -541 'race', -542 'religion', -543 'marital_status', -544 'cellphone', -545 'health_insurance', -546 'home_insured'] # ,'bank_account'] -547 result[household_head_columns] = data.loc[data['role'] -548 == 'head', household_head_columns] -549 return result -550 -551 -552def check_columns(data: pd.DataFrame) -> pd.DataFrame: -553 -554 # These are the columns of the India case -555 used_columns = [ -556 # 'hhid', -557 'aeexp', -558 'is_poor', -559 'aeinc', -560 'aesoc', -561 'k_house_ae', -562 'v_init', -563 # 'delta_tax_safety', -564 'own_rent', -565 'aeexp_house', -566 ] -567 -568 extra_columns = [ -569 'popwgt', # used, but seems to be not essential, just for writing -570 ] -571 -572 not_used_columns = [ -573 'hhsize', -574 'hhweight', -575 'state', -576 'hhexp', -577 'inc_safetynet_frac', -578 'houses_owned', -579 'percentile', -580 'decile', -581 'quintile' -582 ] -583 -584 # Check whether the new data has all columns that we need -585 missing_columns = [] -586 -587 for column in used_columns: -588 if column not in data.columns: -589 missing_columns.append(column) -590 -591 # Check what columns we have besides the ones we need from used_columns -592 extra_columns = [ -593 column for column in data.columns if column not in used_columns] -594 print(f'We have the following extra columns: {extra_columns}') -595 -596 if len(missing_columns) > 0: -597 raise ValueError(f'Missing columns: {missing_columns}') -598 -599 return data -600 -601 -602def add_missing_columns(data: pd.DataFrame, missing_columns: list) -> pd.DataFrame: -603 '''Manually add missing columns to the data.''' -604 for column in missing_columns: -605 data[column] = 0 -606 return data -607 -608 -609def merge_districts(data: pd.DataFrame) -> pd.DataFrame: -610 # !: We merged two districts into one -611 data['district_original'] = data['district'] -612 data.replace({'district': {'Castries Sub-Urban': 'Castries', -613 'Castries City': 'Castries'}}, inplace=True) -614 return data -615 -616 -617# Some regression-alike functions -618# * I did not test them -619np.random.seed(123) -620 -621 -622def exponential_regression(data: pd.DataFrame, X_column: str, y_column: str, weights: np.array = None, return_model: bool = False) -> tuple[np.array, float]: -623 X = data[X_column].values.reshape(-1, 1) -624 y = data[y_column].values.reshape(-1, 1) -625 transformer = FunctionTransformer(np.log, validate=True) -626 y_transformed = transformer.fit_transform(y) -627 -628 lr = LinearRegression() -629 lr.fit(X, y_transformed, sample_weight=weights) -630 y_pred = lr.predict(X) -631 coef = lr.coef_ -632 r2 = lr.score(X, y_transformed, sample_weight=weights) -633 if return_model: -634 return lr -635 else: -636 return y_pred, coef, r2 -637 -638 -639def polynomial_regression(data: pd.DataFrame, -640 X_column: str, -641 y_column: str, -642 power: int, -643 weights: np.array = None, -644 X_new: np.array = None, -645 X_start: int = 0, -646 X_end: int = 40, -647 X_num: int = 100): -648 # !: Weights are not used in this function -649 X = data[X_column].squeeze().T -650 y = data[y_column].squeeze().T -651 coef = poly.polyfit(X, y, power) -652 -653 if X_new is None: -654 X_new = np.linspace(X_start, X_end, num=X_num) -655 -656 f = poly.polyval(X_new, coef) -657 -658 return X_new, f -659 -660 -661def linear_regression(data: pd.DataFrame, X_column: str, y_column: str, weights: np.array = None, return_model: bool = False) -> tuple[np.array, float, float]: -662 '''Do a linear regression on the data and return the predicted values, the coefficient and the r2 score.''' -663 X = data[X_column].values.reshape(-1, 1) -664 y = data[y_column].values.reshape(-1, 1) -665 lr = LinearRegression() -666 lr.fit(X, y, sample_weight=weights) -667 y_pred = lr.predict(X) -668 coef = lr.coef_ -669 r2 = lr.score(X, y, sample_weight=weights) -670 if return_model: -671 return lr -672 else: -673 return y_pred, coef, r2 -674 -675# ---------------------------------------------------------------------------- # -676# Run data preparation pipelines # -677# ---------------------------------------------------------------------------- # -678 -679 -680# prepare_household_survey(country='Saint Lucia') -681# prepare_asset_damage(country='Saint Lucia', -682# scale='district', return_period=100) -
14def prepare_asset_damage(country: str, scale: str, return_period: int = 100) -> None: -15 '''Prepare district-level asset damage data and save it into a XLSX file.''' -16 if country == 'Saint Lucia': -17 if scale == 'district': -18 # Load raw data -19 df = pd.read_excel( -20 '../../data/raw/asset_damage/Saint Lucia/St Lucia 2015 exposure summary.xlsx', sheet_name='total by parish', skiprows=1) -21 # Remove redundant columns -22 df.drop(df.columns[0], axis=1, inplace=True) -23 # Even though the data is by `parish``, let's call the corresponding column `district`` -24 df.rename(columns={'Unnamed: 1': 'district'}, inplace=True) -25 # !: Check whether rp is = 100 given the data -26 df['rp'] = 100 -27 df.rename( -28 columns={'Combined Total': 'exposed_value'}, inplace=True) -29 -30 # !: Replace with the real data -31 # Let's assume that PML is equal to AAL % by district * by the PML for the whole country -32 # These values are from PML Results 19022016 SaintLucia FinalSummary2.xlsx -33 total_pml = {10: 351733.75, # 3,517,337.50 -34 50: 23523224.51, # 2,352,322,451.00 -35 100: 59802419.04, # 5,980,241,904.00 -36 250: 147799213.30, # 14,779,921,330.00 -37 500: 248310895.20, # 24,831,089,520.00 -38 1000: 377593847.00} # 37,759,384,700.00 -39 aal = pd.read_excel( -40 '../../data/processed/asset_damage/Saint Lucia/AAL Results 19022016 StLucia FinalSummary2 adjusted.xlsx', sheet_name='AAL St. Lucia Province') -41 aal.set_index('Name', inplace=True) -42 aal = aal[['AAL as % of Total AAL']] -43 aal.columns = ['pml'] -44 aal = aal[aal.index.notnull()] -45 pml = aal.multiply(total_pml[return_period]) -46 df = pd.merge(df, pml, left_on='district', right_index=True) -47 df.to_excel( -48 f'../../data/processed/asset_damage/{country}/{country}.xlsx', index=False) -49 else: -50 raise ValueError( -51 'Only `district` scale is supported for Saint Lucia.') -52 else: -53 raise ValueError('Only `Saint Lucia` is supported.') -
Prepare district-level asset damage data and save it into a XLSX file.
-118def prepare_household_survey(country: str) -> None: -119 '''Prepare data for the simulation model. -120 -121 Parameters -122 ---------- -123 country : str -124 -125 Raises -126 ------ -127 ValueError -128 If the country is not supported. -129 -130 ''' -131 # Data preprocessing description: -132 # 0. Load raw data -133 # 1. Change `parentid1` to `hhid` -134 # 2. Add `is_rural` column. 0 if `urban` is URBAN, if `urban` is RURAL then 1. -135 # 3. Rename `tvalassets` to `kreported`. -136 # 4. Rename a set of columns. -137 # 5. Calculate some household attributes. Need to figure out what they mean. -138 # 6. Add `financial_inst` column which has info on bank or credit union. -139 # 7. Decode income attributes. -140 # 8. Calculate some income attributes. Need to figure out what they mean. -141 # 9. Decode housing attributes. -142 # 10. Add new housing attributes. Need to figure out what they mean. -143 # 11. Add new insurance attributes. Need to figure out what they mean. -144 # 12. Calculate some housing attributes. Need to figure out what they mean. -145 # 13. Calculate povery attributes. Need to figure out what they mean. -146 # 14. Assign vulnerability by type of house. -147 # 15. Subset columns of interest. -148 # 16. Check which columns do we have and which do we miss. -149 # 17. Add missing columns. -150 # 18. Merge districts. -151 # 19. Save data. -152 -153 if country != 'Saint Lucia': -154 raise ValueError('Currently only Saint Lucia is supported.') -155 -156 print_statistics = True -157 data = load_data(print_statistics=print_statistics) -158 -159 # * Note that the sequence of the functions is important -160 result = (start_pipeline(data) -161 .pipe(add_is_rural_column, print_statistics=print_statistics) -162 .pipe(rename_assets_column) -163 .pipe(rename_other_columns) -164 .pipe(calculate_household_attributes) -165 .pipe(get_bank_or_credit_union) -166 .pipe(decode_demographic_attributes) -167 .pipe(decode_income_attributes) -168 .pipe(calculate_income_attributes) -169 .pipe(decode_housing_attributes) -170 .pipe(add_housing_attributes) -171 .pipe(add_insurance_attributes) -172 .pipe(calculate_housing_attributes) -173 .pipe(calculate_poverty_attributes) -174 .pipe(assign_housing_vulnerability) -175 .pipe(subset_columns) -176 .pipe(check_columns) -177 .pipe(add_missing_columns, missing_columns=['delta_tax_safety']) -178 .pipe(merge_districts) -179 ) -180 -181 result.to_csv( -182 f'../../data/processed/household_survey/{country}/{country}.csv ') -
Prepare data for the simulation model.
- -country : str
- -ValueError - If the country is not supported.
-185def load_data(print_statistics: bool = True) -> pd.DataFrame: -186 """Load the raw data.""" -187 # Read the raw data -188 # * This dataset is the combined version of the household and persons files on parentid1 -189 data = pd.read_csv( -190 '../../data/raw/household_survey/Saint Lucia/SLCHBS2016PersonV12_Housing.csv', low_memory=False) -191 data.rename(columns={'parentid1': 'hhid'}, inplace=True) -192 -193 # Set the index to the household id -194 data.set_index('hhid', inplace=True) -195 -196 if print_statistics: -197 print('Number of rows: ', data.shape[0]) -198 print('Number of columns: ', data.shape[1]) -199 print('Number of duplicates based on index: ', -200 data.index.duplicated().sum()) -201 -202 return data -
Load the raw data.
-205def start_pipeline(data: pd.DataFrame): -206 """Start the data processing pipeline.""" -207 return data.copy() -
Start the data processing pipeline.
-210def add_is_rural_column(data: pd.DataFrame, print_statistics: bool = True) -> pd.DataFrame: -211 """Create a new column that indicates whether the household is rural or not.""" -212 data['is_rural'] = 0 -213 data.loc[data['urban'] == 'RURAL', 'is_rural'] = 1 -214 if print_statistics: -215 print('Number of rural households: ', data['is_rural'].sum()) -216 print('Number of urban households: ', -217 data.shape[0] - data['is_rural'].sum()) -218 return data -
Create a new column that indicates whether the household is rural or not.
-221def rename_assets_column(data: pd.DataFrame) -> pd.DataFrame: -222 """Rename the assets column to be more descriptive.""" -223 data.rename(columns={'tvalassets': 'kreported'}, inplace=True) -224 return data -
Rename the assets column to be more descriptive.
-227def rename_other_columns(data: pd.DataFrame) -> pd.DataFrame: -228 '''Rename a set of columns. See function for details.''' -229 data = data.rename(columns={'DISTRICT_NAME': 'district', -230 'persons': 'hhsize', -231 'totexp.x': 'hhexp', -232 'pcexpae.x': 'aeexp', -233 'hincome': 'hhinc', -234 'WT.x': 'pwgt', -235 'food.x': 'hhexp_food'}) -236 return data -
Rename a set of columns. See function for details.
-261def calculate_household_attributes(data: pd.DataFrame) -> pd.DataFrame: -262 lower = 1 -263 fill_na = 1 -264 data['popwgt'] = data.groupby('hhid')['pwgt'].transform('sum') -265 data['hhwgt'] = data['popwgt'] / data['hhsize'] -266 data['hhsize_ae'] = (data['hhexp'] / data['aeexp'] -267 ).fillna(fill_na).clip(lower=lower) -268 data['aewgt'] = data['pwgt']*(data['hhsize_ae'] / data['hhsize']) -269 return data -
272def get_bank_or_credit_union(data: pd.DataFrame) -> pd.DataFrame: -273 data['financial_inst'] = 0 -274 data.loc[data['p1_11__3'] == 'yes - bank', 'financial_inst'] = 1 -275 data.loc[data['p1_11__2'] == 'yes - bank', 'financial_inst'] = 1 -276 data.loc[data['p1_11__2'] == 'yes - credit union', 'financial_inst'] = 1 -277 data.loc[data['p1_11__1'] == 'yes - bank', 'financial_inst'] = 1 -278 data.loc[data['p1_11__1'] == 'yes - credit union', 'financial_inst'] = 1 -279 return data -
282def decode_demographic_attributes(data: pd.DataFrame) -> pd.DataFrame: -283 '''Decode the demographic attributes.''' -284 data = data.rename(columns={'p1_1': 'role', -285 'p1_2': 'sex', -286 'p1_3': 'age', -287 'p1_4': 'race', -288 'p1_5': 'religion', -289 'p1_6': 'marital_status', -290 'p1_7': 'cellphone'}) -291 return data -
Decode the demographic attributes.
-294def decode_income_attributes(data: pd.DataFrame) -> pd.DataFrame: -295 '''Decode the income-related attributes.''' -296 data = data.rename(columns={ -297 # 'p1_11':'bank_account', -298 'p4_1': 'months_worked', -299 'inc2231002': 'other_entrepreneurial', -300 'inc2331001': 'remits_intl', -301 'inc2341001': 'rental_income', -302 'inc2351001': 'dividends', # other -303 'inc2361001': 'interest', # other -304 'inc2361002': 'other_investment_income', # other -305 'inc2371001': 'pension_public', # UCT -306 'inc2371002': 'pension_private_LCA', # pension private -307 'inc2371003': 'pension_private_int', # pension private -308 'inc2371004': 'social_security', # UCT -309 # 'inc2381001':'annuity', # other -310 'inc2381002': 'public_assistance', # CCT -311 'inc2381003': 'child_support', # other -312 'inc2391001': 'scholarships', # other -313 'inc2391002': 'financial_aid', # other -314 'inc2391003': 'alimony', # other -315 'inc2391099': 'mystery' -316 }) -317 return data -
Decode the income-related attributes.
-320def calculate_income_attributes(data: pd.DataFrame) -> pd.DataFrame: -321 data['remits_dom'] = 0 -322 -323 # Primary job income -324 data['primary_income'] = data[['months_worked', 'pincome']].prod(axis=1) -325 -326 # Secondary income -327 data['cct'] = data['public_assistance'].copy() -328 data['uct'] = data[['pension_public', 'social_security']].sum(axis=1) -329 data['remits'] = data[['remits_intl', 'remits_dom']].sum(axis=1) -330 data['other_sources'] = data[['dividends', 'interest', 'child_support', 'alimony', 'financial_aid', -331 'scholarships', 'pension_private_LCA', 'pension_private_int', 'other_investment_income', 'mystery']].sum(axis=1) -332 data['secondary_income'] = data[['other_entrepreneurial', 'cct', -333 'uct', 'remits', 'rental_income', 'other_sources']].sum(axis=1) -334 -335 # Total income -336 data['total_income'] = data[[ -337 'primary_income', 'secondary_income']].sum(axis=1) -338 -339 return data -
342def decode_housing_attributes(data: pd.DataFrame) -> pd.DataFrame: -343 '''Decode the housing-related attributes.''' -344 data = data.rename(columns={'s2': 'own_rent', -345 # owner-occupied -346 'c1900105': 'mortgage_monthly', -347 'c1900104': 'domicile_value', -348 'c1900101': 'new_home_purchase_price', -349 'c1900103': 'new_home_mortgage_monthly', -350 'c1800501': 'rental_income_furnished', -351 'c1800502': 'rental_income_unfurnished', -352 'c1800503': 'rental_income_business', -353 'c0421101': 'imputed_rent_monthly', -354 'c1252101': 'insurance_premium', -355 # rental -356 'c0411100': 'actual_rent_monthly', -357 # condition & construction -358 's9q1': 'had_shock', -359 'h1_2': 'walls', -360 'h1_3': 'roof', -361 'h1_13': 'yr_house_built'}) -362 return data -
Decode the housing-related attributes.
-365def add_housing_attributes(data: pd.DataFrame) -> pd.DataFrame: -366 '''Introduce new housing attributes.''' -367 # ! An assumption -368 data['own_rent'] = data['own_rent'].replace({'own or rent free': 'own'}) -369 data['home_insured'] = data['insurance_premium'] > 0 -370 return data -
Introduce new housing attributes.
-373def add_insurance_attributes(data: pd.DataFrame) -> pd.DataFrame: -374 # ? What does it mean? -375 # National insurance corporation (unemployment) -376 data['NIC_enrolled'] = data['p4_18'].isin(['employer', 'self-employed']) -377 data['NIC_recipient'] = data['p4_17'].isin(['yes, from the nic']) -378 -379 # Health insurance -380 data = data.rename(columns={'p2_5': 'health_insurance'}) -381 return data -
384def calculate_housing_attributes(data: pd.DataFrame) -> pd.DataFrame: -385 # Predict domicile value for hh that rent -386 data['k_house'] = data['domicile_value'].copy().fillna(0) -387 # total rent per capita per year -388 data['hhexp_house'] = 12 * data['imputed_rent_monthly'].copy() -389 data['hhexp_house'].update(12 * data['actual_rent_monthly']) -390 data['hhexp_house'] = data['hhexp_house'].clip(lower=0).fillna(0) -391 -392 # Urban population -393 training_slc = (data['domicile_value'] > 10 * data['imputed_rent_monthly'] -394 ) & (data['domicile_value'] < 1E6) & (data['is_rural'] == 0) -395 urban_predictor = linear_regression(data.loc[training_slc].dropna( -396 subset=['domicile_value', 'imputed_rent_monthly']), 'imputed_rent_monthly', 'domicile_value', return_model=True) -397 -398 prediction_slc = (data['own_rent'] == 'rent') & ( -399 data['is_rural'] == 0) & (data['actual_rent_monthly'] is not None) -400 data.loc[prediction_slc, 'k_house'] = urban_predictor.predict( -401 data.loc[prediction_slc, 'actual_rent_monthly'].values.reshape(-1, 1)) -402 -403 # Rural population -404 training_slc = (data['domicile_value'] > 10 * data['imputed_rent_monthly'] -405 ) & (data['domicile_value'] < 1E6) & (data['is_rural'] == 1) -406 rural_predictor = linear_regression(data.loc[training_slc].dropna( -407 subset=['domicile_value', 'imputed_rent_monthly']), 'imputed_rent_monthly', 'domicile_value', return_model=True) -408 -409 prediction_slc = (data['own_rent'] == 'rent') & ( -410 data['is_rural'] == 1) & (data['actual_rent_monthly'] is not None) -411 data.loc[prediction_slc, 'k_house'] = rural_predictor.predict( -412 data.loc[prediction_slc, 'actual_rent_monthly'].values.reshape(-1, 1)) -413 -414 # Correct for the households that reported unreasonably low domicile value -415 prediction_slc = (data['own_rent'] == 'own') & (data['is_rural'] == 0) & ( -416 data['k_house'] <= 10*data['imputed_rent_monthly']) -417 data.loc[prediction_slc, 'k_house'] = urban_predictor.predict( -418 data.loc[prediction_slc, 'imputed_rent_monthly'].values.reshape(-1, 1)) -419 -420 prediction_slc = (data['own_rent'] == 'own') & (data['is_rural'] == 1) & ( -421 data['k_house'] <= 10*data['imputed_rent_monthly']) -422 data.loc[prediction_slc, 'k_house'] = rural_predictor.predict( -423 data.loc[prediction_slc, 'imputed_rent_monthly'].values.reshape(-1, 1)) -424 -425 data['k_house'] = data['k_house'].clip(lower=0).fillna(0) -426 -427 return data -
430def calculate_poverty_attributes(data: pd.DataFrame) -> pd.DataFrame: -431 # Data has four poverty levels: -432 # (1) $1.90/day = 1345 (ipline190 in dataset) -433 # (2) $4.00/day = 2890, -434 # (3) indigence line based on food is 2123 (indline in dataset), -435 # (4) relative poverty line for food and non-food items is 6443 (povline in dataset) -436 # Saint Lucia's poverty line is 1.90 * 365 = $689.7 US Dollars per year, -437 # discounting using the PPP exchange rate of 1.952 -438 # the international poverty line for Saint Lucia is 1.90 * 1.952 * 365 = EC $1, 354 (0.7% in doc have 0.66%) -439 # US $4 a day PPP is 4 * 1.952 * 365 = EC $2,890 (4.4% in doc have 4%) -440 # poverty highest in Dennery and Vieux-Fort -441 -442 # Domestic lines -443 # !: Do not hardcode these values -444 # !: Check with Bramka -445 data['pov_line'] = 6443 -446 data['vul_line'] = 8053.75 -447 data['is_poor'] = data['aeexp'] <= data['pov_line'] -448 -449 # Load PMT data -450 # ? What is PMT? -451 # TODO: Merge PMT with data -452 # !: I don't have this dataset -453 # pmt = pd.read_stata(inputs + 'SLNET_16April.dta') -454 -455 # Consumption quintiles and deciles -456 data = data.rename(columns={'quintile.y': 'quintile', -457 'decile.y': 'decile'}) -458 -459 # print('income = {} mil. EC$'.format(round(1E-6*dfout[['aewgt','aeinc']].prod(axis=1).sum(),1))) -460 # print(' = {} EC$/cap'.format(round(dfout[['aewgt','aeinc']].prod(axis=1).sum()/dfout['pwgt'].sum(),1))) -461 -462 # Individual income -463 for _i in ['primary_income_ae', 'cct_ae', 'uct_ae', 'remits_ae', 'other_sources_ae']: -464 data[_i] = data.groupby('hhid')[_i.replace('_ae', '')].transform( -465 'sum').multiply(1/data['hhsize_ae']) -466 -467 # Household consumption -468 data['imputed_rent_monthly'] = data['imputed_rent_monthly'].fillna(0) -469 data['housing_service_ae'] = data.groupby( -470 'hhid')['imputed_rent_monthly'].transform('mean').multiply(12./data['hhsize_ae']) -471 data['aeexp_house'] = data['hhexp_house'] / data['hhsize_ae'] -472 data['aeexp_food'] = data['hhexp_food'] / data['hhsize_ae'] -473 data['aeexp_other'] = data['aeexp'] - \ -474 data[['aeexp_house', 'aeexp_food']].sum(axis=1) -475 -476 # sum to households -477 data['aesoc'] = data['cct_ae'].copy() -478 data['aeinc'] = data[['primary_income_ae', 'cct_ae', 'uct_ae', -479 'remits_ae', 'other_sources_ae', 'housing_service_ae']].sum(axis=1) -480 -481 data['k_house_ae'] = data['k_house']/data['hhsize_ae'] -482 return data -
485def assign_housing_vulnerability(data: pd.DataFrame) -> pd.DataFrame: -486 # !: This is quite random! -487 # TODO: Do not hard code parameters here. Move them to a config file. -488 data['walls'].fillna('others', inplace=True) -489 data['v_walls'] = 0.1 -490 data.loc[data['walls'].isin( -491 ['brick/blocks', 'concrete/concrete blocks']), 'v_walls'] = 0.35 -492 data.loc[data['walls'].isin(['wood & concrete']), 'v_walls'] = 0.5 -493 data.loc[data['walls'].isin(['wood/timber']), 'v_walls'] = 0.6 -494 data.loc[data['walls'].isin(['plywood']), 'v_walls'] = 0.7 -495 data.loc[data['walls'].isin( -496 ['makeshift', 'others', 'other/dont know']), 'v_walls'] = 0.8 -497 data['roof'].fillna('others', inplace=True) -498 data['v_roof'] = 0.75 -499 data.loc[data['roof'].isin( -500 ['sheet metal (galvanize, galvalume)']), 'v_roof'] = 0.5 -501 data['v_init'] = 0.5 * data['v_roof'] + 0.5 * data['v_walls'] -502 return data -
505def subset_columns(data: pd.DataFrame) -> pd.DataFrame: -506 '''Subset columns of interest.''' -507 columns_of_interest = ['district', -508 'is_rural', -509 'hhwgt', -510 'hhsize_ae', -511 'popwgt', -512 'aeinc', -513 'aesoc', -514 'k_house_ae', -515 'own_rent', -516 'aeexp', -517 'aeexp_house', -518 'aeexp_food', -519 'aeexp_other', -520 'is_poor', -521 'v_init', -522 'v_walls', -523 'v_roof', -524 'walls', -525 'roof', -526 'quintile', -527 'decile', -528 'primary_income_ae', -529 'cct_ae', -530 'uct_ae', 'remits_ae', -531 'other_sources_ae', -532 'housing_service_ae', -533 'pov_line', -534 'vul_line'] -535 result = data.loc[~data.index.duplicated( -536 keep='first'), columns_of_interest] -537 result['aewgt'] = data['aewgt'].groupby(level='hhid').sum() -538 -539 # Keep characteristics of head of household -540 household_head_columns = ['sex', -541 'age', -542 'race', -543 'religion', -544 'marital_status', -545 'cellphone', -546 'health_insurance', -547 'home_insured'] # ,'bank_account'] -548 result[household_head_columns] = data.loc[data['role'] -549 == 'head', household_head_columns] -550 return result -
Subset columns of interest.
-553def check_columns(data: pd.DataFrame) -> pd.DataFrame: -554 -555 # These are the columns of the India case -556 used_columns = [ -557 # 'hhid', -558 'aeexp', -559 'is_poor', -560 'aeinc', -561 'aesoc', -562 'k_house_ae', -563 'v_init', -564 # 'delta_tax_safety', -565 'own_rent', -566 'aeexp_house', -567 ] -568 -569 extra_columns = [ -570 'popwgt', # used, but seems to be not essential, just for writing -571 ] -572 -573 not_used_columns = [ -574 'hhsize', -575 'hhweight', -576 'state', -577 'hhexp', -578 'inc_safetynet_frac', -579 'houses_owned', -580 'percentile', -581 'decile', -582 'quintile' -583 ] -584 -585 # Check whether the new data has all columns that we need -586 missing_columns = [] -587 -588 for column in used_columns: -589 if column not in data.columns: -590 missing_columns.append(column) -591 -592 # Check what columns we have besides the ones we need from used_columns -593 extra_columns = [ -594 column for column in data.columns if column not in used_columns] -595 print(f'We have the following extra columns: {extra_columns}') -596 -597 if len(missing_columns) > 0: -598 raise ValueError(f'Missing columns: {missing_columns}') -599 -600 return data -
603def add_missing_columns(data: pd.DataFrame, missing_columns: list) -> pd.DataFrame: -604 '''Manually add missing columns to the data.''' -605 for column in missing_columns: -606 data[column] = 0 -607 return data -
Manually add missing columns to the data.
-623def exponential_regression(data: pd.DataFrame, X_column: str, y_column: str, weights: np.array = None, return_model: bool = False) -> tuple[np.array, float]: -624 X = data[X_column].values.reshape(-1, 1) -625 y = data[y_column].values.reshape(-1, 1) -626 transformer = FunctionTransformer(np.log, validate=True) -627 y_transformed = transformer.fit_transform(y) -628 -629 lr = LinearRegression() -630 lr.fit(X, y_transformed, sample_weight=weights) -631 y_pred = lr.predict(X) -632 coef = lr.coef_ -633 r2 = lr.score(X, y_transformed, sample_weight=weights) -634 if return_model: -635 return lr -636 else: -637 return y_pred, coef, r2 -
640def polynomial_regression(data: pd.DataFrame, -641 X_column: str, -642 y_column: str, -643 power: int, -644 weights: np.array = None, -645 X_new: np.array = None, -646 X_start: int = 0, -647 X_end: int = 40, -648 X_num: int = 100): -649 # !: Weights are not used in this function -650 X = data[X_column].squeeze().T -651 y = data[y_column].squeeze().T -652 coef = poly.polyfit(X, y, power) -653 -654 if X_new is None: -655 X_new = np.linspace(X_start, X_end, num=X_num) -656 -657 f = poly.polyval(X_new, coef) -658 -659 return X_new, f -
662def linear_regression(data: pd.DataFrame, X_column: str, y_column: str, weights: np.array = None, return_model: bool = False) -> tuple[np.array, float, float]: -663 '''Do a linear regression on the data and return the predicted values, the coefficient and the r2 score.''' -664 X = data[X_column].values.reshape(-1, 1) -665 y = data[y_column].values.reshape(-1, 1) -666 lr = LinearRegression() -667 lr.fit(X, y, sample_weight=weights) -668 y_pred = lr.predict(X) -669 coef = lr.coef_ -670 r2 = lr.score(X, y, sample_weight=weights) -671 if return_model: -672 return lr -673 else: -674 return y_pred, coef, r2 -
Do a linear regression on the data and return the predicted values, the coefficient and the r2 score.
-1import pandas as pd - 2import os - 3import numpy as np - 4import json - 5 - 6 - 7def read_asset_damage(country) -> None: - 8 '''Read asset damage for all districts from a XLSX file and load it into the memory.''' - 9 if country == 'Saint Lucia': -10 all_damage = pd.read_excel( -11 f"../data/processed/asset_damage/{country}/{country}.xlsx", index_col=None, header=0) -12 else: -13 raise ValueError('Only `Saint Lucia` is supported.') -14 -15 return all_damage -16 -17 -18def get_asset_damage(all_damage: pd.DataFrame, scale: str, district: str, return_period: int, print_statistics: bool) -> tuple: -19 '''Get asset damage for a specific district. -20 -21 Args: -22 all_damage (pd.DataFrame): Asset damage data for all districts. -23 scale (str): Scale of the analysis. Only `district` is supported. -24 district (str): District name. -25 return_period (int): Return period. -26 print_statistics (bool): Print the statistics. -27 -28 Returns: -29 tuple: Event damage, total asset stock, expected loss fraction. -30 -31 Raises: -32 ValueError: If the scale is not `district`. -33 ValueError: If the expected loss fraction is greater than 1. -34 ''' -35 if scale == 'district': -36 event_damage = all_damage.loc[(all_damage[scale] == district) & ( -37 all_damage['rp'] == return_period), 'pml'].values[0] # PML -38 total_asset_stock = all_damage.loc[(all_damage[scale] == district) & ( -39 all_damage['rp'] == return_period), 'exposed_value'].values[0] # Exposed value -40 -41 else: -42 raise ValueError( -43 'Only `district` scale is supported.') -44 -45 event_damage = event_damage -46 total_asset_stock = total_asset_stock -47 expected_loss_fraction = event_damage / total_asset_stock -48 -49 if expected_loss_fraction > 1: -50 raise ValueError( -51 'Expected loss fraction is greater than 1. Check the data.') -52 -53 if print_statistics: -54 print('Event damage = ' + str('{:,}'.format(round(event_damage)))) -55 print('Total asset stock = ' + -56 str('{:,}'.format(round(total_asset_stock)))) -57 print('Expected loss fraction = ' + -58 str(np.round(expected_loss_fraction, 3))) -59 -60 return event_damage, total_asset_stock, expected_loss_fraction -61 -62 -63def read_household_survey(country: str) -> pd.DataFrame: -64 '''Reads household survey from a CSV file. -65 -66 Args: -67 country (str): Country name. -68 -69 Returns: -70 pd.DataFrame: Household survey data. -71 -72 Raises: -73 ValueError: If the country is not `Saint Lucia`. -74 ''' -75 if country == 'Saint Lucia': -76 household_survey = pd.read_csv( -77 f"../data/processed/household_survey/{country}/{country}.csv") -78 else: -79 raise ValueError('Only `Saint Lucia` is supported.') -80 -81 return household_survey -
8def read_asset_damage(country) -> None: - 9 '''Read asset damage for all districts from a XLSX file and load it into the memory.''' -10 if country == 'Saint Lucia': -11 all_damage = pd.read_excel( -12 f"../data/processed/asset_damage/{country}/{country}.xlsx", index_col=None, header=0) -13 else: -14 raise ValueError('Only `Saint Lucia` is supported.') -15 -16 return all_damage -
Read asset damage for all districts from a XLSX file and load it into the memory.
-19def get_asset_damage(all_damage: pd.DataFrame, scale: str, district: str, return_period: int, print_statistics: bool) -> tuple: -20 '''Get asset damage for a specific district. -21 -22 Args: -23 all_damage (pd.DataFrame): Asset damage data for all districts. -24 scale (str): Scale of the analysis. Only `district` is supported. -25 district (str): District name. -26 return_period (int): Return period. -27 print_statistics (bool): Print the statistics. -28 -29 Returns: -30 tuple: Event damage, total asset stock, expected loss fraction. -31 -32 Raises: -33 ValueError: If the scale is not `district`. -34 ValueError: If the expected loss fraction is greater than 1. -35 ''' -36 if scale == 'district': -37 event_damage = all_damage.loc[(all_damage[scale] == district) & ( -38 all_damage['rp'] == return_period), 'pml'].values[0] # PML -39 total_asset_stock = all_damage.loc[(all_damage[scale] == district) & ( -40 all_damage['rp'] == return_period), 'exposed_value'].values[0] # Exposed value -41 -42 else: -43 raise ValueError( -44 'Only `district` scale is supported.') -45 -46 event_damage = event_damage -47 total_asset_stock = total_asset_stock -48 expected_loss_fraction = event_damage / total_asset_stock -49 -50 if expected_loss_fraction > 1: -51 raise ValueError( -52 'Expected loss fraction is greater than 1. Check the data.') -53 -54 if print_statistics: -55 print('Event damage = ' + str('{:,}'.format(round(event_damage)))) -56 print('Total asset stock = ' + -57 str('{:,}'.format(round(total_asset_stock)))) -58 print('Expected loss fraction = ' + -59 str(np.round(expected_loss_fraction, 3))) -60 -61 return event_damage, total_asset_stock, expected_loss_fraction -
Get asset damage for a specific district.
- -Args:
- all_damage (pd.DataFrame): Asset damage data for all districts.
- scale (str): Scale of the analysis. Only district
is supported.
- district (str): District name.
- return_period (int): Return period.
- print_statistics (bool): Print the statistics.
Returns: - tuple: Event damage, total asset stock, expected loss fraction.
- -Raises:
- ValueError: If the scale is not district
.
- ValueError: If the expected loss fraction is greater than 1.
64def read_household_survey(country: str) -> pd.DataFrame: -65 '''Reads household survey from a CSV file. -66 -67 Args: -68 country (str): Country name. -69 -70 Returns: -71 pd.DataFrame: Household survey data. -72 -73 Raises: -74 ValueError: If the country is not `Saint Lucia`. -75 ''' -76 if country == 'Saint Lucia': -77 household_survey = pd.read_csv( -78 f"../data/processed/household_survey/{country}/{country}.csv") -79 else: -80 raise ValueError('Only `Saint Lucia` is supported.') -81 -82 return household_survey -
Reads household survey from a CSV file.
- -Args: - country (str): Country name.
- -Returns: - pd.DataFrame: Household survey data.
- -Raises:
- ValueError: If the country is not Saint Lucia
.
1import geopandas as gpd - 2import matplotlib - 3import matplotlib.pyplot as plt - 4import pandas as pd - 5import numpy as np - 6from sklearn.preprocessing import MinMaxScaler - 7import ptitprince as pt - 8import seaborn as sns - 9from scipy.stats import spearmanr - 10from matplotlib.ticker import MaxNLocator - 11# import contextily as ctx - 12 - 13 - 14def rainclouds(outcomes: pd.DataFrame, savefigs: bool, x_columns: list = [], x_titles: list = [], plot_years_in_poverty: bool = False, color_palette: str = 'Set2', sharex: bool = True): - 15 districts = outcomes['district'].unique().tolist() - 16 n_districts = len(districts) - 17 colors = sns.color_palette(color_palette, n_colors=len(districts)) - 18 - 19 if len(x_columns) == 0: - 20 x_columns = [ - 21 'n_affected_people', - 22 'n_new_poor_increase_pct', - 23 'n_new_poor', - 24 'annual_average_consumption_loss_pct', - 25 'r', - 26 'new_poverty_gap', - 27 # 'one_year_in_poverty', - 28 # 'two_years_in_poverty', - 29 # 'three_years_in_poverty', - 30 # 'four_years_in_poverty', - 31 # 'five_years_in_poverty', - 32 # 'six_years_in_poverty', - 33 # 'seven_years_in_poverty', - 34 # 'eight_years_in_poverty', - 35 # 'nine_years_in_poverty', - 36 # 'ten_years_in_poverty' - 37 ] - 38 - 39 if len(x_titles) == 0: - 40 x_titles = [ - 41 'Affected People', - 42 'New Poor Increase (%)', - 43 'New Poor', - 44 'Wt. Ann. Avg. Consump. Loss p.c. (%)', - 45 'Socio-Economic Resilience', - 46 'Poverty Gap', - 47 # 'One year in poverty', - 48 # 'Two years in poverty', - 49 # 'Three years in poverty', - 50 # 'Four years in poverty', - 51 # 'Five years in poverty', - 52 # 'Six years in poverty', - 53 # 'Seven years in poverty', - 54 # 'Eight years in poverty', - 55 # 'Nine years in poverty', - 56 # 'Ten years in poverty' - 57 ] - 58 - 59 is_years_in_poverty = False - 60 - 61 for x_column, x_title in zip(x_columns, x_titles): - 62 fig, ax = plt.subplots(ncols=3, nrows=3, figsize=( - 63 4 * n_districts / 3, 3 * n_districts / 3), sharex=sharex) - 64 - 65 for district in districts: - 66 df = outcomes[outcomes['district'] == district].copy() - 67 - 68 # Calculate an increase in new poor in respect to the total population - 69 # df = df.assign(one_year_in_poverty = df['years_in_poverty'].apply(lambda x: x[0])) - 70 # df = df.assign(two_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[1])) - 71 # df = df.assign(three_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[2])) - 72 # df = df.assign(four_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[3])) - 73 # df = df.assign(five_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[4])) - 74 # df = df.assign(six_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[5])) - 75 # df = df.assign(seven_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[6])) - 76 # df = df.assign(eight_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[7])) - 77 # df = df.assign(nine_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[8])) - 78 # df = df.assign(ten_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[9])) - 79 - 80 df[x_column] = df[x_column].astype(float) - 81 - 82 # Make a half violin plot - 83 pt.half_violinplot(x=x_column, - 84 y='policy', # hue='scenario', - 85 data=df, - 86 color=colors[districts.index(district)], - 87 bw=.2, - 88 cut=0., - 89 scale="area", - 90 width=.6, - 91 inner=None, - 92 ax=ax[districts.index(district) // 3, districts.index(district) % 3]) - 93 - 94 # Add stripplot - 95 sns.stripplot(x=x_column, - 96 y='policy', # hue='scenario', - 97 data=df, - 98 color=colors[districts.index(district)], - 99 edgecolor='white', -100 size=3, -101 jitter=1, -102 zorder=0, -103 orient='h', -104 ax=ax[districts.index(district) // 3, districts.index(district) % 3]) -105 -106 # Add boxplot -107 sns.boxplot(x=x_column, -108 y='policy', # hue='scenario', -109 data=df, -110 color="black", -111 width=.15, -112 zorder=10, -113 showcaps=True, -114 boxprops={'facecolor': 'none', "zorder": 10}, -115 showfliers=True, -116 whiskerprops={'linewidth': 2, "zorder": 10}, -117 saturation=1, -118 orient='h', -119 ax=ax[districts.index(district) // 3, districts.index(district) % 3]) -120 -121 if is_years_in_poverty: -122 title = district + ', E = ' + \ -123 f'{round(df[x_column].mean())}' -124 else: -125 title = district -126 ax[districts.index(district) // 3, -127 districts.index(district) % 3].set_title(title) -128 ax[districts.index(district) // 3, -129 districts.index(district) % 3].set_ylabel('') -130 ax[districts.index(district) // 3, -131 districts.index(district) % 3].set_xlabel(x_title) -132 -133 # Remove y ticks and labels -134 ax[districts.index(district) // 3, -135 districts.index(district) % 3].set_yticklabels([]) -136 ax[districts.index(district) // 3, -137 districts.index(district) % 3].set_yticks([]) -138 -139 # Do not display floats in the x-axis -140 ax[districts.index(district) // 3, districts.index(district) % -141 3].xaxis.set_major_locator(MaxNLocator(integer=True)) -142 -143 # Plot the median -144 # ax[districts.index(district) // 3, districts.index(district) % 3].axvline(df[x_column].median(), color='black', linestyle='--', linewidth=1) -145 -146 # Add text close to the boxplot's median -147 ax[districts.index(district) // 3, districts.index(district) % 3].text(df[x_column].median(), 0.2, -148 f'M={df[x_column].median():.2f}', -149 horizontalalignment='left', size='small', color='black') -150 -151 # # Add text close to the boxplot's min and max -152 # ax[districts.index(district) // 3, districts.index(district) % 3].text(df[x_column].min(), 0.3, -153 # f'min={df[x_column].min():.2f}', -154 # horizontalalignment='left', size='small', color='black') -155 # ax[districts.index(district) // 3, districts.index(district) % 3].text(df[x_column].max(), 0.4, -156 # f'max={df[x_column].max():.2f}', -157 # horizontalalignment='left', size='small', color='black') -158 -159 initial_poverty_gap = df['initial_poverty_gap'].iloc[0] -160 -161 # Add initial poverty gap as in the legend to the plot -162 if x_column == 'new_poverty_gap': -163 ax[districts.index(district) // 3, districts.index(district) % 3].text(0.025, 0.9, -164 f'Poverty gap before disaster={initial_poverty_gap:.2f}', -165 horizontalalignment='left', size='small', color='black', -166 transform=ax[districts.index(district) // 3, districts.index(district) % 3].transAxes) -167 -168 # Add a super title -169 # fig.suptitle(x_title, fontsize=16) -170 fig.tight_layout() -171 if savefigs: -172 plt.savefig( -173 f'../figures/analysis/{x_column}.png', dpi=500, bbox_inches='tight') -174 -175 -176def bivariate_choropleth(data, x_name, y_name, x_label, y_label, scale, figsize, return_table): -177 fig, ax = plt.subplots(figsize=figsize) -178 -179 # Bin the data -180 data = bin_data(data, x_name, y_name, scale, print_statistics=False) -181 -182 # Get colors -183 all_colors, available_colors = get_colors(data) -184 cmap = matplotlib.colors.ListedColormap(available_colors) -185 -186 # Step 1: Draw the map -187 # border = gpd.read_file(f'../data/processed/boundaries/{city}/city.json') -188 border = gpd.read_file( -189 '../data/raw/shapefiles/Saint Lucia/gadm36_LCA_shp/gadm36_LCA_0.shp') -190 data.plot(ax=ax, -191 edgecolor='black', -192 linewidth=.1, -193 column='Bi_Class', # variable that is going to be used to color the map -194 cmap=cmap, # newly defined bivariate cmap -195 categorical=True, # bivariate choropleth has to be colored as categorical map -196 legend=False) # we're going to draw the legend ourselves -197 # add the basemap -198 # ctx.add_basemap(ax=ax, source=ctx.providers.CartoDB.Positron) -199 border.plot(ax=ax, facecolor='none', -200 edgecolor='black', alpha=.5) # city border -201 for idx, row in data.iterrows(): -202 ax.annotate(text=row['NAME_1'], xy=row['geometry'].centroid.coords[0], -203 ha='center', fontsize=8, color='white') -204 -205 plt.tight_layout() # "tighten" two figures map and basemap -206 plt.axis('off') # we don't need axis with coordinates -207 # ax.set_title('Bivariate Choropleth Amsterdam') -208 -209 # Step 2: draw the legend -210 -211 # We're drawing a 3x3 "box" as 3 columns -212 # The xmin and xmax arguments axvspan are defined to create equally sized small boxes -213 -214 img2 = fig # refer to the main figure -215 # add new axes to place the legend there -216 ax2 = fig.add_axes([0.15, 0.25, 0.1, 0.1]) -217 # and specify its location -218 alpha = 1 # alpha argument to make it more/less transparent -219 -220 # Column 1 -221 # All colors to create a complete legend -222 # all_colors = ['#e8e8e8', '#b0d5df', '#64acbe', '#e4acac', '#ad9ea5', '#627f8c', '#c85a5a', '#985356', '#574249'] -223 -224 ax2.axvspan(xmin=0, xmax=0.33, ymin=0, ymax=0.33, -225 alpha=alpha, color=all_colors[0]) -226 ax2.axvspan(xmin=0, xmax=0.33, ymin=0.33, ymax=0.66, -227 alpha=alpha, color=all_colors[1]) -228 ax2.axvspan(xmin=0, xmax=0.33, ymin=0.66, ymax=1, -229 alpha=alpha, color=all_colors[2]) -230 -231 # Column 2 -232 ax2.axvspan(xmin=0.33, xmax=0.66, ymin=0, ymax=0.33, -233 alpha=alpha, color=all_colors[3]) -234 ax2.axvspan(xmin=0.33, xmax=0.66, ymin=0.33, ymax=0.66, -235 alpha=alpha, color=all_colors[4]) -236 ax2.axvspan(xmin=0.33, xmax=0.66, ymin=0.66, ymax=1, -237 alpha=alpha, color=all_colors[5]) -238 -239 # Column 3 -240 ax2.axvspan(xmin=0.66, xmax=1, ymin=0, ymax=0.33, -241 alpha=alpha, color=all_colors[6]) -242 ax2.axvspan(xmin=0.66, xmax=1, ymin=0.33, ymax=0.66, -243 alpha=alpha, color=all_colors[7]) -244 ax2.axvspan(xmin=0.66, xmax=1, ymin=0.66, ymax=1, -245 alpha=alpha, color=all_colors[8]) -246 -247 # Step 3: annoate the legend -248 # remove ticks from the big box -249 ax2.tick_params(axis='both', which='both', length=0) -250 ax2.axis('off') # turn off its axis -251 ax2.annotate("", xy=(0, 1), xytext=(0, 0), arrowprops=dict( -252 arrowstyle="->", lw=1, color='black')) # draw arrow for x -253 ax2.annotate("", xy=(1, 0), xytext=(0, 0), arrowprops=dict( -254 arrowstyle="->", lw=1, color='black')) # draw arrow for y -255 ax2.text(s=x_label, x=0.1, y=-0.25, fontsize=8) # annotate x axis -256 ax2.text(s=y_label, x=-0.25, y=0.1, rotation=90, -257 fontsize=8) # annotate y axis -258 # plt.savefig('bivariate_choropleth.png', dpi=300) -259 -260 if return_table: -261 return data -262 -263 -264def nine_quadrants_plot(data, x_name, y_name, scale=True): -265 _, ax = plt.subplots(figsize=(6, 5)) -266 -267 if scale: -268 scaler = MinMaxScaler() -269 # data[x_name] = scaler.fit_transform(data[x_name].values.reshape(-1, 1)) -270 # data[y_name] = scaler.fit_transform(data[y_name].values.reshape(-1, 1)) -271 # Scale data between 0 and 1 -272 data[x_name] = (data[x_name] - data[x_name].min()) / \ -273 (data[x_name].max() - data[x_name].min()) -274 data[y_name] = (data[y_name] - data[y_name].min()) / \ -275 (data[y_name].max() - data[y_name].min()) -276 -277 data.plot.scatter(x_name, y_name, s=20, ax=ax, c='black', zorder=2) -278 -279 # Iterate over each row and annotate the points -280 for idx, row in data.iterrows(): -281 ax.annotate(text=row['NAME_1'], xy=(row[x_name], row[y_name]), -282 ha='center', fontsize=10, color='black') -283 -284 # Annotate with Spearman's rho -285 # rho, p = spearmanr(data[x_name], data[y_name]) -286 # ax.text(0.05, 0.95, f'$\\rho$ = {round(rho, 2)}', transform=ax.transAxes, -287 # verticalalignment='top', fontsize=12, bbox=dict(facecolor='white', edgecolor='black', alpha=1)) -288 -289 ax.axvline(0.33, color='black', alpha=.33, lw=1) -290 ax.axvline(0.66, color='black', alpha=.33, lw=1) -291 ax.axhline(0.33, color='black', alpha=.33, lw=1) -292 ax.axhline(0.66, color='black', alpha=.33, lw=1) -293 -294 alpha = 1 -295 -296 all_colors = {'1A': '#dddddd', -297 '1B': '#dd7c8a', -298 '1C': '#cc0024', -299 '2A': '#7bb3d1', -300 '2B': '#8d6c8f', -301 '2C': '#8a274a', -302 '3A': '#016eae', -303 '3B': '#4a4779', -304 '3C': '#4b264d'} -305 -306 # Column 1 -307 c = all_colors['1A'] -308 ax.axvspan(xmin=0, xmax=0.33, ymin=0 + 0.025, -309 ymax=0.345, alpha=alpha, color=c) -310 -311 c = all_colors['1B'] -312 ax.axvspan(xmin=0, xmax=0.33, ymin=0.33 + 0.015, -313 ymax=0.66 - 0.015, alpha=alpha, color=c) -314 -315 c = all_colors['1C'] -316 ax.axvspan(xmin=0, xmax=0.33, ymin=0.66 - 0.015, -317 ymax=1 - 0.05, alpha=alpha, color=c) -318 -319 # Column 2 -320 c = all_colors['2A'] -321 ax.axvspan(xmin=0.33, xmax=0.66, ymin=0 + 0.025, -322 ymax=0.345, alpha=alpha, color=c) -323 -324 c = all_colors['2B'] -325 ax.axvspan(xmin=0.33, xmax=0.66, ymin=0.345, -326 ymax=0.645, alpha=alpha, color=c) -327 -328 c = all_colors['2C'] -329 ax.axvspan(xmin=0.33, xmax=0.66, ymin=0.649, -330 ymax=1 - 0.05, alpha=alpha, color=c) -331 -332 # Column 3 -333 c = all_colors['3A'] -334 ax.axvspan(xmin=0.66, xmax=1, ymin=0.025, ymax=0.345, alpha=alpha, color=c) -335 -336 c = all_colors['3B'] -337 ax.axvspan(xmin=0.66, xmax=1, ymin=0.345, -338 ymax=0.645, alpha=alpha, color=c) -339 -340 c = all_colors['3C'] -341 ax.axvspan(xmin=0.66, xmax=1, ymin=0.649, -342 ymax=1 - 0.05, alpha=alpha, color=c) -343 -344 ax.set_xlim(-.05, 1.05) -345 ax.set_ylim(-0.05, 1.05) -346 -347 # Add regression line -348 # x = data[x_name] -349 # y = data[y_name] -350 # m, b = np.polyfit(x, y, 1) -351 # ax.plot(x, m * x + b, color='black', alpha=0.5, zorder=1) -352 -353 -354def get_colors(data): -355 -356 # colors = ['#e8e8e8', # 1A -357 # '#b0d5df', # 1B -358 # # '#64acbe', # 1C -359 # '#e4acac', # 2A -360 # '#ad9ea5', # 2B -361 # '#627f8c', # 2C -362 # '#c85a5a', # 3A -363 # '#985356'] # , # 3B -364 # # '#574249'] # 3C -365 -366 all_colors = {'1A': '#e8e8e8', -367 '1B': '#b0d5df', -368 '1C': '#64acbe', -369 '2A': '#e4acac', -370 '2B': '#ad9ea5', -371 '2C': '#627f8c', -372 '3A': '#c85a5a', -373 '3B': '#985356', -374 '3C': '#574249'} -375 -376 all_colors = {'1A': '#dddddd', -377 '1B': '#dd7c8a', -378 '1C': '#cc0024', -379 '2A': '#7bb3d1', -380 '2B': '#8d6c8f', -381 '2C': '#8a274a', -382 '3A': '#016eae', -383 '3B': '#4a4779', -384 '3C': '#4b264d'} -385 -386 # Set of colors matching the elements of Bi_Class -387 # We have to exclude those that did not come up in the data -388 available_classes = data['Bi_Class'].value_counts().sort_index().index -389 available_colors = [all_colors[i] for i in available_classes] -390 return list(all_colors.values()), available_colors -391 -392 -393def bin_data(data, x_name, y_name, scale, print_statistics=True): -394 if scale: -395 # Scale the data to be between 0 and 1 -396 # data[x_name] = (data[x_name] - data[x_name].min()) / \ -397 # (data[x_name].max() - data[x_name].min()) -398 # data[y_name] = (data[y_name] - data[y_name].min()) / \ -399 # (data[y_name].max() - data[y_name].min()) -400 # Scale the data with MinMaxScaler -401 scaler = MinMaxScaler() -402 data[x_name] = scaler.fit_transform(data[x_name].values.reshape(-1, 1)) -403 data[y_name] = scaler.fit_transform(data[y_name].values.reshape(-1, 1)) -404 -405 # Define the bins -406 bins = [0, 0.33, 0.66, 1] -407 -408 # Bin the first variable - x -409 data['Var1_Class'] = pd.cut(data[x_name], bins=bins, include_lowest=True) -410 data['Var1_Class'] = data['Var1_Class'].astype('str') -411 -412 # Bin the second variable - y -413 data['Var2_Class'] = pd.cut(data[y_name], bins=bins, include_lowest=True) -414 data['Var2_Class'] = data['Var2_Class'].astype('str') -415 -416 # Code created x bins to 1, 2, 3 -417 x_class_codes = np.arange(1, len(bins)) -418 d = dict( -419 zip(data['Var1_Class'].value_counts().sort_index().index, x_class_codes)) -420 data['Var1_Class'] = data['Var1_Class'].replace(d) -421 -422 # Code created y bins to A, B, C -423 y_class_codes = ['A', 'B', 'C'] -424 d = dict( -425 zip(data['Var2_Class'].value_counts().sort_index().index, y_class_codes)) -426 data['Var2_Class'] = data['Var2_Class'].replace(d) -427 -428 # Combine x and y codes to create Bi_Class -429 data['Bi_Class'] = data['Var1_Class'].astype('str') + data['Var2_Class'] -430 -431 if print_statistics: -432 print('Number of unique elements in Var1_Class =', -433 len(data['Var1_Class'].unique())) -434 print('Number of unique elements in Var2_Class =', -435 len(data['Var2_Class'].unique())) -436 print('Number of unique elements in Bi_Class =', -437 len(data['Bi_Class'].unique())) -438 return data -
15def rainclouds(outcomes: pd.DataFrame, savefigs: bool, x_columns: list = [], x_titles: list = [], plot_years_in_poverty: bool = False, color_palette: str = 'Set2', sharex: bool = True): - 16 districts = outcomes['district'].unique().tolist() - 17 n_districts = len(districts) - 18 colors = sns.color_palette(color_palette, n_colors=len(districts)) - 19 - 20 if len(x_columns) == 0: - 21 x_columns = [ - 22 'n_affected_people', - 23 'n_new_poor_increase_pct', - 24 'n_new_poor', - 25 'annual_average_consumption_loss_pct', - 26 'r', - 27 'new_poverty_gap', - 28 # 'one_year_in_poverty', - 29 # 'two_years_in_poverty', - 30 # 'three_years_in_poverty', - 31 # 'four_years_in_poverty', - 32 # 'five_years_in_poverty', - 33 # 'six_years_in_poverty', - 34 # 'seven_years_in_poverty', - 35 # 'eight_years_in_poverty', - 36 # 'nine_years_in_poverty', - 37 # 'ten_years_in_poverty' - 38 ] - 39 - 40 if len(x_titles) == 0: - 41 x_titles = [ - 42 'Affected People', - 43 'New Poor Increase (%)', - 44 'New Poor', - 45 'Wt. Ann. Avg. Consump. Loss p.c. (%)', - 46 'Socio-Economic Resilience', - 47 'Poverty Gap', - 48 # 'One year in poverty', - 49 # 'Two years in poverty', - 50 # 'Three years in poverty', - 51 # 'Four years in poverty', - 52 # 'Five years in poverty', - 53 # 'Six years in poverty', - 54 # 'Seven years in poverty', - 55 # 'Eight years in poverty', - 56 # 'Nine years in poverty', - 57 # 'Ten years in poverty' - 58 ] - 59 - 60 is_years_in_poverty = False - 61 - 62 for x_column, x_title in zip(x_columns, x_titles): - 63 fig, ax = plt.subplots(ncols=3, nrows=3, figsize=( - 64 4 * n_districts / 3, 3 * n_districts / 3), sharex=sharex) - 65 - 66 for district in districts: - 67 df = outcomes[outcomes['district'] == district].copy() - 68 - 69 # Calculate an increase in new poor in respect to the total population - 70 # df = df.assign(one_year_in_poverty = df['years_in_poverty'].apply(lambda x: x[0])) - 71 # df = df.assign(two_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[1])) - 72 # df = df.assign(three_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[2])) - 73 # df = df.assign(four_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[3])) - 74 # df = df.assign(five_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[4])) - 75 # df = df.assign(six_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[5])) - 76 # df = df.assign(seven_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[6])) - 77 # df = df.assign(eight_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[7])) - 78 # df = df.assign(nine_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[8])) - 79 # df = df.assign(ten_years_in_poverty = df['years_in_poverty'].apply(lambda x: x[9])) - 80 - 81 df[x_column] = df[x_column].astype(float) - 82 - 83 # Make a half violin plot - 84 pt.half_violinplot(x=x_column, - 85 y='policy', # hue='scenario', - 86 data=df, - 87 color=colors[districts.index(district)], - 88 bw=.2, - 89 cut=0., - 90 scale="area", - 91 width=.6, - 92 inner=None, - 93 ax=ax[districts.index(district) // 3, districts.index(district) % 3]) - 94 - 95 # Add stripplot - 96 sns.stripplot(x=x_column, - 97 y='policy', # hue='scenario', - 98 data=df, - 99 color=colors[districts.index(district)], -100 edgecolor='white', -101 size=3, -102 jitter=1, -103 zorder=0, -104 orient='h', -105 ax=ax[districts.index(district) // 3, districts.index(district) % 3]) -106 -107 # Add boxplot -108 sns.boxplot(x=x_column, -109 y='policy', # hue='scenario', -110 data=df, -111 color="black", -112 width=.15, -113 zorder=10, -114 showcaps=True, -115 boxprops={'facecolor': 'none', "zorder": 10}, -116 showfliers=True, -117 whiskerprops={'linewidth': 2, "zorder": 10}, -118 saturation=1, -119 orient='h', -120 ax=ax[districts.index(district) // 3, districts.index(district) % 3]) -121 -122 if is_years_in_poverty: -123 title = district + ', E = ' + \ -124 f'{round(df[x_column].mean())}' -125 else: -126 title = district -127 ax[districts.index(district) // 3, -128 districts.index(district) % 3].set_title(title) -129 ax[districts.index(district) // 3, -130 districts.index(district) % 3].set_ylabel('') -131 ax[districts.index(district) // 3, -132 districts.index(district) % 3].set_xlabel(x_title) -133 -134 # Remove y ticks and labels -135 ax[districts.index(district) // 3, -136 districts.index(district) % 3].set_yticklabels([]) -137 ax[districts.index(district) // 3, -138 districts.index(district) % 3].set_yticks([]) -139 -140 # Do not display floats in the x-axis -141 ax[districts.index(district) // 3, districts.index(district) % -142 3].xaxis.set_major_locator(MaxNLocator(integer=True)) -143 -144 # Plot the median -145 # ax[districts.index(district) // 3, districts.index(district) % 3].axvline(df[x_column].median(), color='black', linestyle='--', linewidth=1) -146 -147 # Add text close to the boxplot's median -148 ax[districts.index(district) // 3, districts.index(district) % 3].text(df[x_column].median(), 0.2, -149 f'M={df[x_column].median():.2f}', -150 horizontalalignment='left', size='small', color='black') -151 -152 # # Add text close to the boxplot's min and max -153 # ax[districts.index(district) // 3, districts.index(district) % 3].text(df[x_column].min(), 0.3, -154 # f'min={df[x_column].min():.2f}', -155 # horizontalalignment='left', size='small', color='black') -156 # ax[districts.index(district) // 3, districts.index(district) % 3].text(df[x_column].max(), 0.4, -157 # f'max={df[x_column].max():.2f}', -158 # horizontalalignment='left', size='small', color='black') -159 -160 initial_poverty_gap = df['initial_poverty_gap'].iloc[0] -161 -162 # Add initial poverty gap as in the legend to the plot -163 if x_column == 'new_poverty_gap': -164 ax[districts.index(district) // 3, districts.index(district) % 3].text(0.025, 0.9, -165 f'Poverty gap before disaster={initial_poverty_gap:.2f}', -166 horizontalalignment='left', size='small', color='black', -167 transform=ax[districts.index(district) // 3, districts.index(district) % 3].transAxes) -168 -169 # Add a super title -170 # fig.suptitle(x_title, fontsize=16) -171 fig.tight_layout() -172 if savefigs: -173 plt.savefig( -174 f'../figures/analysis/{x_column}.png', dpi=500, bbox_inches='tight') -
177def bivariate_choropleth(data, x_name, y_name, x_label, y_label, scale, figsize, return_table): -178 fig, ax = plt.subplots(figsize=figsize) -179 -180 # Bin the data -181 data = bin_data(data, x_name, y_name, scale, print_statistics=False) -182 -183 # Get colors -184 all_colors, available_colors = get_colors(data) -185 cmap = matplotlib.colors.ListedColormap(available_colors) -186 -187 # Step 1: Draw the map -188 # border = gpd.read_file(f'../data/processed/boundaries/{city}/city.json') -189 border = gpd.read_file( -190 '../data/raw/shapefiles/Saint Lucia/gadm36_LCA_shp/gadm36_LCA_0.shp') -191 data.plot(ax=ax, -192 edgecolor='black', -193 linewidth=.1, -194 column='Bi_Class', # variable that is going to be used to color the map -195 cmap=cmap, # newly defined bivariate cmap -196 categorical=True, # bivariate choropleth has to be colored as categorical map -197 legend=False) # we're going to draw the legend ourselves -198 # add the basemap -199 # ctx.add_basemap(ax=ax, source=ctx.providers.CartoDB.Positron) -200 border.plot(ax=ax, facecolor='none', -201 edgecolor='black', alpha=.5) # city border -202 for idx, row in data.iterrows(): -203 ax.annotate(text=row['NAME_1'], xy=row['geometry'].centroid.coords[0], -204 ha='center', fontsize=8, color='white') -205 -206 plt.tight_layout() # "tighten" two figures map and basemap -207 plt.axis('off') # we don't need axis with coordinates -208 # ax.set_title('Bivariate Choropleth Amsterdam') -209 -210 # Step 2: draw the legend -211 -212 # We're drawing a 3x3 "box" as 3 columns -213 # The xmin and xmax arguments axvspan are defined to create equally sized small boxes -214 -215 img2 = fig # refer to the main figure -216 # add new axes to place the legend there -217 ax2 = fig.add_axes([0.15, 0.25, 0.1, 0.1]) -218 # and specify its location -219 alpha = 1 # alpha argument to make it more/less transparent -220 -221 # Column 1 -222 # All colors to create a complete legend -223 # all_colors = ['#e8e8e8', '#b0d5df', '#64acbe', '#e4acac', '#ad9ea5', '#627f8c', '#c85a5a', '#985356', '#574249'] -224 -225 ax2.axvspan(xmin=0, xmax=0.33, ymin=0, ymax=0.33, -226 alpha=alpha, color=all_colors[0]) -227 ax2.axvspan(xmin=0, xmax=0.33, ymin=0.33, ymax=0.66, -228 alpha=alpha, color=all_colors[1]) -229 ax2.axvspan(xmin=0, xmax=0.33, ymin=0.66, ymax=1, -230 alpha=alpha, color=all_colors[2]) -231 -232 # Column 2 -233 ax2.axvspan(xmin=0.33, xmax=0.66, ymin=0, ymax=0.33, -234 alpha=alpha, color=all_colors[3]) -235 ax2.axvspan(xmin=0.33, xmax=0.66, ymin=0.33, ymax=0.66, -236 alpha=alpha, color=all_colors[4]) -237 ax2.axvspan(xmin=0.33, xmax=0.66, ymin=0.66, ymax=1, -238 alpha=alpha, color=all_colors[5]) -239 -240 # Column 3 -241 ax2.axvspan(xmin=0.66, xmax=1, ymin=0, ymax=0.33, -242 alpha=alpha, color=all_colors[6]) -243 ax2.axvspan(xmin=0.66, xmax=1, ymin=0.33, ymax=0.66, -244 alpha=alpha, color=all_colors[7]) -245 ax2.axvspan(xmin=0.66, xmax=1, ymin=0.66, ymax=1, -246 alpha=alpha, color=all_colors[8]) -247 -248 # Step 3: annoate the legend -249 # remove ticks from the big box -250 ax2.tick_params(axis='both', which='both', length=0) -251 ax2.axis('off') # turn off its axis -252 ax2.annotate("", xy=(0, 1), xytext=(0, 0), arrowprops=dict( -253 arrowstyle="->", lw=1, color='black')) # draw arrow for x -254 ax2.annotate("", xy=(1, 0), xytext=(0, 0), arrowprops=dict( -255 arrowstyle="->", lw=1, color='black')) # draw arrow for y -256 ax2.text(s=x_label, x=0.1, y=-0.25, fontsize=8) # annotate x axis -257 ax2.text(s=y_label, x=-0.25, y=0.1, rotation=90, -258 fontsize=8) # annotate y axis -259 # plt.savefig('bivariate_choropleth.png', dpi=300) -260 -261 if return_table: -262 return data -
265def nine_quadrants_plot(data, x_name, y_name, scale=True): -266 _, ax = plt.subplots(figsize=(6, 5)) -267 -268 if scale: -269 scaler = MinMaxScaler() -270 # data[x_name] = scaler.fit_transform(data[x_name].values.reshape(-1, 1)) -271 # data[y_name] = scaler.fit_transform(data[y_name].values.reshape(-1, 1)) -272 # Scale data between 0 and 1 -273 data[x_name] = (data[x_name] - data[x_name].min()) / \ -274 (data[x_name].max() - data[x_name].min()) -275 data[y_name] = (data[y_name] - data[y_name].min()) / \ -276 (data[y_name].max() - data[y_name].min()) -277 -278 data.plot.scatter(x_name, y_name, s=20, ax=ax, c='black', zorder=2) -279 -280 # Iterate over each row and annotate the points -281 for idx, row in data.iterrows(): -282 ax.annotate(text=row['NAME_1'], xy=(row[x_name], row[y_name]), -283 ha='center', fontsize=10, color='black') -284 -285 # Annotate with Spearman's rho -286 # rho, p = spearmanr(data[x_name], data[y_name]) -287 # ax.text(0.05, 0.95, f'$\\rho$ = {round(rho, 2)}', transform=ax.transAxes, -288 # verticalalignment='top', fontsize=12, bbox=dict(facecolor='white', edgecolor='black', alpha=1)) -289 -290 ax.axvline(0.33, color='black', alpha=.33, lw=1) -291 ax.axvline(0.66, color='black', alpha=.33, lw=1) -292 ax.axhline(0.33, color='black', alpha=.33, lw=1) -293 ax.axhline(0.66, color='black', alpha=.33, lw=1) -294 -295 alpha = 1 -296 -297 all_colors = {'1A': '#dddddd', -298 '1B': '#dd7c8a', -299 '1C': '#cc0024', -300 '2A': '#7bb3d1', -301 '2B': '#8d6c8f', -302 '2C': '#8a274a', -303 '3A': '#016eae', -304 '3B': '#4a4779', -305 '3C': '#4b264d'} -306 -307 # Column 1 -308 c = all_colors['1A'] -309 ax.axvspan(xmin=0, xmax=0.33, ymin=0 + 0.025, -310 ymax=0.345, alpha=alpha, color=c) -311 -312 c = all_colors['1B'] -313 ax.axvspan(xmin=0, xmax=0.33, ymin=0.33 + 0.015, -314 ymax=0.66 - 0.015, alpha=alpha, color=c) -315 -316 c = all_colors['1C'] -317 ax.axvspan(xmin=0, xmax=0.33, ymin=0.66 - 0.015, -318 ymax=1 - 0.05, alpha=alpha, color=c) -319 -320 # Column 2 -321 c = all_colors['2A'] -322 ax.axvspan(xmin=0.33, xmax=0.66, ymin=0 + 0.025, -323 ymax=0.345, alpha=alpha, color=c) -324 -325 c = all_colors['2B'] -326 ax.axvspan(xmin=0.33, xmax=0.66, ymin=0.345, -327 ymax=0.645, alpha=alpha, color=c) -328 -329 c = all_colors['2C'] -330 ax.axvspan(xmin=0.33, xmax=0.66, ymin=0.649, -331 ymax=1 - 0.05, alpha=alpha, color=c) -332 -333 # Column 3 -334 c = all_colors['3A'] -335 ax.axvspan(xmin=0.66, xmax=1, ymin=0.025, ymax=0.345, alpha=alpha, color=c) -336 -337 c = all_colors['3B'] -338 ax.axvspan(xmin=0.66, xmax=1, ymin=0.345, -339 ymax=0.645, alpha=alpha, color=c) -340 -341 c = all_colors['3C'] -342 ax.axvspan(xmin=0.66, xmax=1, ymin=0.649, -343 ymax=1 - 0.05, alpha=alpha, color=c) -344 -345 ax.set_xlim(-.05, 1.05) -346 ax.set_ylim(-0.05, 1.05) -
355def get_colors(data): -356 -357 # colors = ['#e8e8e8', # 1A -358 # '#b0d5df', # 1B -359 # # '#64acbe', # 1C -360 # '#e4acac', # 2A -361 # '#ad9ea5', # 2B -362 # '#627f8c', # 2C -363 # '#c85a5a', # 3A -364 # '#985356'] # , # 3B -365 # # '#574249'] # 3C -366 -367 all_colors = {'1A': '#e8e8e8', -368 '1B': '#b0d5df', -369 '1C': '#64acbe', -370 '2A': '#e4acac', -371 '2B': '#ad9ea5', -372 '2C': '#627f8c', -373 '3A': '#c85a5a', -374 '3B': '#985356', -375 '3C': '#574249'} -376 -377 all_colors = {'1A': '#dddddd', -378 '1B': '#dd7c8a', -379 '1C': '#cc0024', -380 '2A': '#7bb3d1', -381 '2B': '#8d6c8f', -382 '2C': '#8a274a', -383 '3A': '#016eae', -384 '3B': '#4a4779', -385 '3C': '#4b264d'} -386 -387 # Set of colors matching the elements of Bi_Class -388 # We have to exclude those that did not come up in the data -389 available_classes = data['Bi_Class'].value_counts().sort_index().index -390 available_colors = [all_colors[i] for i in available_classes] -391 return list(all_colors.values()), available_colors -
394def bin_data(data, x_name, y_name, scale, print_statistics=True): -395 if scale: -396 # Scale the data to be between 0 and 1 -397 # data[x_name] = (data[x_name] - data[x_name].min()) / \ -398 # (data[x_name].max() - data[x_name].min()) -399 # data[y_name] = (data[y_name] - data[y_name].min()) / \ -400 # (data[y_name].max() - data[y_name].min()) -401 # Scale the data with MinMaxScaler -402 scaler = MinMaxScaler() -403 data[x_name] = scaler.fit_transform(data[x_name].values.reshape(-1, 1)) -404 data[y_name] = scaler.fit_transform(data[y_name].values.reshape(-1, 1)) -405 -406 # Define the bins -407 bins = [0, 0.33, 0.66, 1] -408 -409 # Bin the first variable - x -410 data['Var1_Class'] = pd.cut(data[x_name], bins=bins, include_lowest=True) -411 data['Var1_Class'] = data['Var1_Class'].astype('str') -412 -413 # Bin the second variable - y -414 data['Var2_Class'] = pd.cut(data[y_name], bins=bins, include_lowest=True) -415 data['Var2_Class'] = data['Var2_Class'].astype('str') -416 -417 # Code created x bins to 1, 2, 3 -418 x_class_codes = np.arange(1, len(bins)) -419 d = dict( -420 zip(data['Var1_Class'].value_counts().sort_index().index, x_class_codes)) -421 data['Var1_Class'] = data['Var1_Class'].replace(d) -422 -423 # Code created y bins to A, B, C -424 y_class_codes = ['A', 'B', 'C'] -425 d = dict( -426 zip(data['Var2_Class'].value_counts().sort_index().index, y_class_codes)) -427 data['Var2_Class'] = data['Var2_Class'].replace(d) -428 -429 # Combine x and y codes to create Bi_Class -430 data['Bi_Class'] = data['Var1_Class'].astype('str') + data['Var2_Class'] -431 -432 if print_statistics: -433 print('Number of unique elements in Var1_Class =', -434 len(data['Var1_Class'].unique())) -435 print('Number of unique elements in Var2_Class =', -436 len(data['Var2_Class'].unique())) -437 print('Number of unique elements in Bi_Class =', -438 len(data['Bi_Class'].unique())) -439 return data -
1# Specify which outcomes to store in each run of the simulation model - 2 - 3import pandas as pd - 4import numpy as np - 5 - 6 - 7def add_columns(households: pd.DataFrame, affected_households: pd.DataFrame) -> pd.DataFrame: - 8 '''Add columns/outcomes of interest from `affected households` to the `households` dataframe.''' - 9 - 10 # Outcomes of interest from affected households - 11 outcomes_of_interest: list = [ - 12 'consumption_loss', - 13 'consumption_loss_NPV', - 14 'c_t', - 15 'c_t_unaffected', - 16 'recovery_rate', - 17 'weeks_pov'] - 18 - 19 # Merge affected households onto households - 20 columns = ['hhid'] + outcomes_of_interest - 21 households = pd.merge( - 22 households, affected_households[columns], on='hhid', how='left') - 23 return households - 24 - 25 - 26def get_outcomes(households, event_damage, total_asset_stock, expected_loss_fraction, average_productivity, n_years) -> dict: - 27 '''Calculate outcomes of interest from the simulation model. - 28 - 29 Args: - 30 households (pd.DataFrame): Households data frame. - 31 event_damage (float): Event damage. - 32 total_asset_stock (float): Total asset stock. - 33 expected_loss_fraction (float): Expected loss fraction. - 34 average_productivity (float): Average productivity. - 35 n_years (float): Number of years to consider for calculations (same as for optimization algorithm). - 36 - 37 Returns: - 38 dict: Outcomes of interest. - 39 ''' - 40 # Save some outcomes for verification - 41 total_population = households['popwgt'].sum() - 42 total_asset_in_survey = households['total_asset_in_survey'].iloc[0] - 43 - 44 # Actual outcomes of interest - 45 affected_households = households[households['is_affected'] == True] - 46 total_asset_loss = affected_households[[ - 47 'keff', 'v', 'popwgt']].prod(axis=1).sum() - 48 total_consumption_loss = affected_households[[ - 49 'consumption_loss_NPV', 'popwgt']].prod(axis=1).sum() - 50 n_affected_people = affected_households['popwgt'].sum() - 51 annual_average_consumption = ( - 52 households['aeexp'] * households['popwgt']).sum() / households['popwgt'].sum() - 53 recovery_rate = households['recovery_rate'].mean() - 54 - 55 # * Poverty line is different across replications - 56 poverty_line_adjusted = households['poverty_line_adjusted'].values[0] - 57 - 58 # Get PML, its the same across replications and stored in households - 59 pml = households['pml'].iloc[0] - 60 - 61 # Run statistics - 62 no_affected_households = 0 - 63 zero_consumption_loss = 0 - 64 - 65 # * Some runs give no affected households and we will skip these - 66 if len(affected_households) == 0: - 67 no_affected_households += 1 - 68 pass - 69 - 70 # * Sometimes households are affected but they have no consumption loss - 71 if affected_households['consumption_loss_NPV'].sum() == 0: - 72 zero_consumption_loss += 1 - 73 pass - 74 - 75 # Calculate outcomes of interest - 76 n_poor_initial, n_new_poor, n_poor_affected, poor_initial, new_poor = find_poor( - 77 households, poverty_line_adjusted, n_years) - 78 - 79 years_in_poverty = get_people_by_years_in_poverty(new_poor) - 80 - 81 initial_poverty_gap, new_poverty_gap = calculate_poverty_gap( - 82 poor_initial, new_poor, poverty_line_adjusted, n_years) - 83 - 84 annual_average_consumption_loss, annual_average_consumption_loss_pct = calculate_average_annual_consumption_loss( - 85 affected_households, n_years) - 86 - 87 r = calculate_resilience( - 88 affected_households, pml) - 89 - 90 return { - 91 'total_population': total_population, - 92 'total_asset_loss': total_asset_loss, - 93 'total_consumption_loss': total_consumption_loss, - 94 'event_damage': event_damage, - 95 'total_asset_stock': total_asset_stock, - 96 'average_productivity': average_productivity, - 97 'total_asset_in_survey': total_asset_in_survey, - 98 'expected_loss_fraction': expected_loss_fraction, - 99 'n_affected_people': n_affected_people, -100 'annual_average_consumption': annual_average_consumption, -101 'poverty_line_adjusted': poverty_line_adjusted, -102 'pml': pml, -103 'n_poor_initial': n_poor_initial, -104 'n_poor_affected': n_poor_affected, -105 'n_new_poor': n_new_poor, -106 'initial_poverty_gap': initial_poverty_gap, -107 'new_poverty_gap': new_poverty_gap, -108 'annual_average_consumption_loss': annual_average_consumption_loss, -109 'annual_average_consumption_loss_pct': annual_average_consumption_loss_pct, -110 'r': r, -111 'recovery_rate': recovery_rate, -112 'years_in_poverty': years_in_poverty -113 # 'n_resilience_more_than_1' : n_resilience_more_than_1 -114 } -115 -116 -117def find_poor(households: pd.DataFrame, poverty_line: float, n_years: int) -> tuple: -118 '''Get the poor at the beginning of the simulation and the poor at the end of the simulation -119 -120 Args: -121 households (pd.DataFrame): Household dataframe -122 poverty_line (float): Poverty line -123 -124 Returns: -125 tuple: Number of poor at the beginning of the simulation, number of new poor at the end of the simulation, and the new poor dataframe -126 ''' -127 # First, find the poor at the beginning of the simulation -128 poor_initial = households[households['is_poor'] == True] -129 n_poor_initial = round(poor_initial['popwgt'].sum()) -130 n_poor_affected = round( -131 poor_initial[poor_initial['is_affected'] == True]['popwgt'].sum()) -132 -133 # Second, find the new poor at the end of the simulation (`n_years`) -134 not_poor = households[households['is_poor'] == False] -135 not_poor_affected = not_poor[not_poor['is_affected'] == True] -136 x = not_poor_affected['aeexp'] - \ -137 not_poor_affected['consumption_loss_NPV'] / n_years -138 new_poor = not_poor_affected.loc[x < poverty_line, :] -139 n_new_poor = round(new_poor['popwgt'].sum()) -140 -141 return n_poor_initial, n_new_poor, n_poor_affected, poor_initial, new_poor -142 -143 -144def get_people_by_years_in_poverty(new_poor: pd.DataFrame) -> dict: -145 '''Get the number of people in poverty for each year in poverty. -146 -147 Args: -148 new_poor (pd.DataFrame): New poor dataframe -149 -150 Returns: -151 dict: Number of people in poverty for each year in poverty -152 ''' -153 new_poor = new_poor.assign( -154 years_in_poverty=new_poor['weeks_pov'] // 52) -155 d = {} -156 # !: This cannot be higher > n_years -157 longest_years_in_poverty = 10 -158 for i in range(longest_years_in_poverty): -159 d[i] = round(new_poor[new_poor['years_in_poverty'] == i] -160 ['popwgt'].sum()) -161 d[longest_years_in_poverty] = round( -162 new_poor[new_poor['years_in_poverty'] >= longest_years_in_poverty]['popwgt'].sum()) -163 -164 return d -165 -166 -167def calculate_poverty_gap(poor_initial: pd.DataFrame, new_poor: pd.DataFrame, poverty_line: float, n_years: int) -> tuple: -168 '''Calculate the poverty gap at the beginning and at the end of the simulation. -169 -170 Args: -171 poor_initial (pd.DataFrame): Poor at the beginning of the simulation -172 new_poor (pd.DataFrame): New poor at the end of the simulation -173 poverty_line (float): Poverty line -174 n_years (int): Number of years of the optimization algorithm -175 -176 Returns: -177 tuple: Poverty gap at the beginning and at the end of the simulation -178 -179 Raises: -180 Exception: If the index is duplicated -181 Exception: If the poverty gap is greater than 1 -182 ''' -183 # First, get the average expenditure of the poor at the beginning of the simulation -184 average_expenditure_poor_initial = ( -185 poor_initial['aeexp'] * poor_initial['popwgt']).sum() / poor_initial['popwgt'].sum() -186 initial_poverty_gap = ( -187 poverty_line - average_expenditure_poor_initial) / poverty_line -188 -189 new_poor['aeexp'] = new_poor['aeexp'] - \ -190 new_poor['consumption_loss_NPV'] / n_years -191 -192 all_poor = pd.concat([poor_initial, new_poor]) -193 -194 # Now, get the average expenditure of the poor at the end of the simulation -195 average_expenditure_poor_new = ( -196 all_poor['aeexp'] * all_poor['popwgt']).sum() / all_poor['popwgt'].sum() -197 new_poverty_gap = ( -198 poverty_line - average_expenditure_poor_new) / poverty_line -199 -200 # Poverty gap cannot be greater than 1 -201 if new_poverty_gap > 1 or initial_poverty_gap > 1: -202 raise Exception('Poverty gap is greater than 1') -203 -204 return initial_poverty_gap, new_poverty_gap -205 -206 -207def calculate_average_annual_consumption_loss(affected_households: pd.DataFrame, n_years: int) -> tuple: -208 '''Get the average annual consumption loss and the average annual consumption loss as a percentage of average annual consumption. -209 -210 Args: -211 affected_households (pd.DataFrame): Affected households dataframe -212 n_years (int): Number of years of the optimization algorithm -213 -214 Returns: -215 tuple: Average annual consumption loss and average annual consumption loss as a percentage of average annual consumption -216 -217 Raises: -218 Exception: If the average annual consumption loss is greater than 1 -219 ''' -220 -221 if len(affected_households) == 0: -222 return np.nan, np.nan -223 -224 # Annual consumption loss -225 annual_consumption_loss = ( -226 affected_households['consumption_loss_NPV'].div(n_years).multiply(affected_households['popwgt'])).sum() -227 -228 # Weighted average -229 annual_average_consumption_loss = annual_consumption_loss / \ -230 affected_households['popwgt'].sum() -231 -232 # Annual average consumption -233 annual_average_consumption = ( -234 affected_households['aeexp'] * affected_households['popwgt']).sum() / \ -235 affected_households['popwgt'].sum() -236 -237 # Annual average consumption loss as a percentage of average annual consumption -238 annual_average_consumption_loss_pct = annual_average_consumption_loss / \ -239 annual_average_consumption -240 -241 if annual_average_consumption_loss_pct > 1: -242 raise Exception( -243 'Annual average consumption loss is greater than 1') -244 -245 return annual_average_consumption_loss, annual_average_consumption_loss_pct -246 -247 -248def calculate_resilience(affected_households: pd.DataFrame, pml: float, -249 # n_resilience_more_than_1: int -250 ) -> tuple: -251 '''Calculate the resilience of the affected households. -252 -253 Args: -254 affected_households (pd.DataFrame): Affected households dataframe -255 pml (float): Probable maximum loss -256 -257 Returns: -258 tuple: Resilience and number of times resilience is greater than 1 -259 -260 Raises: -261 Exception: If the total consumption loss is 0 -262 ''' -263 total_consumption_loss = ( -264 affected_households['consumption_loss_NPV'] * affected_households['popwgt']).sum() -265 -266 if total_consumption_loss == 0: -267 # raise Exception('Total consumption loss is 0') -268 r = np.nan -269 else: -270 r = pml / total_consumption_loss -271 -272 # !: Sometimes resilience is greater than 1 -273 # We will set it to 1 then -274 # if r > 5: -275 # r = 1 -276 # # raise Exception('Resilience is greater than 1') -277 # # n_resilience_more_than_1 += 1 -278 # # continue -279 return r -
8def add_columns(households: pd.DataFrame, affected_households: pd.DataFrame) -> pd.DataFrame: - 9 '''Add columns/outcomes of interest from `affected households` to the `households` dataframe.''' -10 -11 # Outcomes of interest from affected households -12 outcomes_of_interest: list = [ -13 'consumption_loss', -14 'consumption_loss_NPV', -15 'c_t', -16 'c_t_unaffected', -17 'recovery_rate', -18 'weeks_pov'] -19 -20 # Merge affected households onto households -21 columns = ['hhid'] + outcomes_of_interest -22 households = pd.merge( -23 households, affected_households[columns], on='hhid', how='left') -24 return households -
Add columns/outcomes of interest from affected households
to the households
dataframe.
27def get_outcomes(households, event_damage, total_asset_stock, expected_loss_fraction, average_productivity, n_years) -> dict: - 28 '''Calculate outcomes of interest from the simulation model. - 29 - 30 Args: - 31 households (pd.DataFrame): Households data frame. - 32 event_damage (float): Event damage. - 33 total_asset_stock (float): Total asset stock. - 34 expected_loss_fraction (float): Expected loss fraction. - 35 average_productivity (float): Average productivity. - 36 n_years (float): Number of years to consider for calculations (same as for optimization algorithm). - 37 - 38 Returns: - 39 dict: Outcomes of interest. - 40 ''' - 41 # Save some outcomes for verification - 42 total_population = households['popwgt'].sum() - 43 total_asset_in_survey = households['total_asset_in_survey'].iloc[0] - 44 - 45 # Actual outcomes of interest - 46 affected_households = households[households['is_affected'] == True] - 47 total_asset_loss = affected_households[[ - 48 'keff', 'v', 'popwgt']].prod(axis=1).sum() - 49 total_consumption_loss = affected_households[[ - 50 'consumption_loss_NPV', 'popwgt']].prod(axis=1).sum() - 51 n_affected_people = affected_households['popwgt'].sum() - 52 annual_average_consumption = ( - 53 households['aeexp'] * households['popwgt']).sum() / households['popwgt'].sum() - 54 recovery_rate = households['recovery_rate'].mean() - 55 - 56 # * Poverty line is different across replications - 57 poverty_line_adjusted = households['poverty_line_adjusted'].values[0] - 58 - 59 # Get PML, its the same across replications and stored in households - 60 pml = households['pml'].iloc[0] - 61 - 62 # Run statistics - 63 no_affected_households = 0 - 64 zero_consumption_loss = 0 - 65 - 66 # * Some runs give no affected households and we will skip these - 67 if len(affected_households) == 0: - 68 no_affected_households += 1 - 69 pass - 70 - 71 # * Sometimes households are affected but they have no consumption loss - 72 if affected_households['consumption_loss_NPV'].sum() == 0: - 73 zero_consumption_loss += 1 - 74 pass - 75 - 76 # Calculate outcomes of interest - 77 n_poor_initial, n_new_poor, n_poor_affected, poor_initial, new_poor = find_poor( - 78 households, poverty_line_adjusted, n_years) - 79 - 80 years_in_poverty = get_people_by_years_in_poverty(new_poor) - 81 - 82 initial_poverty_gap, new_poverty_gap = calculate_poverty_gap( - 83 poor_initial, new_poor, poverty_line_adjusted, n_years) - 84 - 85 annual_average_consumption_loss, annual_average_consumption_loss_pct = calculate_average_annual_consumption_loss( - 86 affected_households, n_years) - 87 - 88 r = calculate_resilience( - 89 affected_households, pml) - 90 - 91 return { - 92 'total_population': total_population, - 93 'total_asset_loss': total_asset_loss, - 94 'total_consumption_loss': total_consumption_loss, - 95 'event_damage': event_damage, - 96 'total_asset_stock': total_asset_stock, - 97 'average_productivity': average_productivity, - 98 'total_asset_in_survey': total_asset_in_survey, - 99 'expected_loss_fraction': expected_loss_fraction, -100 'n_affected_people': n_affected_people, -101 'annual_average_consumption': annual_average_consumption, -102 'poverty_line_adjusted': poverty_line_adjusted, -103 'pml': pml, -104 'n_poor_initial': n_poor_initial, -105 'n_poor_affected': n_poor_affected, -106 'n_new_poor': n_new_poor, -107 'initial_poverty_gap': initial_poverty_gap, -108 'new_poverty_gap': new_poverty_gap, -109 'annual_average_consumption_loss': annual_average_consumption_loss, -110 'annual_average_consumption_loss_pct': annual_average_consumption_loss_pct, -111 'r': r, -112 'recovery_rate': recovery_rate, -113 'years_in_poverty': years_in_poverty -114 # 'n_resilience_more_than_1' : n_resilience_more_than_1 -115 } -
Calculate outcomes of interest from the simulation model.
- -Args: - households (pd.DataFrame): Households data frame. - event_damage (float): Event damage. - total_asset_stock (float): Total asset stock. - expected_loss_fraction (float): Expected loss fraction. - average_productivity (float): Average productivity. - n_years (float): Number of years to consider for calculations (same as for optimization algorithm).
- -Returns: - dict: Outcomes of interest.
-118def find_poor(households: pd.DataFrame, poverty_line: float, n_years: int) -> tuple: -119 '''Get the poor at the beginning of the simulation and the poor at the end of the simulation -120 -121 Args: -122 households (pd.DataFrame): Household dataframe -123 poverty_line (float): Poverty line -124 -125 Returns: -126 tuple: Number of poor at the beginning of the simulation, number of new poor at the end of the simulation, and the new poor dataframe -127 ''' -128 # First, find the poor at the beginning of the simulation -129 poor_initial = households[households['is_poor'] == True] -130 n_poor_initial = round(poor_initial['popwgt'].sum()) -131 n_poor_affected = round( -132 poor_initial[poor_initial['is_affected'] == True]['popwgt'].sum()) -133 -134 # Second, find the new poor at the end of the simulation (`n_years`) -135 not_poor = households[households['is_poor'] == False] -136 not_poor_affected = not_poor[not_poor['is_affected'] == True] -137 x = not_poor_affected['aeexp'] - \ -138 not_poor_affected['consumption_loss_NPV'] / n_years -139 new_poor = not_poor_affected.loc[x < poverty_line, :] -140 n_new_poor = round(new_poor['popwgt'].sum()) -141 -142 return n_poor_initial, n_new_poor, n_poor_affected, poor_initial, new_poor -
Get the poor at the beginning of the simulation and the poor at the end of the simulation
- -Args: - households (pd.DataFrame): Household dataframe - poverty_line (float): Poverty line
- -Returns: - tuple: Number of poor at the beginning of the simulation, number of new poor at the end of the simulation, and the new poor dataframe
-145def get_people_by_years_in_poverty(new_poor: pd.DataFrame) -> dict: -146 '''Get the number of people in poverty for each year in poverty. -147 -148 Args: -149 new_poor (pd.DataFrame): New poor dataframe -150 -151 Returns: -152 dict: Number of people in poverty for each year in poverty -153 ''' -154 new_poor = new_poor.assign( -155 years_in_poverty=new_poor['weeks_pov'] // 52) -156 d = {} -157 # !: This cannot be higher > n_years -158 longest_years_in_poverty = 10 -159 for i in range(longest_years_in_poverty): -160 d[i] = round(new_poor[new_poor['years_in_poverty'] == i] -161 ['popwgt'].sum()) -162 d[longest_years_in_poverty] = round( -163 new_poor[new_poor['years_in_poverty'] >= longest_years_in_poverty]['popwgt'].sum()) -164 -165 return d -
Get the number of people in poverty for each year in poverty.
- -Args: - new_poor (pd.DataFrame): New poor dataframe
- -Returns: - dict: Number of people in poverty for each year in poverty
-168def calculate_poverty_gap(poor_initial: pd.DataFrame, new_poor: pd.DataFrame, poverty_line: float, n_years: int) -> tuple: -169 '''Calculate the poverty gap at the beginning and at the end of the simulation. -170 -171 Args: -172 poor_initial (pd.DataFrame): Poor at the beginning of the simulation -173 new_poor (pd.DataFrame): New poor at the end of the simulation -174 poverty_line (float): Poverty line -175 n_years (int): Number of years of the optimization algorithm -176 -177 Returns: -178 tuple: Poverty gap at the beginning and at the end of the simulation -179 -180 Raises: -181 Exception: If the index is duplicated -182 Exception: If the poverty gap is greater than 1 -183 ''' -184 # First, get the average expenditure of the poor at the beginning of the simulation -185 average_expenditure_poor_initial = ( -186 poor_initial['aeexp'] * poor_initial['popwgt']).sum() / poor_initial['popwgt'].sum() -187 initial_poverty_gap = ( -188 poverty_line - average_expenditure_poor_initial) / poverty_line -189 -190 new_poor['aeexp'] = new_poor['aeexp'] - \ -191 new_poor['consumption_loss_NPV'] / n_years -192 -193 all_poor = pd.concat([poor_initial, new_poor]) -194 -195 # Now, get the average expenditure of the poor at the end of the simulation -196 average_expenditure_poor_new = ( -197 all_poor['aeexp'] * all_poor['popwgt']).sum() / all_poor['popwgt'].sum() -198 new_poverty_gap = ( -199 poverty_line - average_expenditure_poor_new) / poverty_line -200 -201 # Poverty gap cannot be greater than 1 -202 if new_poverty_gap > 1 or initial_poverty_gap > 1: -203 raise Exception('Poverty gap is greater than 1') -204 -205 return initial_poverty_gap, new_poverty_gap -
Calculate the poverty gap at the beginning and at the end of the simulation.
- -Args: - poor_initial (pd.DataFrame): Poor at the beginning of the simulation - new_poor (pd.DataFrame): New poor at the end of the simulation - poverty_line (float): Poverty line - n_years (int): Number of years of the optimization algorithm
- -Returns: - tuple: Poverty gap at the beginning and at the end of the simulation
- -Raises: - Exception: If the index is duplicated - Exception: If the poverty gap is greater than 1
-208def calculate_average_annual_consumption_loss(affected_households: pd.DataFrame, n_years: int) -> tuple: -209 '''Get the average annual consumption loss and the average annual consumption loss as a percentage of average annual consumption. -210 -211 Args: -212 affected_households (pd.DataFrame): Affected households dataframe -213 n_years (int): Number of years of the optimization algorithm -214 -215 Returns: -216 tuple: Average annual consumption loss and average annual consumption loss as a percentage of average annual consumption -217 -218 Raises: -219 Exception: If the average annual consumption loss is greater than 1 -220 ''' -221 -222 if len(affected_households) == 0: -223 return np.nan, np.nan -224 -225 # Annual consumption loss -226 annual_consumption_loss = ( -227 affected_households['consumption_loss_NPV'].div(n_years).multiply(affected_households['popwgt'])).sum() -228 -229 # Weighted average -230 annual_average_consumption_loss = annual_consumption_loss / \ -231 affected_households['popwgt'].sum() -232 -233 # Annual average consumption -234 annual_average_consumption = ( -235 affected_households['aeexp'] * affected_households['popwgt']).sum() / \ -236 affected_households['popwgt'].sum() -237 -238 # Annual average consumption loss as a percentage of average annual consumption -239 annual_average_consumption_loss_pct = annual_average_consumption_loss / \ -240 annual_average_consumption -241 -242 if annual_average_consumption_loss_pct > 1: -243 raise Exception( -244 'Annual average consumption loss is greater than 1') -245 -246 return annual_average_consumption_loss, annual_average_consumption_loss_pct -
Get the average annual consumption loss and the average annual consumption loss as a percentage of average annual consumption.
- -Args: - affected_households (pd.DataFrame): Affected households dataframe - n_years (int): Number of years of the optimization algorithm
- -Returns: - tuple: Average annual consumption loss and average annual consumption loss as a percentage of average annual consumption
- -Raises: - Exception: If the average annual consumption loss is greater than 1
-249def calculate_resilience(affected_households: pd.DataFrame, pml: float, -250 # n_resilience_more_than_1: int -251 ) -> tuple: -252 '''Calculate the resilience of the affected households. -253 -254 Args: -255 affected_households (pd.DataFrame): Affected households dataframe -256 pml (float): Probable maximum loss -257 -258 Returns: -259 tuple: Resilience and number of times resilience is greater than 1 -260 -261 Raises: -262 Exception: If the total consumption loss is 0 -263 ''' -264 total_consumption_loss = ( -265 affected_households['consumption_loss_NPV'] * affected_households['popwgt']).sum() -266 -267 if total_consumption_loss == 0: -268 # raise Exception('Total consumption loss is 0') -269 r = np.nan -270 else: -271 r = pml / total_consumption_loss -272 -273 # !: Sometimes resilience is greater than 1 -274 # We will set it to 1 then -275 # if r > 5: -276 # r = 1 -277 # # raise Exception('Resilience is greater than 1') -278 # # n_resilience_more_than_1 += 1 -279 # # continue -280 return r -
Calculate the resilience of the affected households.
- -Args: - affected_households (pd.DataFrame): Affected households dataframe - pml (float): Probable maximum loss
- -Returns: - tuple: Resilience and number of times resilience is greater than 1
- -Raises: - Exception: If the total consumption loss is 0
-1# The model function pipeline, which is called by the ema_workbench in `__main__.py`. - 2 - 3import pandas as pd - 4import numpy as np - 5import random - 6import matplotlib.pyplot as plt - 7from src.data.read import * - 8from src.data.write import * - 9from src.modules.optimize import * - 10from src.modules.households import * - 11 - 12 - 13def initialize_model(country: str, min_households: int) -> tuple: - 14 '''Initialize the model by reading household survey and asset damage files. - 15 - 16 Args: - 17 country (str): Country name. - 18 min_households (int): Minimum number of households that we need to have in a sample to be representative. - 19 - 20 Returns: - 21 tuple: Household survey and asset damage files. - 22 ''' - 23 - 24 # Read household survey and asset damage files - 25 household_survey = read_household_survey(country) - 26 all_damage = read_asset_damage(country) - 27 - 28 # Duplicate households to have at least `min_households` households - 29 household_survey = duplicate_households(household_survey, min_households) - 30 - 31 return household_survey, all_damage - 32 - 33 - 34def run_model(**kwargs): - 35 '''Run the model.''' - 36 # ------------------------- Read the model parameters ------------------------ # - 37 country = kwargs['country'] - 38 scale = kwargs['scale'] - 39 districts = kwargs['districts'] - 40 min_households = kwargs['min_households'] - 41 - 42 # Read household survey and asset damage files - 43 household_survey, all_damage = initialize_model( - 44 country, min_households) - 45 - 46 # Case study constants - 47 return_period = kwargs['return_period'] - 48 poverty_line = kwargs['poverty_line'] - 49 indigence_line = kwargs['indigence_line'] - 50 saving_rate = kwargs['saving_rate'] - 51 is_vulnerability_random = kwargs['is_vulnerability_random'] - 52 n_years = kwargs['n_years'] # number of years in optimization algorithm - 53 - 54 # Model constants - 55 estimate_savings_params = kwargs['estimate_savings_params'] - 56 set_vulnerability_params = kwargs['set_vulnerability_params'] - 57 calculate_exposure_params = kwargs['calculate_exposure_params'] - 58 determine_affected_params = kwargs['determine_affected_params'] - 59 - 60 # Uncertainties - 61 poverty_bias = kwargs['poverty_bias'] - 62 consumption_utility = kwargs['consumption_utility'] - 63 discount_rate = kwargs['discount_rate'] - 64 optimization_timestep = kwargs['optimization_timestep'] - 65 income_and_expenditure_growth = kwargs['income_and_expenditure_growth'] - 66 - 67 # Policy levers - 68 try: - 69 my_policy = kwargs['my_policy'] - 70 except: - 71 # If a policy is not provided, use the default policy - 72 my_policy = 'all+0' - 73 - 74 add_income_loss = kwargs['add_income_loss'] - 75 - 76 # Outcomes - 77 # Store outcomes in a dictionary, where the key is a district and value is a dictionary of outcomes - 78 outcomes = {} - 79 - 80 # Print statistics for debugging - 81 print_statistics = kwargs['print_statistics'] - 82 - 83 # Fix random seed for reproducibility - 84 random_seed = kwargs['random_seed'] - 85 random.seed(random_seed) - 86 np.random.seed(random_seed) - 87 - 88 # PIPELINE: - 89 # 1. Load all damage - 90 # 2. Load household survey - 91 # 3. Select district - 92 # 4. Get event damage, total asset stock, expected loss fraction - 93 # 5. Calculate average productivity - 94 # 6. Adjust assets and expenditure - 95 # 7. Calculate PML - 96 # 8. Estimate savings - 97 # 9. Set vulnerability - 98 # 10. Calculate exposure - 99 # 11. Determine affected -100 # 12. Apply individual policy -101 # 13. Run optimization -102 # 14. Integrate wellbeing -103 # 15. Prepare outcomes -104 # 16. Get outcomes -105 -106 # ---------------------- Run the model for each district --------------------- # -107 -108 for district in districts: -109 # Read household survey and asset damage files for a specific district -110 event_damage, total_asset_stock, expected_loss_fraction = get_asset_damage( -111 all_damage, scale, district, return_period, print_statistics) -112 -113 households = select_district(household_survey, district) -114 -115 average_productivity = calculate_average_productivity( -116 households, print_statistics) -117 -118 # Model the impact of a disaster on households -119 households = (adjust_assets_and_expenditure(households, total_asset_stock, poverty_line, indigence_line, print_statistics) -120 .pipe(calculate_pml, expected_loss_fraction, print_statistics) -121 .pipe(estimate_savings, saving_rate, estimate_savings_params) -122 .pipe(set_vulnerability, is_vulnerability_random, set_vulnerability_params) -123 .pipe(calculate_exposure, poverty_bias, calculate_exposure_params, print_statistics) -124 .pipe(determine_affected, determine_affected_params)) -125 -126 # households['aesav'].hist() -127 # plt.show() -128 -129 # Apply a policy -130 households, affected_households = apply_individual_policy( -131 households, my_policy) -132 -133 # Calculate the impact and recovery -134 # cash_transfer = {52: 1000, 208: 5000} -135 cash_transfer = {} -136 affected_households = (run_optimization(affected_households, consumption_utility, discount_rate, average_productivity, optimization_timestep, n_years) -137 .pipe(integrate_wellbeing, consumption_utility, discount_rate, income_and_expenditure_growth, average_productivity, poverty_line, n_years, add_income_loss, cash_transfer)) -138 -139 # Add columns of affected households to the original households dataframe -140 households = add_columns(households, affected_households) -141 # Get outcomes -142 array_outcomes = np.array(list(get_outcomes( -143 households, event_damage, total_asset_stock, expected_loss_fraction, average_productivity, n_years).values())) -144 -145 # * To check whether we have different households affected in different runs -146 # if district == 'Castries': -147 # affected_households.to_csv(f'affected_households_{random_seed}.csv') -148 -149 outcomes[district] = array_outcomes -150 -151 return outcomes -
14def initialize_model(country: str, min_households: int) -> tuple: -15 '''Initialize the model by reading household survey and asset damage files. -16 -17 Args: -18 country (str): Country name. -19 min_households (int): Minimum number of households that we need to have in a sample to be representative. -20 -21 Returns: -22 tuple: Household survey and asset damage files. -23 ''' -24 -25 # Read household survey and asset damage files -26 household_survey = read_household_survey(country) -27 all_damage = read_asset_damage(country) -28 -29 # Duplicate households to have at least `min_households` households -30 household_survey = duplicate_households(household_survey, min_households) -31 -32 return household_survey, all_damage -
Initialize the model by reading household survey and asset damage files.
- -Args: - country (str): Country name. - min_households (int): Minimum number of households that we need to have in a sample to be representative.
- -Returns: - tuple: Household survey and asset damage files.
-35def run_model(**kwargs): - 36 '''Run the model.''' - 37 # ------------------------- Read the model parameters ------------------------ # - 38 country = kwargs['country'] - 39 scale = kwargs['scale'] - 40 districts = kwargs['districts'] - 41 min_households = kwargs['min_households'] - 42 - 43 # Read household survey and asset damage files - 44 household_survey, all_damage = initialize_model( - 45 country, min_households) - 46 - 47 # Case study constants - 48 return_period = kwargs['return_period'] - 49 poverty_line = kwargs['poverty_line'] - 50 indigence_line = kwargs['indigence_line'] - 51 saving_rate = kwargs['saving_rate'] - 52 is_vulnerability_random = kwargs['is_vulnerability_random'] - 53 n_years = kwargs['n_years'] # number of years in optimization algorithm - 54 - 55 # Model constants - 56 estimate_savings_params = kwargs['estimate_savings_params'] - 57 set_vulnerability_params = kwargs['set_vulnerability_params'] - 58 calculate_exposure_params = kwargs['calculate_exposure_params'] - 59 determine_affected_params = kwargs['determine_affected_params'] - 60 - 61 # Uncertainties - 62 poverty_bias = kwargs['poverty_bias'] - 63 consumption_utility = kwargs['consumption_utility'] - 64 discount_rate = kwargs['discount_rate'] - 65 optimization_timestep = kwargs['optimization_timestep'] - 66 income_and_expenditure_growth = kwargs['income_and_expenditure_growth'] - 67 - 68 # Policy levers - 69 try: - 70 my_policy = kwargs['my_policy'] - 71 except: - 72 # If a policy is not provided, use the default policy - 73 my_policy = 'all+0' - 74 - 75 add_income_loss = kwargs['add_income_loss'] - 76 - 77 # Outcomes - 78 # Store outcomes in a dictionary, where the key is a district and value is a dictionary of outcomes - 79 outcomes = {} - 80 - 81 # Print statistics for debugging - 82 print_statistics = kwargs['print_statistics'] - 83 - 84 # Fix random seed for reproducibility - 85 random_seed = kwargs['random_seed'] - 86 random.seed(random_seed) - 87 np.random.seed(random_seed) - 88 - 89 # PIPELINE: - 90 # 1. Load all damage - 91 # 2. Load household survey - 92 # 3. Select district - 93 # 4. Get event damage, total asset stock, expected loss fraction - 94 # 5. Calculate average productivity - 95 # 6. Adjust assets and expenditure - 96 # 7. Calculate PML - 97 # 8. Estimate savings - 98 # 9. Set vulnerability - 99 # 10. Calculate exposure -100 # 11. Determine affected -101 # 12. Apply individual policy -102 # 13. Run optimization -103 # 14. Integrate wellbeing -104 # 15. Prepare outcomes -105 # 16. Get outcomes -106 -107 # ---------------------- Run the model for each district --------------------- # -108 -109 for district in districts: -110 # Read household survey and asset damage files for a specific district -111 event_damage, total_asset_stock, expected_loss_fraction = get_asset_damage( -112 all_damage, scale, district, return_period, print_statistics) -113 -114 households = select_district(household_survey, district) -115 -116 average_productivity = calculate_average_productivity( -117 households, print_statistics) -118 -119 # Model the impact of a disaster on households -120 households = (adjust_assets_and_expenditure(households, total_asset_stock, poverty_line, indigence_line, print_statistics) -121 .pipe(calculate_pml, expected_loss_fraction, print_statistics) -122 .pipe(estimate_savings, saving_rate, estimate_savings_params) -123 .pipe(set_vulnerability, is_vulnerability_random, set_vulnerability_params) -124 .pipe(calculate_exposure, poverty_bias, calculate_exposure_params, print_statistics) -125 .pipe(determine_affected, determine_affected_params)) -126 -127 # households['aesav'].hist() -128 # plt.show() -129 -130 # Apply a policy -131 households, affected_households = apply_individual_policy( -132 households, my_policy) -133 -134 # Calculate the impact and recovery -135 # cash_transfer = {52: 1000, 208: 5000} -136 cash_transfer = {} -137 affected_households = (run_optimization(affected_households, consumption_utility, discount_rate, average_productivity, optimization_timestep, n_years) -138 .pipe(integrate_wellbeing, consumption_utility, discount_rate, income_and_expenditure_growth, average_productivity, poverty_line, n_years, add_income_loss, cash_transfer)) -139 -140 # Add columns of affected households to the original households dataframe -141 households = add_columns(households, affected_households) -142 # Get outcomes -143 array_outcomes = np.array(list(get_outcomes( -144 households, event_damage, total_asset_stock, expected_loss_fraction, average_productivity, n_years).values())) -145 -146 # * To check whether we have different households affected in different runs -147 # if district == 'Castries': -148 # affected_households.to_csv(f'affected_households_{random_seed}.csv') -149 -150 outcomes[district] = array_outcomes -151 -152 return outcomes -
Run the model.
-1import pandas as pd - 2import numpy as np - 3 - 4 - 5def duplicate_households(household_survey: pd.DataFrame, min_households: int) -> pd.DataFrame: - 6 '''Duplicates households if the number of households is less than `min_households` threshold. - 7 - 8 Args: - 9 household_survey (pd.DataFrame): Household survey data. - 10 min_households (int): Minimum number of households. - 11 - 12 Returns: - 13 pd.DataFrame: Household survey data with duplicated households. - 14 - 15 Raises: - 16 ValueError: If the total weights after duplication is not equal to the initial total weights. - 17 ''' - 18 - 19 if len(household_survey) < min_households: - 20 print( - 21 f'Number of households = {len(household_survey)} is less than the threshold = {min_households}') - 22 - 23 initial_total_weights = household_survey['popwgt'].sum() - 24 - 25 # Save the original household id - 26 household_survey['hhid_original'] = household_survey[['hhid']] - 27 - 28 # Get random ids from the household data to be duplicated - 29 ids = np.random.choice( - 30 household_survey.index, min_households - len(household_survey), replace=True) - 31 n_duplicates = pd.Series(ids).value_counts() + 1 - 32 duplicates = household_survey.loc[ids] - 33 - 34 # Adjust the weights of the duplicated households - 35 duplicates['popwgt'] = duplicates['popwgt'] / n_duplicates - 36 - 37 # Adjust the weights of the original households - 38 household_survey.loc[ids, 'popwgt'] = household_survey.loc[ids, - 39 'popwgt'] / n_duplicates - 40 - 41 # Combine the original and duplicated households - 42 household_survey = pd.concat( - 43 [household_survey, duplicates], ignore_index=True) - 44 - 45 # Check if the total weights after duplication is equal to the initial total weights - 46 # TODO: Allow for a small difference - 47 weights_after_duplication = household_survey['popwgt'].sum() - 48 if weights_after_duplication != initial_total_weights: - 49 raise ValueError( - 50 'Total weights after duplication is not equal to the initial total weights') - 51 - 52 household_survey.reset_index(drop=True, inplace=True) - 53 print( - 54 f'Number of households after duplication: {len(household_survey)}') - 55 else: - 56 return household_survey - 57 - 58 - 59def calculate_average_productivity(households: pd.DataFrame, print_statistics: bool) -> float: - 60 '''Calculate average productivity as aeinc \ k_house_ae. - 61 - 62 Args: - 63 households (pd.DataFrame): Household survey data. - 64 print_statistics (bool, optional): Whether to print the average productivity. Defaults to False. - 65 - 66 Returns: - 67 float: Average productivity. - 68 ''' - 69 # DEFF: aeinc - some type of income - 70 average_productivity = households['aeinc'] / households['k_house_ae'] - 71 - 72 # ?: What's happening here? - 73 # average_productivity = average_productivity.iloc[0] - 74 average_productivity = np.nanmedian(average_productivity) - 75 if print_statistics: - 76 print('Average productivity of capital = ' + - 77 str(np.round(average_productivity, 3))) - 78 return average_productivity - 79 - 80 - 81def adjust_assets_and_expenditure(households: pd.DataFrame, total_asset_stock: float, poverty_line: float, indigence_line: float, print_statistics: bool) -> pd.DataFrame: - 82 '''Adjust assets and expenditure of household to match data of asset damage file. - 83 - 84 There can be a mismatch between the data in the household survey and the of the asset damage. - 85 The latest was created independently. - 86 - 87 Args: - 88 households (pd.DataFrame): Household survey data. - 89 total_asset_stock (float): Total asset stock. - 90 poverty_line (float): Poverty line. - 91 indigence_line (float): Indigence line. - 92 print_statistics (bool, optional): Whether to print the statistics. Defaults to False. - 93 - 94 Returns: - 95 pd.DataFrame: Household survey data with adjusted assets and expenditure. - 96 ''' - 97 # k_house_ae - effective capital stock of the household - 98 # aeexp - adult equivalent expenditure of a household (total) - 99 # aeexp_house - data['hhexp_house'] (annual rent) / data['hhsize_ae'] -100 included_variables = ['k_house_ae', 'aeexp', 'aeexp_house'] -101 -102 # Save the initial values -103 households['k_house_ae_original'] = households['k_house_ae'] -104 households['aeexp_original'] = households['aeexp'] -105 households['aeexp_house_original'] = households['aeexp_house'] -106 -107 # Calculate the total asset in the survey -108 total_asset_in_survey = households[[ -109 'popwgt', 'k_house_ae']].prod(axis=1).sum() -110 households['total_asset_in_survey'] = total_asset_in_survey -111 -112 # Calculate the scaling factor and adjust the variables -113 scaling_factor = total_asset_stock / total_asset_in_survey -114 households[included_variables] *= scaling_factor -115 households['poverty_line_adjusted'] = poverty_line * scaling_factor -116 households['indigence_line_adjusted'] = indigence_line * scaling_factor -117 -118 if print_statistics: -119 print('Total asset in survey =', '{:,}'.format( -120 round(total_asset_in_survey))) -121 print('Total asset in asset damage file =', -122 '{:,}'.format(round(total_asset_stock))) -123 print('Scaling factor =', round(scaling_factor, 3)) -124 -125 return households -126 -127 -128def calculate_pml(households: pd.DataFrame, expected_loss_fraction: float, print_statistics: bool) -> pd.DataFrame: -129 '''Calculate probable maximum loss as a product of population weight, effective capital stock and expected loss fraction. -130 -131 Args: -132 households (pd.DataFrame): Household survey data. -133 expected_loss_fraction (float): Expected loss fraction. -134 print_statistics (bool, optional): Whether to print the statistics. Defaults to False. -135 -136 Returns: -137 pd.DataFrame: Household survey data with probable maximum loss. -138 ''' -139 # DEF: keff - effective capital stock -140 # DEF: pml - probable maximum loss -141 # DEF: popwgt - population weight of each household -142 households['keff'] = households['k_house_ae'].copy() -143 pml = households[['popwgt', 'keff']].prod( -144 axis=1).sum() * expected_loss_fraction -145 households['pml'] = pml -146 if print_statistics: -147 print('Probable maximum loss (total) : ', '{:,}'.format(round(pml))) -148 return households -149 -150 -151def select_district(household_survey: pd.DataFrame, district: str) -> pd.DataFrame: -152 '''Select households for a specific district.''' -153 return household_survey[household_survey['district'] == district].copy() -154 -155 -156def estimate_savings(households: pd.DataFrame, saving_rate: float, estimate_savings_params: dict) -> pd.DataFrame: -157 '''Estimate savings of households. -158 -159 We assume that savings are a product of expenditure and saving rate with Gaussian noise. -160 -161 Args: -162 households (pd.DataFrame): Household survey data for a specific district. -163 saving_rate (float): Saving rate. -164 estimate_savings_params (dict): Parameters for estimating savings function. -165 -166 Returns: -167 pd.DataFrame: Household survey data with estimated savings. -168 ''' -169 # * Expenditure & savings information for Saint Lucia https://www.ceicdata.com/en/saint-lucia/lending-saving-and-deposit-rates-annual/lc-savings-rate -170 -171 # Savings are a product of expenditure and saving rate -172 x = households.eval(f'aeexp*{saving_rate}') -173 -174 # Get the mean of the noise with uniform distribution -175 mean_noise_low = estimate_savings_params['mean_noise_low'] # default 0 -176 mean_noise_high = estimate_savings_params['mean_noise_high'] # default 5 -177 -178 if estimate_savings_params['mean_noise_distribution'] == 'uniform': -179 loc = np.random.uniform(mean_noise_low, mean_noise_high) -180 else: -181 raise ValueError("Only uniform distribution is supported yet.") -182 -183 # Get the scale -184 scale = estimate_savings_params['noise_scale'] # default 2.5 -185 size = households.shape[0] -186 clip_min = estimate_savings_params['savings_clip_min'] # default 0.1 -187 clip_max = estimate_savings_params['savings_clip_max'] # default 1.0 -188 -189 # Calculate savings with normal noise -190 # !: aesav can go to 0 and above 1 because of the mean noise and loc -191 # !: See `verification.ipynb` for more details -192 if estimate_savings_params['noise_distribution'] == 'normal': -193 households['aesav'] = x * \ -194 np.random.normal(loc, scale, size).round( -195 2).clip(min=clip_min, max=clip_max) -196 else: -197 ValueError("Only normal distribution is supported yet.") -198 -199 return households -200 -201 -202def set_vulnerability(households: pd.DataFrame, is_vulnerability_random: bool, set_vulnerability_params: dict) -> pd.DataFrame: -203 '''Set vulnerability of households. -204 -205 Vulnerability can be random or based on `v_init` with uniform noise. -206 -207 Args: -208 households (pd.DataFrame): Household survey data for a specific district. -209 is_vulnerability_random (bool): If True, vulnerability is random. -210 -211 Returns: -212 pd.DataFrame: Household survey data with assigned vulnerability. -213 -214 Raises: -215 ValueError: If the distribution is not supported. -216 ''' -217 -218 # If vulnerability is random, then draw from the uniform distribution -219 if is_vulnerability_random: -220 # default 0.01 -221 low = set_vulnerability_params['vulnerability_random_low'] -222 # default 0.90 -223 high = set_vulnerability_params['vulnerability_random_high'] -224 if set_vulnerability_params['vulnerability_random_distribution'] == 'uniform': -225 households['v'] = np.random.uniform(low, high, households.shape[0]) -226 else: -227 raise ValueError("Only uniform distribution is supported yet.") -228 -229 # If vulnerability is not random, use v_init as a starting point and add some noise -230 # ?: What is the point of adding the noise to the v_init if we cap it anyhow -231 else: -232 # default 0.6 -233 low = set_vulnerability_params['vulnerability_initial_low'] -234 # default 1.4 -235 high = set_vulnerability_params['vulnerability_initial_high'] -236 # v - actual vulnerability -237 # v_init - initial vulnerability -238 if set_vulnerability_params['vulnerability_initial_distribution'] == 'uniform': -239 households['v'] = households['v_init'] * \ -240 np.random.uniform(low, high, households.shape[0]) -241 else: -242 raise ValueError("Only uniform distribution is supported yet.") -243 -244 # default 0.95 -245 vulnerability_threshold = set_vulnerability_params['vulnerability_initial_threshold'] -246 -247 # If vulnerability turned out to be (drawn) is above the threshold, set it to the threshold -248 households.loc[households['v'] > -249 vulnerability_threshold, 'v'] = vulnerability_threshold -250 -251 return households -252 -253 -254def calculate_exposure(households: pd.DataFrame, poverty_bias: float, calculate_exposure_params: dict, print_statistics: bool) -> pd.DataFrame: -255 '''Calculate exposure of households. -256 -257 Exposure is a function of poverty bias, effective capital stock, -258 vulnerability and probable maximum loss. -259 -260 Args: -261 households (pd.DataFrame): Household survey data for a specific district. -262 poverty_bias (float): Poverty bias. -263 calculate_exposure_params (dict): Parameters for calculating exposure function. -264 print_statistics (bool): If True, print statistics. -265 -266 Returns: -267 pd.DataFrame: Household survey data with calculated exposure. -268 ''' -269 pml = households['pml'].iloc[0] -270 -271 # Random value for poverty bias -272 if poverty_bias == 'random': -273 # default 0.5 -274 low = calculate_exposure_params['poverty_bias_random_low'] -275 # default 1.5 -276 high = calculate_exposure_params['poverty_bias_random_high'] -277 if calculate_exposure_params['poverty_bias_random_distribution'] == 'uniform': -278 povbias = np.random.uniform(low, high) -279 else: -280 raise ValueError("Only uniform distribution is supported yet.") -281 else: -282 povbias = poverty_bias -283 -284 # Set poverty bias to 1 for all households -285 households['poverty_bias'] = 1 -286 -287 # Set poverty bias to povbias for poor households -288 households.loc[households['is_poor'] == True, 'poverty_bias'] = povbias -289 -290 # DEFF: keff - effective capital stock -291 delimiter = households[['keff', 'v', 'poverty_bias', 'popwgt']].prod( -292 axis=1).sum() -293 -294 # ?: fa - fraction affected? -295 fa0 = pml / delimiter -296 -297 # Print delimiter and fa0 with commas for thousands -298 if print_statistics: -299 print('PML: ', '{:,}'.format(round(pml, 2))) -300 print('Delimiter: ', '{:,}'.format(round(delimiter, 2))) -301 print('f0: ', '{:,}'.format(round(fa0, 2))) -302 -303 households['fa'] = fa0 * households[['poverty_bias']] -304 households.drop('poverty_bias', axis=1, inplace=True) -305 return households -306 -307 -308def determine_affected(households: pd.DataFrame, determine_affected_params: dict) -> tuple: -309 '''Determines affected households. -310 -311 We assume that all households have the same probability of being affected, -312 but based on `fa` calculated in `calculate_exposure`. -313 -314 Args: -315 households (pd.DataFrame): Household survey data for a specific district. -316 determine_affected_params (dict): Parameters for determining affected households function. -317 -318 Returns: -319 tuple: Household survey data with determined affected households and asset loss for each household. -320 -321 Raises: -322 ValueError: If total asset is less than PML. -323 ValueError: If no mask was found. -324 ''' -325 # Get PML, it is the same for all households -326 pml = households['pml'].iloc[0] -327 -328 # Allow for a relatively small error -329 delta = pml * determine_affected_params['delta_pct'] # default 0.025 -330 -331 # Check if total asset is less than PML -332 total_asset = households[['keff', 'popwgt']].prod(axis=1).sum() -333 if total_asset < pml: -334 raise ValueError( -335 'Total asset is less than PML.') -336 -337 low = determine_affected_params['low'] # default 0 -338 high = determine_affected_params['high'] # default 1 -339 -340 # Generate multiple boolean masks at once -341 num_masks = determine_affected_params['num_masks'] # default 2000 -342 masks = np.random.uniform( -343 low, high, (num_masks, households.shape[0])) <= households['fa'].values -344 -345 # Compute total_asset_loss for each mask -346 asset_losses = ( -347 masks * households[['keff', 'v', 'popwgt']].values.prod(axis=1)).sum(axis=1) -348 -349 # Find the first mask that yields a total_asset_loss within the desired range -350 mask_index = np.where((asset_losses >= pml - delta) & -351 (asset_losses <= pml + delta)) -352 -353 # Raise an error if no mask was found -354 if mask_index is None: -355 raise ValueError( -356 f'Cannot find affected households in {num_masks} iterations.') -357 else: -358 try: -359 mask_index = mask_index[0][0] -360 except: -361 print('mask_index: ', mask_index) -362 -363 chosen_mask = masks[mask_index] -364 -365 # Assign the chosen mask to the 'is_affected' column of the DataFrame -366 households['is_affected'] = chosen_mask -367 -368 # Save the asset loss for each household -369 households['asset_loss'] = households.loc[households['is_affected'], [ -370 'keff', 'v', 'popwgt']].prod(axis=1).round(2) -371 households['asset_loss'] = households['asset_loss'].fillna(0) -372 -373 return households -374 -375 -376def apply_individual_policy(households: pd.DataFrame, my_policy: str) -> tuple: -377 '''Apply a policy to a specific target group. -378 -379 Args: -380 households (pd.DataFrame): Household survey data for a specific district. -381 my_policy (str): Policy to apply. The structure of the policy is `target_group`+`top_up` in a single string. `target_group` can be `all`, `poor`, `poor_near_poor1.25`, `poor_near_poor2.0`, and the `top_up` 0, 10, 30 or 50. -382 -383 Returns: -384 tuple: Household survey data with applied policy and affected households. -385 ''' -386 -387 poverty_line_adjusted = households['poverty_line_adjusted'].iloc[0] -388 -389 target_group, top_up = my_policy.split('+') -390 top_up = float(top_up) -391 -392 # Select a target group -393 if target_group == 'all': -394 beneficiaries = households['is_affected'] == True -395 -396 # * If the target group is poor, the policy won't decrease the number of new poor -397 elif target_group == 'poor': -398 beneficiaries = (households['is_affected'] == True) & ( -399 households['is_poor'] == True) -400 -401 elif target_group == 'poor_near_poor1.25': -402 poor_affected = (households['is_affected'] == True) & ( -403 households['is_poor'] == True) -404 near_poor_affected = (households['is_affected'] == True) & ( -405 households['is_poor'] == False) & (households['aeexp'] < 1.25 * poverty_line_adjusted) -406 beneficiaries = poor_affected | near_poor_affected -407 -408 elif target_group == 'poor_near_poor2.0': -409 poor_affected = (households['is_affected'] == True) & ( -410 households['is_poor'] == True) -411 near_poor_affected = (households['is_affected'] == True) & ( -412 households['is_poor'] == False) & (households['aeexp'] < 2 * poverty_line_adjusted) -413 beneficiaries = poor_affected | near_poor_affected -414 -415 # * Here we have to decide to what to add to aeexp or aesav -416 households.loc[beneficiaries, -417 'aesav'] += households.loc[beneficiaries].eval('keff*v') * top_up / 100 -418 -419 # Select columns of interest -420 columns_of_interest = ['hhid', 'popwgt', 'own_rent', 'quintile', 'aeexp', -421 'aeexp_house', 'keff', 'v', 'aesav', 'aesoc', 'delta_tax_safety'] -422 affected_households = households.loc[households['is_affected'], -423 columns_of_interest].copy() -424 return households, affected_households -
6def duplicate_households(household_survey: pd.DataFrame, min_households: int) -> pd.DataFrame: - 7 '''Duplicates households if the number of households is less than `min_households` threshold. - 8 - 9 Args: -10 household_survey (pd.DataFrame): Household survey data. -11 min_households (int): Minimum number of households. -12 -13 Returns: -14 pd.DataFrame: Household survey data with duplicated households. -15 -16 Raises: -17 ValueError: If the total weights after duplication is not equal to the initial total weights. -18 ''' -19 -20 if len(household_survey) < min_households: -21 print( -22 f'Number of households = {len(household_survey)} is less than the threshold = {min_households}') -23 -24 initial_total_weights = household_survey['popwgt'].sum() -25 -26 # Save the original household id -27 household_survey['hhid_original'] = household_survey[['hhid']] -28 -29 # Get random ids from the household data to be duplicated -30 ids = np.random.choice( -31 household_survey.index, min_households - len(household_survey), replace=True) -32 n_duplicates = pd.Series(ids).value_counts() + 1 -33 duplicates = household_survey.loc[ids] -34 -35 # Adjust the weights of the duplicated households -36 duplicates['popwgt'] = duplicates['popwgt'] / n_duplicates -37 -38 # Adjust the weights of the original households -39 household_survey.loc[ids, 'popwgt'] = household_survey.loc[ids, -40 'popwgt'] / n_duplicates -41 -42 # Combine the original and duplicated households -43 household_survey = pd.concat( -44 [household_survey, duplicates], ignore_index=True) -45 -46 # Check if the total weights after duplication is equal to the initial total weights -47 # TODO: Allow for a small difference -48 weights_after_duplication = household_survey['popwgt'].sum() -49 if weights_after_duplication != initial_total_weights: -50 raise ValueError( -51 'Total weights after duplication is not equal to the initial total weights') -52 -53 household_survey.reset_index(drop=True, inplace=True) -54 print( -55 f'Number of households after duplication: {len(household_survey)}') -56 else: -57 return household_survey -
Duplicates households if the number of households is less than min_households
threshold.
Args: - household_survey (pd.DataFrame): Household survey data. - min_households (int): Minimum number of households.
- -Returns: - pd.DataFrame: Household survey data with duplicated households.
- -Raises: - ValueError: If the total weights after duplication is not equal to the initial total weights.
-60def calculate_average_productivity(households: pd.DataFrame, print_statistics: bool) -> float: -61 '''Calculate average productivity as aeinc \ k_house_ae. -62 -63 Args: -64 households (pd.DataFrame): Household survey data. -65 print_statistics (bool, optional): Whether to print the average productivity. Defaults to False. -66 -67 Returns: -68 float: Average productivity. -69 ''' -70 # DEFF: aeinc - some type of income -71 average_productivity = households['aeinc'] / households['k_house_ae'] -72 -73 # ?: What's happening here? -74 # average_productivity = average_productivity.iloc[0] -75 average_productivity = np.nanmedian(average_productivity) -76 if print_statistics: -77 print('Average productivity of capital = ' + -78 str(np.round(average_productivity, 3))) -79 return average_productivity -
Calculate average productivity as aeinc \ k_house_ae.
- -Args: - households (pd.DataFrame): Household survey data. - print_statistics (bool, optional): Whether to print the average productivity. Defaults to False.
- -Returns: - float: Average productivity.
-82def adjust_assets_and_expenditure(households: pd.DataFrame, total_asset_stock: float, poverty_line: float, indigence_line: float, print_statistics: bool) -> pd.DataFrame: - 83 '''Adjust assets and expenditure of household to match data of asset damage file. - 84 - 85 There can be a mismatch between the data in the household survey and the of the asset damage. - 86 The latest was created independently. - 87 - 88 Args: - 89 households (pd.DataFrame): Household survey data. - 90 total_asset_stock (float): Total asset stock. - 91 poverty_line (float): Poverty line. - 92 indigence_line (float): Indigence line. - 93 print_statistics (bool, optional): Whether to print the statistics. Defaults to False. - 94 - 95 Returns: - 96 pd.DataFrame: Household survey data with adjusted assets and expenditure. - 97 ''' - 98 # k_house_ae - effective capital stock of the household - 99 # aeexp - adult equivalent expenditure of a household (total) -100 # aeexp_house - data['hhexp_house'] (annual rent) / data['hhsize_ae'] -101 included_variables = ['k_house_ae', 'aeexp', 'aeexp_house'] -102 -103 # Save the initial values -104 households['k_house_ae_original'] = households['k_house_ae'] -105 households['aeexp_original'] = households['aeexp'] -106 households['aeexp_house_original'] = households['aeexp_house'] -107 -108 # Calculate the total asset in the survey -109 total_asset_in_survey = households[[ -110 'popwgt', 'k_house_ae']].prod(axis=1).sum() -111 households['total_asset_in_survey'] = total_asset_in_survey -112 -113 # Calculate the scaling factor and adjust the variables -114 scaling_factor = total_asset_stock / total_asset_in_survey -115 households[included_variables] *= scaling_factor -116 households['poverty_line_adjusted'] = poverty_line * scaling_factor -117 households['indigence_line_adjusted'] = indigence_line * scaling_factor -118 -119 if print_statistics: -120 print('Total asset in survey =', '{:,}'.format( -121 round(total_asset_in_survey))) -122 print('Total asset in asset damage file =', -123 '{:,}'.format(round(total_asset_stock))) -124 print('Scaling factor =', round(scaling_factor, 3)) -125 -126 return households -
Adjust assets and expenditure of household to match data of asset damage file.
- -There can be a mismatch between the data in the household survey and the of the asset damage. -The latest was created independently.
- -Args: - households (pd.DataFrame): Household survey data. - total_asset_stock (float): Total asset stock. - poverty_line (float): Poverty line. - indigence_line (float): Indigence line. - print_statistics (bool, optional): Whether to print the statistics. Defaults to False.
- -Returns: - pd.DataFrame: Household survey data with adjusted assets and expenditure.
-129def calculate_pml(households: pd.DataFrame, expected_loss_fraction: float, print_statistics: bool) -> pd.DataFrame: -130 '''Calculate probable maximum loss as a product of population weight, effective capital stock and expected loss fraction. -131 -132 Args: -133 households (pd.DataFrame): Household survey data. -134 expected_loss_fraction (float): Expected loss fraction. -135 print_statistics (bool, optional): Whether to print the statistics. Defaults to False. -136 -137 Returns: -138 pd.DataFrame: Household survey data with probable maximum loss. -139 ''' -140 # DEF: keff - effective capital stock -141 # DEF: pml - probable maximum loss -142 # DEF: popwgt - population weight of each household -143 households['keff'] = households['k_house_ae'].copy() -144 pml = households[['popwgt', 'keff']].prod( -145 axis=1).sum() * expected_loss_fraction -146 households['pml'] = pml -147 if print_statistics: -148 print('Probable maximum loss (total) : ', '{:,}'.format(round(pml))) -149 return households -
Calculate probable maximum loss as a product of population weight, effective capital stock and expected loss fraction.
- -Args: - households (pd.DataFrame): Household survey data. - expected_loss_fraction (float): Expected loss fraction. - print_statistics (bool, optional): Whether to print the statistics. Defaults to False.
- -Returns: - pd.DataFrame: Household survey data with probable maximum loss.
-152def select_district(household_survey: pd.DataFrame, district: str) -> pd.DataFrame: -153 '''Select households for a specific district.''' -154 return household_survey[household_survey['district'] == district].copy() -
Select households for a specific district.
-157def estimate_savings(households: pd.DataFrame, saving_rate: float, estimate_savings_params: dict) -> pd.DataFrame: -158 '''Estimate savings of households. -159 -160 We assume that savings are a product of expenditure and saving rate with Gaussian noise. -161 -162 Args: -163 households (pd.DataFrame): Household survey data for a specific district. -164 saving_rate (float): Saving rate. -165 estimate_savings_params (dict): Parameters for estimating savings function. -166 -167 Returns: -168 pd.DataFrame: Household survey data with estimated savings. -169 ''' -170 # * Expenditure & savings information for Saint Lucia https://www.ceicdata.com/en/saint-lucia/lending-saving-and-deposit-rates-annual/lc-savings-rate -171 -172 # Savings are a product of expenditure and saving rate -173 x = households.eval(f'aeexp*{saving_rate}') -174 -175 # Get the mean of the noise with uniform distribution -176 mean_noise_low = estimate_savings_params['mean_noise_low'] # default 0 -177 mean_noise_high = estimate_savings_params['mean_noise_high'] # default 5 -178 -179 if estimate_savings_params['mean_noise_distribution'] == 'uniform': -180 loc = np.random.uniform(mean_noise_low, mean_noise_high) -181 else: -182 raise ValueError("Only uniform distribution is supported yet.") -183 -184 # Get the scale -185 scale = estimate_savings_params['noise_scale'] # default 2.5 -186 size = households.shape[0] -187 clip_min = estimate_savings_params['savings_clip_min'] # default 0.1 -188 clip_max = estimate_savings_params['savings_clip_max'] # default 1.0 -189 -190 # Calculate savings with normal noise -191 # !: aesav can go to 0 and above 1 because of the mean noise and loc -192 # !: See `verification.ipynb` for more details -193 if estimate_savings_params['noise_distribution'] == 'normal': -194 households['aesav'] = x * \ -195 np.random.normal(loc, scale, size).round( -196 2).clip(min=clip_min, max=clip_max) -197 else: -198 ValueError("Only normal distribution is supported yet.") -199 -200 return households -
Estimate savings of households.
- -We assume that savings are a product of expenditure and saving rate with Gaussian noise.
- -Args: - households (pd.DataFrame): Household survey data for a specific district. - saving_rate (float): Saving rate. - estimate_savings_params (dict): Parameters for estimating savings function.
- -Returns: - pd.DataFrame: Household survey data with estimated savings.
-203def set_vulnerability(households: pd.DataFrame, is_vulnerability_random: bool, set_vulnerability_params: dict) -> pd.DataFrame: -204 '''Set vulnerability of households. -205 -206 Vulnerability can be random or based on `v_init` with uniform noise. -207 -208 Args: -209 households (pd.DataFrame): Household survey data for a specific district. -210 is_vulnerability_random (bool): If True, vulnerability is random. -211 -212 Returns: -213 pd.DataFrame: Household survey data with assigned vulnerability. -214 -215 Raises: -216 ValueError: If the distribution is not supported. -217 ''' -218 -219 # If vulnerability is random, then draw from the uniform distribution -220 if is_vulnerability_random: -221 # default 0.01 -222 low = set_vulnerability_params['vulnerability_random_low'] -223 # default 0.90 -224 high = set_vulnerability_params['vulnerability_random_high'] -225 if set_vulnerability_params['vulnerability_random_distribution'] == 'uniform': -226 households['v'] = np.random.uniform(low, high, households.shape[0]) -227 else: -228 raise ValueError("Only uniform distribution is supported yet.") -229 -230 # If vulnerability is not random, use v_init as a starting point and add some noise -231 # ?: What is the point of adding the noise to the v_init if we cap it anyhow -232 else: -233 # default 0.6 -234 low = set_vulnerability_params['vulnerability_initial_low'] -235 # default 1.4 -236 high = set_vulnerability_params['vulnerability_initial_high'] -237 # v - actual vulnerability -238 # v_init - initial vulnerability -239 if set_vulnerability_params['vulnerability_initial_distribution'] == 'uniform': -240 households['v'] = households['v_init'] * \ -241 np.random.uniform(low, high, households.shape[0]) -242 else: -243 raise ValueError("Only uniform distribution is supported yet.") -244 -245 # default 0.95 -246 vulnerability_threshold = set_vulnerability_params['vulnerability_initial_threshold'] -247 -248 # If vulnerability turned out to be (drawn) is above the threshold, set it to the threshold -249 households.loc[households['v'] > -250 vulnerability_threshold, 'v'] = vulnerability_threshold -251 -252 return households -
Set vulnerability of households.
- -Vulnerability can be random or based on v_init
with uniform noise.
Args: - households (pd.DataFrame): Household survey data for a specific district. - is_vulnerability_random (bool): If True, vulnerability is random.
- -Returns: - pd.DataFrame: Household survey data with assigned vulnerability.
- -Raises: - ValueError: If the distribution is not supported.
-255def calculate_exposure(households: pd.DataFrame, poverty_bias: float, calculate_exposure_params: dict, print_statistics: bool) -> pd.DataFrame: -256 '''Calculate exposure of households. -257 -258 Exposure is a function of poverty bias, effective capital stock, -259 vulnerability and probable maximum loss. -260 -261 Args: -262 households (pd.DataFrame): Household survey data for a specific district. -263 poverty_bias (float): Poverty bias. -264 calculate_exposure_params (dict): Parameters for calculating exposure function. -265 print_statistics (bool): If True, print statistics. -266 -267 Returns: -268 pd.DataFrame: Household survey data with calculated exposure. -269 ''' -270 pml = households['pml'].iloc[0] -271 -272 # Random value for poverty bias -273 if poverty_bias == 'random': -274 # default 0.5 -275 low = calculate_exposure_params['poverty_bias_random_low'] -276 # default 1.5 -277 high = calculate_exposure_params['poverty_bias_random_high'] -278 if calculate_exposure_params['poverty_bias_random_distribution'] == 'uniform': -279 povbias = np.random.uniform(low, high) -280 else: -281 raise ValueError("Only uniform distribution is supported yet.") -282 else: -283 povbias = poverty_bias -284 -285 # Set poverty bias to 1 for all households -286 households['poverty_bias'] = 1 -287 -288 # Set poverty bias to povbias for poor households -289 households.loc[households['is_poor'] == True, 'poverty_bias'] = povbias -290 -291 # DEFF: keff - effective capital stock -292 delimiter = households[['keff', 'v', 'poverty_bias', 'popwgt']].prod( -293 axis=1).sum() -294 -295 # ?: fa - fraction affected? -296 fa0 = pml / delimiter -297 -298 # Print delimiter and fa0 with commas for thousands -299 if print_statistics: -300 print('PML: ', '{:,}'.format(round(pml, 2))) -301 print('Delimiter: ', '{:,}'.format(round(delimiter, 2))) -302 print('f0: ', '{:,}'.format(round(fa0, 2))) -303 -304 households['fa'] = fa0 * households[['poverty_bias']] -305 households.drop('poverty_bias', axis=1, inplace=True) -306 return households -
Calculate exposure of households.
- -Exposure is a function of poverty bias, effective capital stock, -vulnerability and probable maximum loss.
- -Args: - households (pd.DataFrame): Household survey data for a specific district. - poverty_bias (float): Poverty bias. - calculate_exposure_params (dict): Parameters for calculating exposure function. - print_statistics (bool): If True, print statistics.
- -Returns: - pd.DataFrame: Household survey data with calculated exposure.
-309def determine_affected(households: pd.DataFrame, determine_affected_params: dict) -> tuple: -310 '''Determines affected households. -311 -312 We assume that all households have the same probability of being affected, -313 but based on `fa` calculated in `calculate_exposure`. -314 -315 Args: -316 households (pd.DataFrame): Household survey data for a specific district. -317 determine_affected_params (dict): Parameters for determining affected households function. -318 -319 Returns: -320 tuple: Household survey data with determined affected households and asset loss for each household. -321 -322 Raises: -323 ValueError: If total asset is less than PML. -324 ValueError: If no mask was found. -325 ''' -326 # Get PML, it is the same for all households -327 pml = households['pml'].iloc[0] -328 -329 # Allow for a relatively small error -330 delta = pml * determine_affected_params['delta_pct'] # default 0.025 -331 -332 # Check if total asset is less than PML -333 total_asset = households[['keff', 'popwgt']].prod(axis=1).sum() -334 if total_asset < pml: -335 raise ValueError( -336 'Total asset is less than PML.') -337 -338 low = determine_affected_params['low'] # default 0 -339 high = determine_affected_params['high'] # default 1 -340 -341 # Generate multiple boolean masks at once -342 num_masks = determine_affected_params['num_masks'] # default 2000 -343 masks = np.random.uniform( -344 low, high, (num_masks, households.shape[0])) <= households['fa'].values -345 -346 # Compute total_asset_loss for each mask -347 asset_losses = ( -348 masks * households[['keff', 'v', 'popwgt']].values.prod(axis=1)).sum(axis=1) -349 -350 # Find the first mask that yields a total_asset_loss within the desired range -351 mask_index = np.where((asset_losses >= pml - delta) & -352 (asset_losses <= pml + delta)) -353 -354 # Raise an error if no mask was found -355 if mask_index is None: -356 raise ValueError( -357 f'Cannot find affected households in {num_masks} iterations.') -358 else: -359 try: -360 mask_index = mask_index[0][0] -361 except: -362 print('mask_index: ', mask_index) -363 -364 chosen_mask = masks[mask_index] -365 -366 # Assign the chosen mask to the 'is_affected' column of the DataFrame -367 households['is_affected'] = chosen_mask -368 -369 # Save the asset loss for each household -370 households['asset_loss'] = households.loc[households['is_affected'], [ -371 'keff', 'v', 'popwgt']].prod(axis=1).round(2) -372 households['asset_loss'] = households['asset_loss'].fillna(0) -373 -374 return households -
Determines affected households.
- -We assume that all households have the same probability of being affected,
-but based on fa
calculated in calculate_exposure
.
Args: - households (pd.DataFrame): Household survey data for a specific district. - determine_affected_params (dict): Parameters for determining affected households function.
- -Returns: - tuple: Household survey data with determined affected households and asset loss for each household.
- -Raises: - ValueError: If total asset is less than PML. - ValueError: If no mask was found.
-377def apply_individual_policy(households: pd.DataFrame, my_policy: str) -> tuple: -378 '''Apply a policy to a specific target group. -379 -380 Args: -381 households (pd.DataFrame): Household survey data for a specific district. -382 my_policy (str): Policy to apply. The structure of the policy is `target_group`+`top_up` in a single string. `target_group` can be `all`, `poor`, `poor_near_poor1.25`, `poor_near_poor2.0`, and the `top_up` 0, 10, 30 or 50. -383 -384 Returns: -385 tuple: Household survey data with applied policy and affected households. -386 ''' -387 -388 poverty_line_adjusted = households['poverty_line_adjusted'].iloc[0] -389 -390 target_group, top_up = my_policy.split('+') -391 top_up = float(top_up) -392 -393 # Select a target group -394 if target_group == 'all': -395 beneficiaries = households['is_affected'] == True -396 -397 # * If the target group is poor, the policy won't decrease the number of new poor -398 elif target_group == 'poor': -399 beneficiaries = (households['is_affected'] == True) & ( -400 households['is_poor'] == True) -401 -402 elif target_group == 'poor_near_poor1.25': -403 poor_affected = (households['is_affected'] == True) & ( -404 households['is_poor'] == True) -405 near_poor_affected = (households['is_affected'] == True) & ( -406 households['is_poor'] == False) & (households['aeexp'] < 1.25 * poverty_line_adjusted) -407 beneficiaries = poor_affected | near_poor_affected -408 -409 elif target_group == 'poor_near_poor2.0': -410 poor_affected = (households['is_affected'] == True) & ( -411 households['is_poor'] == True) -412 near_poor_affected = (households['is_affected'] == True) & ( -413 households['is_poor'] == False) & (households['aeexp'] < 2 * poverty_line_adjusted) -414 beneficiaries = poor_affected | near_poor_affected -415 -416 # * Here we have to decide to what to add to aeexp or aesav -417 households.loc[beneficiaries, -418 'aesav'] += households.loc[beneficiaries].eval('keff*v') * top_up / 100 -419 -420 # Select columns of interest -421 columns_of_interest = ['hhid', 'popwgt', 'own_rent', 'quintile', 'aeexp', -422 'aeexp_house', 'keff', 'v', 'aesav', 'aesoc', 'delta_tax_safety'] -423 affected_households = households.loc[households['is_affected'], -424 columns_of_interest].copy() -425 return households, affected_households -
Apply a policy to a specific target group.
- -Args:
- households (pd.DataFrame): Household survey data for a specific district.
- my_policy (str): Policy to apply. The structure of the policy is target_group
+top_up
in a single string. target_group
can be all
, poor
, poor_near_poor1.25
, poor_near_poor2.0
, and the top_up
0, 10, 30 or 50.
Returns: - tuple: Household survey data with applied policy and affected households.
-1import numpy as np - 2import pandas as pd - 3import pickle - 4 - 5 - 6def run_optimization(affected_households: pd.DataFrame, consumption_utility: float, discount_rate: float, average_productivity: float, optimization_timestep: float, n_years: int) -> pd.DataFrame: - 7 '''This function calculates the recovery rate for each affected household. - 8 - 9 Args: - 10 affected_households (pd.DataFrame): A data frame containing the affected households. - 11 consumption_utility (float): The coefficient of relative risk aversion. - 12 discount_rate (float): The discount rate. - 13 average_productivity (float): The average productivity. - 14 optimization_timestep (float): The timestep for the optimization. - 15 n_years (int): The number of years in the optimization algorithm. - 16 - 17 Returns: - 18 pd.DataFrame: A data frame containing the affected households with the recovery rate. - 19 ''' - 20 - 21 # Set effective capital stock to zero for renters - 22 affected_households.loc[affected_households['own_rent'] - 23 == 'rent', 'keff'] = 0 # V - 24 - 25 # Prepare a data frame to store optimization results - 26 optimization_results = pd.DataFrame({'aeexp': -1, - 27 'aeexp_house': -1, - 28 'keff': -1, - 29 'v': -1, - 30 'aesav': -1, - 31 'solution': None, - 32 'bankrupt': None}, index=[0]) - 33 - 34 optimization_results = optimization_results.reset_index(drop=True).set_index( - 35 ['aeexp', - 36 'aeexp_house', - 37 'keff', - 38 'v', - 39 'aesav']) - 40 - 41 # Calculate the recovery rate for each affected household - 42 affected_households['recovery_rate'] = affected_households['v'].apply( - 43 lambda x: optimize_recovery_rate(x, optimization_results, consumption_utility, discount_rate, average_productivity, optimization_timestep, n_years)) - 44 - 45 # TODO: Check whether this has any impact on anything - 46 # optimization_results = optimization_results.sort_index() - 47 - 48 return affected_households - 49 - 50 - 51def optimize_recovery_rate(x, optimization_results: pd.DataFrame, consumption_utility: float, discount_rate: float, average_productivity: float, optimization_timestep: float, n_years: int) -> float: - 52 try: - 53 # Look for the existing solution - 54 solution = optimization_results.loc[( - 55 0, 0, 0, round(x, 3), round(average_productivity, 3)), 'solution'] - 56 return solution - 57 except: - 58 # No existing solution found, so we need to optimize - 59 t_max_linspace = n_years # years - 60 nsteps_linspace = 52 * t_max_linspace # total weeks - 61 dt = t_max_linspace / nsteps_linspace - 62 - 63 _lambda = 0 - 64 opt_step = optimization_timestep - 65 last_dwdlambda = 0 - 66 - 67 while True: - 68 - 69 dwdlambda = 0 - 70 - 71 for _t in np.linspace(0, t_max_linspace, nsteps_linspace): - 72 - 73 part1 = average_productivity - \ - 74 (average_productivity+_lambda)*x*np.e**(-_lambda*_t) - 75 part1 = part1**(-consumption_utility) - 76 - 77 part2 = _t * (average_productivity+_lambda) - 1 - 78 - 79 part3 = np.e**(-_t*(discount_rate+_lambda)) - 80 - 81 dwdlambda += part1 * part2 * part3 * dt - 82 - 83 # !: All these do the same - 84 if last_dwdlambda < 0 and dwdlambda > 0: - 85 optimization_results.loc[(0, 0, 0, round(x, 3), round(average_productivity, 3)), [ - 86 'solution', 'bankrupt']] = [_lambda, False] - 87 optimization_results = optimization_results.sort_index() - 88 return _lambda - 89 - 90 elif last_dwdlambda > 0 and dwdlambda < 0: - 91 optimization_results.loc[(0, 0, 0, round(x, 3), round(average_productivity, 3)), [ - 92 'solution', 'bankrupt']] = [_lambda, False] - 93 optimization_results = optimization_results.sort_index() - 94 return _lambda - 95 - 96 # !: That's why assigning more than 10 years does not work, we need to change 10 to `n_years`? - 97 elif _lambda > 10: - 98 optimization_results.loc[(0, 0, 0, round(x, 3), round(average_productivity, 3)), [ - 99 'solution', 'bankrupt']] = [_lambda, False] -100 optimization_results = optimization_results.sort_index() -101 return _lambda -102 -103 else: -104 last_dwdlambda = dwdlambda -105 _lambda += opt_step -106 -107 -108def integrate_wellbeing(affected_households: pd.DataFrame, -109 consumption_utility: float, -110 discount_rate: float, -111 income_and_expenditure_growth: float, -112 average_productivity: float, -113 poverty_line: float, -114 n_years: int, -115 add_income_loss: bool, -116 cash_transfer: dict = {}, -117 ) -> pd.DataFrame: -118 -119 # We need to reset some columns to zero to start the integration -120 columns = ['consumption_loss', 'consumption_loss_NPV', 'net_consumption_loss', -121 'net_consumption_loss_NPV', 'c_t', 'w_final', 'weeks_pov', 'w_final2'] -122 affected_households[columns] = [0., 0., 0., 0., 0., 0., 0., 0.] -123 -124 # Define the number of weeks given the number of years -125 n_weeks = 52 * n_years -126 dt = n_years / n_weeks -127 -128 # * Store consumption recovery in a dict for verification and debugging purposes -129 # consumption_recovery = {} -130 -131 # We need to adjust the cash transfer to the timestep of the integration -132 if cash_transfer != {}: # If there is a cash transfer -133 cash_transfer_transformed = {np.linspace(0, n_years, n_weeks)[ -134 t]: cash_transfer[t] for t in list(cash_transfer.keys())} -135 else: -136 cash_transfer_transformed = {} -137 -138 # Calculate the consumption loss for each affected household -139 for _t in np.linspace(0, n_years, n_weeks): -140 gfac = (1 + income_and_expenditure_growth)**_t -141 -142 # TODO: Add an extra condition about to whom the transfer is given -143 # A "dynamic policy" -144 if _t in list(cash_transfer_transformed.keys()): -145 affected_households['aesav'] += cash_transfer_transformed[_t] -146 -147 # `c_t` is the consumption at time t -148 # !: It seems that keff remains constant over time -149 expenditure_growth = gfac * affected_households['aeexp'] -150 exponential_multiplier = np.e**( -151 -affected_households['recovery_rate']*_t) -152 savings = gfac * \ -153 affected_households['aesav'] * affected_households['recovery_rate'] -154 asset_damage = gfac * \ -155 affected_households['v'] * \ -156 affected_households[['keff', 'recovery_rate']].prod(axis=1) -157 -158 # TODO: Make sure that `delta_tax_safety` is not 0 -159 income_loss = gfac * (1 - affected_households['delta_tax_safety']) * \ -160 average_productivity * \ -161 affected_households['keff'] * affected_households['v'] -162 -163 # Equation is as follows: consumption_loss = expenditure_growth + exponential_multiplier * (savings - asset_damage - income_loss) -164 -165 if add_income_loss: -166 affected_households['c_t'] = (expenditure_growth + -167 exponential_multiplier * (savings - asset_damage - income_loss)) -168 else: -169 affected_households['c_t'] = (expenditure_growth + -170 exponential_multiplier * (savings - asset_damage)) -171 -172 # affected_households['c_t'] = (gfac * affected_households['aeexp'] # expenditure growth -173 -174 # + np.e**(-affected_households['recovery_rate']*_t) # exponential multiplier -175 -176 # * (gfac * affected_households['aesav'] * affected_households['recovery_rate'] # savings -177 # - gfac * affected_households['v'] * affected_households[['keff', 'recovery_rate']].prod(axis=1))) # asset damage -178 -179 # # - (1 - affected_households['delta_tax_safety']) # income loss -180 # # * average_productivity * affected_households['keff'] -181 # # * affected_households['v'])) -182 -183 # `c_t_unaffected` is the consumption at time t if the household was not affected by the disaster -184 affected_households['c_t_unaffected'] = gfac * \ -185 affected_households['aeexp'] -186 -187 # TODO: Add a check to see whether the consumption goes below 0 -188 -189 # Consumption cannot be lower than 0 -190 affected_households.loc[affected_households['c_t'] < 1, 'c_t'] = 1 -191 -192 # TODO: Add a check whether the consumption after hit by disaster should be lower than or equal to consumption before hit by disaster -193 -194 # consumption after hit by disaster should be lower than or equal to consumption before hit by disaster -195 affected_households.loc[affected_households['c_t'] > affected_households['c_t_unaffected'], -196 'c_t'] = affected_households.loc[affected_households['c_t'] > affected_households['c_t_unaffected'], 'c_t_unaffected'] -197 -198 # total (integrated) consumption loss -199 affected_households['consumption_loss'] += dt * \ -200 (affected_households['c_t_unaffected'] - -201 affected_households['c_t']) -202 -203 affected_households['consumption_loss_NPV'] += dt * \ -204 (affected_households['c_t_unaffected'] - -205 affected_households['c_t'])*np.e**(-discount_rate*_t) -206 -207 affected_households['net_consumption_loss'] += dt * \ -208 np.e**(-affected_households['recovery_rate']*_t) * \ -209 affected_households['v']*gfac * \ -210 affected_households['aeexp_house'] -211 -212 affected_households['net_consumption_loss_NPV'] += dt * \ -213 np.e**(-affected_households['recovery_rate']*_t) * affected_households['v']*gfac * \ -214 affected_households['aeexp_house'] * \ -215 np.e**(-discount_rate*_t) -216 -217 # Increase the number of weeks in poverty -218 affected_households.loc[affected_households['c_t'] -219 < poverty_line, 'weeks_pov'] += 1 -220 -221 # Integrated wellbeing -222 affected_households['w_final'] += dt*(affected_households['c_t'])**(1-consumption_utility) * \ -223 np.e**(-discount_rate*_t)/(1-consumption_utility) -224 -225 # w_final2 version 02 -226 affected_households['w_final2'] += affected_households['c_t_unaffected']**(1-consumption_utility)/(1-consumption_utility)*dt*( -227 (1-((affected_households['c_t_unaffected'] - affected_households['c_t'])/affected_households['c_t_unaffected'])*np.e**(-affected_households['recovery_rate']*_t))**(1-consumption_utility)-1)*np.e**(-discount_rate*_t) -228 -229 # * Use to examine individual consumption recovery -230 # Save consumption recovery value at the time _t -231 # consumption_recovery[_t] = affected_households['c_t'] -232 -233 # Save consumption recovery as pickle file -234 # with open('consumption_recovery.pickle', 'wb') as handle: -235 # pickle.dump(consumption_recovery, handle, protocol=pickle.HIGHEST_PROTOCOL) -236 -237 return affected_households -
7def run_optimization(affected_households: pd.DataFrame, consumption_utility: float, discount_rate: float, average_productivity: float, optimization_timestep: float, n_years: int) -> pd.DataFrame: - 8 '''This function calculates the recovery rate for each affected household. - 9 -10 Args: -11 affected_households (pd.DataFrame): A data frame containing the affected households. -12 consumption_utility (float): The coefficient of relative risk aversion. -13 discount_rate (float): The discount rate. -14 average_productivity (float): The average productivity. -15 optimization_timestep (float): The timestep for the optimization. -16 n_years (int): The number of years in the optimization algorithm. -17 -18 Returns: -19 pd.DataFrame: A data frame containing the affected households with the recovery rate. -20 ''' -21 -22 # Set effective capital stock to zero for renters -23 affected_households.loc[affected_households['own_rent'] -24 == 'rent', 'keff'] = 0 # V -25 -26 # Prepare a data frame to store optimization results -27 optimization_results = pd.DataFrame({'aeexp': -1, -28 'aeexp_house': -1, -29 'keff': -1, -30 'v': -1, -31 'aesav': -1, -32 'solution': None, -33 'bankrupt': None}, index=[0]) -34 -35 optimization_results = optimization_results.reset_index(drop=True).set_index( -36 ['aeexp', -37 'aeexp_house', -38 'keff', -39 'v', -40 'aesav']) -41 -42 # Calculate the recovery rate for each affected household -43 affected_households['recovery_rate'] = affected_households['v'].apply( -44 lambda x: optimize_recovery_rate(x, optimization_results, consumption_utility, discount_rate, average_productivity, optimization_timestep, n_years)) -45 -46 # TODO: Check whether this has any impact on anything -47 # optimization_results = optimization_results.sort_index() -48 -49 return affected_households -
This function calculates the recovery rate for each affected household.
- -Args: - affected_households (pd.DataFrame): A data frame containing the affected households. - consumption_utility (float): The coefficient of relative risk aversion. - discount_rate (float): The discount rate. - average_productivity (float): The average productivity. - optimization_timestep (float): The timestep for the optimization. - n_years (int): The number of years in the optimization algorithm.
- -Returns: - pd.DataFrame: A data frame containing the affected households with the recovery rate.
-52def optimize_recovery_rate(x, optimization_results: pd.DataFrame, consumption_utility: float, discount_rate: float, average_productivity: float, optimization_timestep: float, n_years: int) -> float: - 53 try: - 54 # Look for the existing solution - 55 solution = optimization_results.loc[( - 56 0, 0, 0, round(x, 3), round(average_productivity, 3)), 'solution'] - 57 return solution - 58 except: - 59 # No existing solution found, so we need to optimize - 60 t_max_linspace = n_years # years - 61 nsteps_linspace = 52 * t_max_linspace # total weeks - 62 dt = t_max_linspace / nsteps_linspace - 63 - 64 _lambda = 0 - 65 opt_step = optimization_timestep - 66 last_dwdlambda = 0 - 67 - 68 while True: - 69 - 70 dwdlambda = 0 - 71 - 72 for _t in np.linspace(0, t_max_linspace, nsteps_linspace): - 73 - 74 part1 = average_productivity - \ - 75 (average_productivity+_lambda)*x*np.e**(-_lambda*_t) - 76 part1 = part1**(-consumption_utility) - 77 - 78 part2 = _t * (average_productivity+_lambda) - 1 - 79 - 80 part3 = np.e**(-_t*(discount_rate+_lambda)) - 81 - 82 dwdlambda += part1 * part2 * part3 * dt - 83 - 84 # !: All these do the same - 85 if last_dwdlambda < 0 and dwdlambda > 0: - 86 optimization_results.loc[(0, 0, 0, round(x, 3), round(average_productivity, 3)), [ - 87 'solution', 'bankrupt']] = [_lambda, False] - 88 optimization_results = optimization_results.sort_index() - 89 return _lambda - 90 - 91 elif last_dwdlambda > 0 and dwdlambda < 0: - 92 optimization_results.loc[(0, 0, 0, round(x, 3), round(average_productivity, 3)), [ - 93 'solution', 'bankrupt']] = [_lambda, False] - 94 optimization_results = optimization_results.sort_index() - 95 return _lambda - 96 - 97 # !: That's why assigning more than 10 years does not work, we need to change 10 to `n_years`? - 98 elif _lambda > 10: - 99 optimization_results.loc[(0, 0, 0, round(x, 3), round(average_productivity, 3)), [ -100 'solution', 'bankrupt']] = [_lambda, False] -101 optimization_results = optimization_results.sort_index() -102 return _lambda -103 -104 else: -105 last_dwdlambda = dwdlambda -106 _lambda += opt_step -
109def integrate_wellbeing(affected_households: pd.DataFrame, -110 consumption_utility: float, -111 discount_rate: float, -112 income_and_expenditure_growth: float, -113 average_productivity: float, -114 poverty_line: float, -115 n_years: int, -116 add_income_loss: bool, -117 cash_transfer: dict = {}, -118 ) -> pd.DataFrame: -119 -120 # We need to reset some columns to zero to start the integration -121 columns = ['consumption_loss', 'consumption_loss_NPV', 'net_consumption_loss', -122 'net_consumption_loss_NPV', 'c_t', 'w_final', 'weeks_pov', 'w_final2'] -123 affected_households[columns] = [0., 0., 0., 0., 0., 0., 0., 0.] -124 -125 # Define the number of weeks given the number of years -126 n_weeks = 52 * n_years -127 dt = n_years / n_weeks -128 -129 # * Store consumption recovery in a dict for verification and debugging purposes -130 # consumption_recovery = {} -131 -132 # We need to adjust the cash transfer to the timestep of the integration -133 if cash_transfer != {}: # If there is a cash transfer -134 cash_transfer_transformed = {np.linspace(0, n_years, n_weeks)[ -135 t]: cash_transfer[t] for t in list(cash_transfer.keys())} -136 else: -137 cash_transfer_transformed = {} -138 -139 # Calculate the consumption loss for each affected household -140 for _t in np.linspace(0, n_years, n_weeks): -141 gfac = (1 + income_and_expenditure_growth)**_t -142 -143 # TODO: Add an extra condition about to whom the transfer is given -144 # A "dynamic policy" -145 if _t in list(cash_transfer_transformed.keys()): -146 affected_households['aesav'] += cash_transfer_transformed[_t] -147 -148 # `c_t` is the consumption at time t -149 # !: It seems that keff remains constant over time -150 expenditure_growth = gfac * affected_households['aeexp'] -151 exponential_multiplier = np.e**( -152 -affected_households['recovery_rate']*_t) -153 savings = gfac * \ -154 affected_households['aesav'] * affected_households['recovery_rate'] -155 asset_damage = gfac * \ -156 affected_households['v'] * \ -157 affected_households[['keff', 'recovery_rate']].prod(axis=1) -158 -159 # TODO: Make sure that `delta_tax_safety` is not 0 -160 income_loss = gfac * (1 - affected_households['delta_tax_safety']) * \ -161 average_productivity * \ -162 affected_households['keff'] * affected_households['v'] -163 -164 # Equation is as follows: consumption_loss = expenditure_growth + exponential_multiplier * (savings - asset_damage - income_loss) -165 -166 if add_income_loss: -167 affected_households['c_t'] = (expenditure_growth + -168 exponential_multiplier * (savings - asset_damage - income_loss)) -169 else: -170 affected_households['c_t'] = (expenditure_growth + -171 exponential_multiplier * (savings - asset_damage)) -172 -173 # affected_households['c_t'] = (gfac * affected_households['aeexp'] # expenditure growth -174 -175 # + np.e**(-affected_households['recovery_rate']*_t) # exponential multiplier -176 -177 # * (gfac * affected_households['aesav'] * affected_households['recovery_rate'] # savings -178 # - gfac * affected_households['v'] * affected_households[['keff', 'recovery_rate']].prod(axis=1))) # asset damage -179 -180 # # - (1 - affected_households['delta_tax_safety']) # income loss -181 # # * average_productivity * affected_households['keff'] -182 # # * affected_households['v'])) -183 -184 # `c_t_unaffected` is the consumption at time t if the household was not affected by the disaster -185 affected_households['c_t_unaffected'] = gfac * \ -186 affected_households['aeexp'] -187 -188 # TODO: Add a check to see whether the consumption goes below 0 -189 -190 # Consumption cannot be lower than 0 -191 affected_households.loc[affected_households['c_t'] < 1, 'c_t'] = 1 -192 -193 # TODO: Add a check whether the consumption after hit by disaster should be lower than or equal to consumption before hit by disaster -194 -195 # consumption after hit by disaster should be lower than or equal to consumption before hit by disaster -196 affected_households.loc[affected_households['c_t'] > affected_households['c_t_unaffected'], -197 'c_t'] = affected_households.loc[affected_households['c_t'] > affected_households['c_t_unaffected'], 'c_t_unaffected'] -198 -199 # total (integrated) consumption loss -200 affected_households['consumption_loss'] += dt * \ -201 (affected_households['c_t_unaffected'] - -202 affected_households['c_t']) -203 -204 affected_households['consumption_loss_NPV'] += dt * \ -205 (affected_households['c_t_unaffected'] - -206 affected_households['c_t'])*np.e**(-discount_rate*_t) -207 -208 affected_households['net_consumption_loss'] += dt * \ -209 np.e**(-affected_households['recovery_rate']*_t) * \ -210 affected_households['v']*gfac * \ -211 affected_households['aeexp_house'] -212 -213 affected_households['net_consumption_loss_NPV'] += dt * \ -214 np.e**(-affected_households['recovery_rate']*_t) * affected_households['v']*gfac * \ -215 affected_households['aeexp_house'] * \ -216 np.e**(-discount_rate*_t) -217 -218 # Increase the number of weeks in poverty -219 affected_households.loc[affected_households['c_t'] -220 < poverty_line, 'weeks_pov'] += 1 -221 -222 # Integrated wellbeing -223 affected_households['w_final'] += dt*(affected_households['c_t'])**(1-consumption_utility) * \ -224 np.e**(-discount_rate*_t)/(1-consumption_utility) -225 -226 # w_final2 version 02 -227 affected_households['w_final2'] += affected_households['c_t_unaffected']**(1-consumption_utility)/(1-consumption_utility)*dt*( -228 (1-((affected_households['c_t_unaffected'] - affected_households['c_t'])/affected_households['c_t_unaffected'])*np.e**(-affected_households['recovery_rate']*_t))**(1-consumption_utility)-1)*np.e**(-discount_rate*_t) -229 -230 # * Use to examine individual consumption recovery -231 # Save consumption recovery value at the time _t -232 # consumption_recovery[_t] = affected_households['c_t'] -233 -234 # Save consumption recovery as pickle file -235 # with open('consumption_recovery.pickle', 'wb') as handle: -236 # pickle.dump(consumption_recovery, handle, protocol=pickle.HIGHEST_PROTOCOL) -237 -238 return affected_households -