Code Monkey home page Code Monkey logo

recession-indicator's Introduction

Recession-Indicator

Uses Machine Learning to detect whether the United States is entering a recession by training a neural network with OECD's (Organisation For Economic Co-Operation and Development) CLI indicator. "The OECD CLI is designed to provide qualitative information on short-term economic movements".

As of 05-2019, the United States has a 0.00% chance of heading into a recession within the next month.


The model looks at each month and gives a percentage represent the likelihood of the United States entering a recession for the next month. It's typically 0.00%, but it'll sometimes be 0.1% or 0.2%. Once it gets above 1.0%, it's time to take notice.

The model tends to start rising from 0.0% when a recession is coming.

Visualizing The Model
The recession indicator model tends to start rising from 0 when a recession is coming, and equal 1 when a recession is in full swing. Preview
A recession is occurring when the NBER value is 1. Preview
Overlapping the indicator model graph and the actual recession graph. Preview

Overfitting possibility? Most definitely. But when the model was trained on recession data before the Great Recession, it was still able to predict the recession and subsequent market pull-backs in 2011 and 2015.


Python libraries needed can be installed using Anaconda on Windows.

  • numpy
  • pandas
  • keras (needs tensorflow and theano, with tensorflow being the backend to keras)

Steps for obtaining country data:

  1. First go to http://stats.oecd.org/Index.aspx?DataSetCode=MEI_CLI
  2. In the left panel menu, select "Composite Leading Indicators (MEI)"
  3. Select "OECD Standardised CCI, Amplitude adjusted (Long term average=100), sa" for the dropdown next to Subject
    Any value below 100 for a month, indicates economic growth below that country's average. The higher the number past 100, the better.
  4. Click on the "Time" header label under "Country" on the graph.
    Top should have "Select time range" selected.
  5. Select the Monthly checkbox.
  6. Can use the dropdown list in the "From:" column to select the oldest date, or select the radiobox for "Select latest data", and use the dropdown list corresponding to the monthly row, and select the higher number of months. Should pick starting from 1970, or 520- months. Data before 1970 is inaccurate or not available.
  7. In the top menu, click Export, then CSV, and Download
  8. Rename the file downloaded to "MEI_standardized_CCI.csv"
  9. Download CSV from https://fred.stlouisfed.org/series/USREC

Steps for running:

  1. Run compile_data.py once country data is properly renamed and placed in the folder.
  2. Run ANN_recession.py
    • Percentage for current recession will be given, and percentages for all previous months will be output to US_recession_percentages.csv
    • If you want to train the model yourself, delete "recession_indicator_model.h5", and run ANN_recession.py again.

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.