Git Product home page Git Product logo

feast-credit-scoring-demo's Introduction

Real-time Loan Approval demo

This application is the adopted Feast Credit Scoring Tutorial to use Redis as online feature store and local files as offline store. solution diagram

Feast supports Redis and so this demo can be configured to use local Redis instance, Redis Cloud or ACRE.

Preparing Redis

Jump to one of the sections below depending on how you want to use Redis for the demo:

Using ACRE

  1. Go to Azure portal and provision Azure Cache for Redis:

create ACR

  1. Populate basic properties and hit 'Create' (Standard tier should be fine for demo):

New ACR

  1. Wait until Redis is fully provisioned (may take up to 20 mins), then navigate to the resource.

  2. Go to 'Advanced settings' and enable non-SSL port:

Note: this is for demo purpose only, never do this in production!

Disable SSL only

  1. Go to 'Access keys' and grab the connection string - you will need it later while setting up the app as well as the feature store settings:

connection string

  1. Modify connection string to adjust the port number:

loanapp.redis.cache.windows.net:6379,password=Ze...A=

Make note of this string as you will be using this later on.

Using Redis Cloud

coming soon

Using local Redis

coming soon

Local demo setup

  1. Create new virtual environment and activate it:
python3 -m venv .venv/loanapp

source .venv/loanapp/bin/activate
  1. Update pip and install project dependencies:
pip install -update pip

pip install wheel

pip install -r requirements.txt
  1. Edit the creditscore/feature_store.yml file to uncomment the connection_string property and populate it with the redis connection string you captured before:
online_store:
    type: redis
    # for Azure:
    connection_string: loanapp.redis.cache.windows.net:6379,password=Ze...A=
  1. Initialize feast repository:
cd creditscore
feast apply
  1. Materialize features to Redis:
CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S")
feast materialize-incremental $CURRENT_TIME
  1. Return to the main directory and train the model:
cd ..
python run.py

You now have the model ready to be served and the latest features materialized and stored in Redis database. You can try and explore the size of the online store by connecting to redis server using redis-cli:

❯ redis-cli -h loanapp.redis.cache.windows.net -p 6379 -a Ze...A= dbsize
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
(integer) 57477

Running demo locally

You can run and test the model using either run.py (CLI) or streamlit_app.py (Browser). Streamlit is the framework that allows building web data apps in minutes.

  1. First, you need to configure the connection to Redis for your application by creating a file .streamlit/secrets.toml and adding the conection string to there:
mkdir .streamlit

echo "redis_connection_string = \"loanapp.redis.cache.windows.net:6379,password=Ze...UA=\"" > .streamlit/secrets.toml
  1. Next, run the application using the command below:
streamlit run streamlit_app.py
  1. In the browser you can play with the loan parameters to see if your loan gets approved or rejected.

Note: the loan application parameters are joined with the applicant's credit history (feature vector) stored in Redis to make an approval decision!

Streamlit hosted demo

Follow the instructions on Streamlit Cloud to deploy a hosted version of this demo.

Also, explore Redis Cloud for a free tier of Redis Enterprise on AWS and GCP.

live demo

feast-credit-scoring-demo's People

Contributors

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