Skip to content

Commit

Permalink
OOP updates
Browse files Browse the repository at this point in the history
  • Loading branch information
whitelightning450 authored Jun 9, 2022
1 parent 35aa4d6 commit fa04d0f
Show file tree
Hide file tree
Showing 57 changed files with 9,603 additions and 0 deletions.
764 changes: 764 additions & 0 deletions OOP_Python/CSD_WDM_AllMonths.py

Large diffs are not rendered by default.

1,936 changes: 1,936 additions & 0 deletions OOP_Python/CSD_WDM_Do not change code.ipynb

Large diffs are not rendered by default.

979 changes: 979 additions & 0 deletions OOP_Python/CSD_WDM_Template-AllMonths.ipynb

Large diffs are not rendered by default.

724 changes: 724 additions & 0 deletions OOP_Python/CSD_WDM_Template.ipynb

Large diffs are not rendered by default.

4,296 changes: 4,296 additions & 0 deletions OOP_Python/CSD_WDM_all_months_modeled.ipynb

Large diffs are not rendered by default.

810 changes: 810 additions & 0 deletions OOP_Python/Emilys_CSD_WDM.py

Large diffs are not rendered by default.

Binary file added OOP_Python/Final/AllData/Apr.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/AllData/Aug.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/AllData/Dec.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/AllData/Feb.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/AllData/Jan.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/AllData/Jul.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/AllData/Jun.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/AllData/Mar.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/AllData/May.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/AllData/Nov.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/AllData/Oct.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/AllData/Sep.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/SnowData/Alta_LCC_snow.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Train/Apr.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Train/Aug.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Train/Dec.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Train/Feb.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Train/Jan.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Train/Jul.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Train/Jun.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Train/Mar.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Train/May.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Train/Nov.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Train/Oct.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Train/Sep.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Validate/Apr_test.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Validate/Aug_test.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Validate/Dec_test.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Validate/Feb_test.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Validate/Jan_test.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Validate/Jul_test.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Validate/Jun_test.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Validate/Mar_test.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Validate/May_test.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Validate/Nov_test.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Validate/Oct_test.xlsx
Binary file not shown.
Binary file added OOP_Python/Final/Validate/Sep_test.xlsx
Binary file not shown.
Binary file added OOP_Python/Processed_Training_Data/Apr.xlsx
Binary file not shown.
Binary file added OOP_Python/Processed_Training_Data/Aug.xlsx
Binary file not shown.
Binary file added OOP_Python/Processed_Training_Data/Dec.xlsx
Binary file not shown.
Binary file added OOP_Python/Processed_Training_Data/Feb.xlsx
Binary file not shown.
Binary file added OOP_Python/Processed_Training_Data/Jan.xlsx
Binary file not shown.
Binary file added OOP_Python/Processed_Training_Data/Jul.xlsx
Binary file not shown.
Binary file added OOP_Python/Processed_Training_Data/Jun.xlsx
Binary file not shown.
Binary file added OOP_Python/Processed_Training_Data/Mar.xlsx
Binary file not shown.
Binary file added OOP_Python/Processed_Training_Data/May.xlsx
Binary file not shown.
Binary file added OOP_Python/Processed_Training_Data/Nov.xlsx
Binary file not shown.
Binary file added OOP_Python/Processed_Training_Data/Oct.xlsx
Binary file not shown.
Binary file added OOP_Python/Processed_Training_Data/Sep.xlsx
Binary file not shown.
94 changes: 94 additions & 0 deletions OOP_Python/README.rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# CSD-WDM

**Version 1.0**

Python-based (v3.8.5) Water Demand Model

## Description

The Climate-Supply-Development Water Demand Model takes in monthly features to identify the key per-capita water demand 'drivers'. During model calibration, the training process evaluates feature correlation with observed gallons per-capita water use (gpcd), checks for feature collinearity and removes the lesser demand correlated co-linear feature, and performs recursive feature elimination to identify key demand drivers and optimize model accuracy in predicting water demand.

## Getting Started

Access the module here:

** link to .py file and template **

### Prerequisites

The following are modules used in the model that are not downloaded automatically with python.

* Progressbar

## Usage

### Loading Data

The user will provide two sets of data: historical data (loaded as historical_data) and forecast data (loaded as forecast_data).

The historical data will be divided into training and testing data with the identification of three years: one drought year, one average year, and one surplus year. The training data will be used to calibrate the model and should not be less than 30 years. The testing data will be used in order to quantify the accuracy of the model's predictions when making predictions for varying conditions.

The forecast data set will include the conditions anticipated by the user for the year which the prediction is being made for.

Historical and forecast data files should each contain an excel file for each month. Excel files should have features listed along the top as column titles and years listed along the left side as row titles. These excel files will be loaded into a python dictionary format with the help of the provided template.

Features may include the following or any other features desired by the user:

| Feature | Suggested Units | Label |
| --- | --- | --- |
| Mean daily temperature | °C |
| Monthly precipitation | mm |
| Monthly snowfall | mm | Apr_snow_in       Mar_snow_in       etc |
| Yearly snowfall | mm | Total_snow_in |
| Snow shortage | mm | Snow_shortage |
| Housing | units |
| Population density | people / sq mile |
| Streamflow of major streams | acre-feet |
| Conservation goal | gpcd | cons_goal |
| Mean monthly per capita water demand | gpcd | Target_gpcd |

** Target_gpcd is a required feature **

Note: the CSD-WDM model used gpcd as units. If user wishes to have predictions in other units, conversions can be made after running the model and collecting values.

### Model Inputs

The following are inputs used within in the model:

* Scoring is used to assess the fit of the model to the testing data. As of now, either the R squared method or Root Mean Square Error method can be used in the model.

* Snow data and set conservation goals may be used in the data files if relevant for the area of interest, but must be set to False if not provided in the excel data.

* Correlation threshold is the limit (number between 0 and 1) to be used when examining the relationship between a feature and the target.

* Collinearity threshold is the limit (number between 0 and 1) to be used when examining the relationship between two features. This threshold is used to remove a feature with the weaker correlation.

**Possible Inputs**

| Name of Input | Choices | Enter in template |
| --- | --- | --- |
| **Snowfeatures** | Use snowfall data | [True, False] |
| | Don't use snowfall data | [False] |
| **Conservation** | Use conservation goal | [True, False] |
| | Don't use conservation goal | [False] |
| **Scoring** | R squared | 'R2' |
| | Root Mean Square Error | 'RMSE' |

| Name of Input | Default (may be editied) | In template |
| --- | --- | --- |
| **Correlation Threshold** | Test all values between 0 and .95 with increments of 0.05 | np.arange(0,0.95, 0.05) |
| **Colinearity Threshold** | Test all values between .65 and .9 with increments of 0.0 | [0.65, 0.7, 0.75, 0.80, 0.85, 0.90] |

### Accessing More Data

More data may be accessed that is not automatically displayed in the CSD-WDM template. To access this data, the user must edit the module file. To print out lines with information about selected features, cv scores, number of selected features, final features, and values for error metrics, the user may remove the quote marks around the print lines in the Outdoor_Demand_Model and model_plots functions. For help with this or other challenges, feel free to contact the contributers via email.

## Contributers

**Ryan Johnson**

[email protected]

**Emily Baur**

[email protected]
Binary file added OOP_Python/SnowData/Alta_LCC_snow.xlsx
Binary file not shown.

0 comments on commit fa04d0f

Please sign in to comment.