Coder Social home page Coder Social logo

chicago / clear-water Goto Github PK

View Code? Open in Web Editor NEW
55.0 20.0 43.0 1.04 GB

Forecasting elevated levels of E. coli at Chicago beaches to provide proper warning to beach-goers.

Home Page: http://chicago.github.io/clear-water

R 100.00%
chicago government public-health r open-source open-science

clear-water's Introduction

Clear Water

DOI MIT License project

The City of Chicago's Clear Water project brings an innovative approach to beach water quality monitoring. It uses a machine learning prediction technique to better forecast the bacteria levels at Chicago beaches. The model works by interpreting patterns in the results of DNA tests at a handful of beaches across the City, which are then extrapolated to forecast the water quality at other, untested beaches. This method provides a new way for beach managers to save money on expensive rapid water quality tests.

Initial evaluation of the model has shown a significant improvement over current methods of predicting beach water quality. Testing is ongoing, and the 2017 beach season is being analyzed to further improve and evaluate the model's performance.

Getting started with R

This project uses R, which you can download here. We recommend you also install RStudio. You can open this project in RStudio by opening the clear-water.Rproj file.

If you are new to R, check out some basics here.

Running the model

To generate the model, open the Master.R file. Inside the file, you will see settings that you can tweak to change the predictors and other facets of the model. Once you're ready, run all the code in the file. If you've successfully generated the model, you'll see ROC and Precision/Recall plots appear in RStudio. You'll also have a Data Frame in R called model_summary that contains the results of the model evaluation.

Running the model in production

This repo is one of two GitHub repos that make up the Clear Water project. The other one can be found here and is an application that automatically generates water quality predictions based on daily DNA test results that are published on Chicago's Data Portal.

Contributing

If you are interested in contributing to this project, see our Contribution Guide.

Notes

Collaboration with the Civic Tech Community

This project originated as a breakout group at Chi Hack Night.

Resources

LICENSE

Copyright (c) 2015 City of Chicago

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

clear-water's People

Contributors

beckeroobonsai avatar callinosborn avatar chrisprokop avatar dgalt avatar fgregg avatar kbrose avatar knowledgemonger avatar mattesweeney avatar mmcneill avatar nicklucius avatar scottlittle avatar tomschenkjr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clear-water's Issues

How are disagreements between reading 1 and reading 2 handled?

Sometimes there is significant disagreement between reading 1 and reading 2, at times, one reading is near zero and another is near the maximum reading. How does Park District handle these numbers? Is the maximum value taken or the minimum? Are the geometric means used?

Reorganize code

I'm conducting some housekeeping on the code as found in a9fd8b3. Namely:

  • Create a split_stack.R function that will split and clean the raw data
  • Call the split_stack.R function from the analysis.R function.
  • Conduct some of the data organization and cleaning in the analysis.R function.

Identify potential variables

E. Coli readings

  • E. Coli beach readings from two days ago
  • E. Coli beach readings from previous day

Beach Water readings

  • Solar radiation
  • Water temperature
  • Turbidity
  • Wave height
  • Wave period

Beach Weather Stations

  • Air temperature
  • Rain intensity
  • Rain interval
  • Wind

Nearby Actions

  • Open locks
  • Park events
    Calendar-based data
  • Day of week
  • Holidays
  • Forecasted e. coli from current model

forecast weather data for days without reading

Even for days where E. coli readings were not taken (e.g., most weekend days), it is still possible to get the weather data. This data should be downloaded and added to the data-set so that models that rely on the previous day's weather can be better informed.

Test harness

Compare performance on various models against benchmarks.

Create a train/test split for benchmarking

It would probably be nice to get a training and test dataset split for comparing new models, similar to the way Kaggle selects a winning model. One thing we'll have to look out for is making sure the training and testing datasets are balanced w.r.t the number of positives and negatives.

Revisit naming conventions

Reading = Drek_Reading
Prediction = Drek_Prediction
SwimStatus = Drek_WorstSwimStatus

e.coli.geomean = e.coli.geomean.calculated

Add Beach Groupings

Add a North/South beach flag (relative Navy Pier).h

Add several other clusters for the beaches. 4? 5? 6?
North-North, North-South, South-South, South-North

Remove ">" from data

When the test results are the highest levels (2420), the data contains a ">" and needs to be removed.

Filling in NaN values

How should NaN values be filled in (if at all)?

Using the city-wide mean for a given day might not be appropriate for filling in NaNs on the weekends, since the beaches that are sampled on the weekend are only sampled because they had a high reading on Friday (and maybe on Thursday? -- don't know the exact resampling rule) possibly causing bias in those readings.

Using a moving average could similarly be biased if the weekend samples are not excluded from the moving average.

Start simple model

  • Autogressive with
  • Day of week
  • Holiday
  • Beach
  • Their forecast levels
  • Levels in other beaches

DEFINEDNAME repeated

When running the data-cleaning code, the following message gets repeated quite a bit. Is this something that can be prevented?

DEFINEDNAME: 20 00 00 01 0b 00 00 00 01 00 00 00 00 00 00 07 3b 00 00 00 00 ff ff 00 00 00 00

This message specifically happens for some of the calls to split_sheets. Specifically, it happens with

df2006 <- split_sheets("data/ChicagoParkDistrict/raw/Standard 18 hr Testing/2006 Lab Results.xls", 2006)

Historical forecast data

Despite the name, it appears as if forecast.io does not have historical forecasts, but only the observed values (e.g., we can not tell what the the weather on 6/2/2014 was forecasted to be on 6/1/2014). What other sources could we draw from to get the historical forecasts?

Some sheets have more than 2 readings

I found a few sheets that have more than 2 readings. It looks like the R code does not handle these (it silently renames the extra reading columns). This could possibly related to the large outlier? Could also be causing the few instances where we observed a larger-than-1 difference between our calculated geometric mean and the geometric mean we pulled from the excel file (i.e. by renaming the column Reading 3 to Escherichia.coli)

Found these dates on a first-pass through:

July 31 2006
August 1 2006
August 2 2006
August 3 2006
August 4 2006
August 9 2006
August 2 2007
August 2 2008

"Shift" data to prior day or previous observations

The data is currently organized so each row represents a lab test result at a beach on a given day. The remainder of the row then shows all of the information associated with that day.

However, to look at the impact of previous weather and other variables from prior days, need to organize the data set to make it easier to run analysis against historical data.

Test harness

Compare performance on various models against benchmarks.

Are beaches systematically sampled?

The beach readings also report the time-of-day when they were taken. Is there a systematic difference in the sampling time for beaches (e.g., does the sampler always go from the north side to the south side?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.