{"id":20408730,"url":"https://github.com/feast-dev/feast-credit-score-local-tutorial","last_synced_at":"2025-04-12T15:36:15.191Z","repository":{"id":242798475,"uuid":"810089091","full_name":"feast-dev/feast-credit-score-local-tutorial","owner":"feast-dev","description":"A Feast tutorial using DuckDB, PostGres, and Redis","archived":false,"fork":false,"pushed_at":"2025-03-15T01:17:02.000Z","size":23518,"stargazers_count":6,"open_issues_count":1,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-26T10:11:18.343Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/feast-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-04T02:58:09.000Z","updated_at":"2025-03-26T10:06:48.000Z","dependencies_parsed_at":"2025-02-20T22:37:39.982Z","dependency_job_id":null,"html_url":"https://github.com/feast-dev/feast-credit-score-local-tutorial","commit_stats":null,"previous_names":["feast-dev/feast-credit-score-local-tutorial"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feast-dev%2Ffeast-credit-score-local-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feast-dev%2Ffeast-credit-score-local-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feast-dev%2Ffeast-credit-score-local-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feast-dev%2Ffeast-credit-score-local-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/feast-dev","download_url":"https://codeload.github.com/feast-dev/feast-credit-score-local-tutorial/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248590295,"owners_count":21129779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T05:35:55.300Z","updated_at":"2025-04-12T15:36:15.179Z","avatar_url":"https://github.com/feast-dev.png","language":"Jupyter Notebook","readme":"# Real-time Credit Scoring with Feast on Local Setup\n\n## Overview\nThis tutorial is built from the original **[feast-aws-credit-scoring-tutorial](https://github.com/feast-dev/feast-aws-credit-scoring-tutorial)**.  \n\nThis tutorial demonstrates the use of Feast as part of a real-time credit scoring application.\n* The primary training dataset is a loan table. This table contains historic loan data with accompanying features. The dataset also contains a target variable, namely whether a user has defaulted on their loan.\n* Feast is used during training to enrich the loan table with zipcode and credit history features from the **data** folder.\n* Feast is also used to serve the latest zipcode and credit history features for online credit scoring using Redis\n\nTo get a better feel of what this example entails, you can view the steps outlined below in notebook \nform in [demo_walkthrough.ipynb](demo_walkthrough.ipynb).\n\n## Requirements\n\n* Python 3.11\n* Registry: Postgresql  \n* Offline Storage: duckdb  \n* Online Storage: Redis\n\n## Setup\n\n### Database Setup\n \nYou can setup the storages with Podman or Docker:  \n\n1. Setup Postgresql and Redis by [Podman](https://podman.io/):  \n```\npodman pull docker://bitnami/postgresql  \npodman run -d -p 5432:5432 --name postgresql -e \"ALLOW_EMPTY_PASSWORD=yes\" docker.io/bitnami/postgresql:latest  \n\npodman pull docker://bitnami/redis:latest\npodman run -d -p 6379:6379 --name redis docker.io/bitnami/redis:latest  \n```\n\n\n2. Setup Postgresql and Redis by Docker:  \n```\ndocker pull bitnami/postgresql:latest\ndocker run -d -p 5432:5432 --name postgresql -e \"ALLOW_EMPTY_PASSWORD=yes\" bitnami/postgresql:latest\n\ndocker pull bitnami/redis:latest\ndocker run -d -p 6379:6379 --name redis -e \"ALLOW_EMPTY_PASSWORD=yes\" bitnami/redis:latest\n```\n\nPlease **create** a database named \"feast\" for Feast's SQL Registry service. It is required by the Registry setting in the **feature_store.yaml**. Feel free to use other names, but to make sure that they are the same and consistent.\n\nThis can be done via:\n```bash\n% psql postgresql://postgres@localhost:5432\npsql (13.4, server 16.3)\nWARNING: psql major version 13, server major version 16.\n         Some psql features might not work.\nType \"help\" for help.\n\npostgres=# create database feast\npostgres-# ;\nCREATE DATABASE\n```\n\n### Pointing to remote databases\n\nRather than provisioning the storage providers locally, you can also provision\nthem remotely and point to them in [feature_store.yaml](feature_repo/feature_store.yaml)\nby specifying the following environment variables:\n\n  * POSTGRES_HOST\n  * POSTGRES_USER\n  * POSTGRES_PASSWORD\n  * POSTGRES_DB\n  * REDIS_HOST\n\n### Setting up Feast\n\nInstall Feast using pip\n\n```\npip install -r requirements.txt\n```\n\nWe have already set up a feature repository in [feature_repo/](feature_repo/). As a result, all we have to do is configure the [feature_store.yaml/](feature_repo/feature_store.yaml) in the feature repository. Please set the connection string of the Postgresql and Redis according to your local infra setup.  \n\nDeploy the feature store by running `apply` from within the `feature_repo/` folder\n```\ncd feature_repo/\nfeast apply\n```\n```\nDeploying infrastructure for credit_history\nDeploying infrastructure for zipcode_features\n```\n\nNext we load features into the online store using the `materialize-incremental` command. This command will load the\nlatest feature values from a data source into the online store.\n\n```\nCURRENT_TIME=$(date -u +\"%Y-%m-%dT%H:%M:%S\")\nfeast materialize-incremental $CURRENT_TIME\n```\n\nAlternatively, you may have to run\n```\nCURRENT_TIME=$(date -u +\"%Y-%m-%dT%H:%M:%S\")\nfeast materialize 1990-01-00T00:00:00  $CURRENT_TIME\n```\n\nReturn to the root of the repository\n```\ncd ..\n```\n\n## Train and test the model\n\nFinally, we train the model using a combination of loan data from the parque file under the `./data` folder and our zipcode and credit history features from duckdb (with Filesource). And then we test online inference by reading those same features from Redis.\n\n```\npython run.py\n```\nThe script should then output the result of a single loan application\n```\nloan rejected!\n```\n\n## Interactive demo (using Streamlit)\n\nOnce the credit scoring model has been trained it can be used for interactive loan applications using Streamlit:\n\nSimply start the Streamlit application\n```\nstreamlit run streamlit_app.py\n```\nThen navigate to the URL on which Streamlit is being served. You should see a user interface through which loan applications can be made:\n\n![Streamlit Loan Application](streamlit.png)\n\n## Serving Demo and OpenAPI docs\n\nYou can run\n```bash\npython app.py\n```\nAnd you'll be able to see the endpoints by going to http://127.0.0.1:8888/docs#/.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeast-dev%2Ffeast-credit-score-local-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffeast-dev%2Ffeast-credit-score-local-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeast-dev%2Ffeast-credit-score-local-tutorial/lists"}