Coder Social home page Coder Social logo

lechatquidanse / bicing-prediction-api Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 1.0 1.56 MB

Predict bikes' availability for Barcelona public bicycle sharing system.

Dockerfile 7.25% Python 83.29% Makefile 4.92% Shell 4.55%
python3 flask-restful machine-learning xgboost swagger bicing prediction docker-compose docker continuous-integration

bicing-prediction-api's Introduction

Bicing Log

Bicing Prediction API

Predict bikes' availability for Barcelona public bicycle sharing system.

The goal of this REST API is to predict the number of bikes or slots available for a Bicing station at a specific time.
By analysing data from different providers and building prediction model foreach Bicing's station, it can advice customers of the best time to pick or return a bike at a station.

Python 3.7 Pylint 10/10 Contributions welcome License

Getting StartedFeaturesBuilt WithDevelopmentMachine LearningCI and Deployment

Bicing API RESTs examples

Getting Started

Prerequisites

To install and run the API you need Docker Compose and... that's all. Please follow the official documentation to install it on your environment.

Installing

Clone the project and run the default installation:

git clone https://github.com/lechatquidanse/bicing-prediction-api.git && cd bicing-prediction-api && make install

Your docker containers should have been successfully built and run.

Features

Multiple features are proposed across 2 user interfaces, a REST API and command-line commands:

REST API:

Bicing API RESTs examples

CLI:

Bicing API CLI features

Built with

Development

The Makefile contains useful command for development purpose

Makefile helpul commands

Domain Driven Design

Code and folder structure follow Domain Driven Design (DDD).
Here is a good article to understand naming and folder Domain Driver Design, little explanation and example, even if the technology used is PHP.

src
    \
        |\ Application     `Contains the Use Cases and the Processes of the domain system, commands, handlers and data providers`
        |
        |\ Domain          `The system business logic layer (Models, Exceptions...)`
        |
        |\ Infrastructure  `Its the implementation of the system outside the model. I.E: Persistence, Query, etc`
        |
        |\ UserInterface   `It contains all the interfaces allowed for a user of the API (Cli, Rest, etc)`

Machine Learning

For a each stations a prediction model is created thanks to machine learning algorithms. It will allow us to forecast the number of bikes/slots available at a specific time.

Here is some very helpful resources that I encourage you to read to understand machine learning and forecasting algorithm:

Time Series Forecasting

To create a prediction model, our machine needs data. For now, data used come from Bicing Statistics Api project

Those data are a sequence of observations (availabilites for each stations) taken sequentially in time. So in order to provide prediction, we choose to use time series technique.

This technique predict future events by analyzing the trends of the past, on the assumption that future trends will hold similar to historical trends

The implementation of this algorithm is made with A Regression tree-based XGBoost.

Results

Here is the result for 33 - C/PONTEVEDRA / JUDICI station:

  • #0000FF In blue, the data provided to train the prediction model
  • #FFA50 In orange, the data provided to validate the prediction model
  • #2f9c2f In green, the data forecasted by the prediction model

33 - C/PONTEVEDRA / JUDICI forecasting

Improvement

The algorithm implementation is a first version. So it's very naive and could be improved by a lot of different approach. Adding weather, station's geo-location or holiday calendar dataset to train the model could make predictions more accurate.

CI and Deployment

CI and deployment can be handled through Gitlab and Docker thanks to .gitlab-ci.yml It contains 3 different stages.

Test

Environment 'test' is triggered when a 'feature/*' branch is pushed to the repository. It will then install project and launch qa tools.

Build

Environment 'build' is triggered when a 'release/*' branch is pushed to the repository. It will then install project, launch qa tools and then build and push a docker image on a registry if no error occured.

Production

This manual action, will pull the image build by the previous step and update the specific container.

Continuous Integration

License

MIT

Stéphane EL MANOUNI  ·  Linkedin

bicing-prediction-api's People

Contributors

lechatquidanse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

karael

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.