Git Product home page Git Product logo

pm25predict's Introduction

PM2.5 Predict

Prototype RNN approach to predicting PM2.5 time series

Experimentation

  • Supply pandas dataframe of features, indexed by timeseries sampled by hour.
    from pm25predict import ModelLoader, DatasetLoader, ModelContext
        
    # load data from influxdb
    df = InfluxDataLoader(database='gams', tables=['indoor', 'outdoor']).df

    # create dataset with dataframe features, df, 
    # supply labels with dataframe with single column, df[['pm25]]
    dataset_loader = DatasetLoader(df, df[['pm25']], look_back=3, ratio=0.9)

    # create model
    model_context = ModelContext(look_back=3)
    
    # train model 
    model_context.train(dataset_loader, nb_epoch=50)

    # test model on 10% of data, this will print RMSE errors
    testPredict = model_context.test(dataset_loader)

    # get training and testing labels for measurement
    train_labels, test_labels = dataset_loader.get_labels()

Online prediction

Data pipeline is captured via indoor and outdoor data sources to influx db.

  • indoor sensor data
  • outdoor atmosphere API

Cruncher will need to supply last 3+2 hours (look_back=3) data as Dataframe and create dataset.

    from pm25predict import ModelLoader, DatasetLoader, ModelContext

    # load dataset with ratio = 0.0 for all testing features
    dataset_loader = DatasetLoader(df, df[['pm25']], look_back=3, ratio=0.)

    # load current model
    model_path = "path/to/models/"
    loader = ModelLoader(model_path)

    # make prediction
    predict = loader.model_context.predict(dataset_loader)
    # load dataset with ratio = 1.0 for all training features
    dataset_loader = DatasetLoader(df, df[['pm25']], look_back=3, ratio=1.)

    # update model
    loader.model_context.update(dataset_loader)

    # save model
    loader.save_model()

dev notes

Generate pip reqs

pipreqs . --force

TODO

  • Monitoring with grafana dashboard, and measure predictions vs actual
  • Add weather data (wind, humidity, air pressure)
  • Predict t+N hours forecasting, and measure accuracy.

pm25predict's People

Contributors

twairball avatar

Watchers

James Cloos avatar  avatar

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.