Giter Site home page Giter Site logo

bike-share-prediction's Introduction

Bike-Share-Prediction

This tool allows people wanting to get bikeshares usage prediction. It currently works with the Vélib' system but can be expanded to any bikeshare system, especially any of the JCDecaux system in a minute.

An example instance of the Webservice is running on Heroku, you can access it here: http://bike-share-prediction-example.herokuapp.com. It contains stations of the Vélib' contract, but does not make any prediction.

Installation

  • Get API key from JCDecaux Developer

  • Get API key from OpenWeatherMap

  • Get API key from forecast.io (max. 1000 calls per day)

  • Create a config/api_keys.yml file with this format:

    jcdecaux: API_KEY
    openweathermap: API_KEY
    forecastio: API_KEY
    
  • bundle install

  • bundle exec rake db:create

  • bundle exec rake db:migrate

  • bundle exec whenever -i

  • bundle exec rake fetch:populate will create Vélib' contract, you can add other systems here if you want to

  • bundle exec rails server

  • Enjoy.

Alternatively, you can set API keys as environment variables, suffixed with \_APIKEY:

$ export JCDECAUX_APIKEY=xxxx $ export OPENWEATHERMAP_APIKEY=xxxx $ export FORECASTIO_APIKEY=xxxx $ bundle exec rails server

Prediction backend

This repository comes packaged with a scikit-learn-based prediction backend, to get it to run, you will need a Redis server running on port 6379, if it is running on another port, please change it in prediction/worker.py and lib/tasks/predict.rake.

Once Redis is running, run prediction/worker.py (install requirements located in prediction/requirements.txt before, works well with Python virtualenv).

The worker will subscribe to a Redis Pub/Sub channel. Once a day, Rails will publish metadata asking to predict usage for the next day, the Python worker will treat these metadata and predict using scikit-learn's linear_model.Lasso and linear_model.Ridge algorithms.

You can add another prediction backend and turn the Python worker off if you have your own implementation of a prediction algorithm.

Routes

  • GET /contacts
  • GET /contracts/:contract_id/stations
  • GET /stations/:station_id

Add a contract

JCDecaux

Simply add a new Contract object to the database, the name must be the name used to fetch data from JCDecaux, latitude and longitude are there for OpenWeatherMap and forecast.io.

Other

You will have to write a rake task, indicating how data are fetch, see lib/tasks/fetch.rake for the format.

Future work

There are a couple of improvements that could be done. Feel free to send us pull requests if you want to contribute!

  • Add a new prediction method (with scikit-learn or something else)
  • Add new bikeshare systems
  • More?

bike-share-prediction's People

Contributors

flavray avatar

Watchers

 avatar  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.