{"id":30460933,"url":"https://github.com/zseta/feast-driver-demo","last_synced_at":"2025-08-23T20:36:24.756Z","repository":{"id":310497222,"uuid":"1027737863","full_name":"zseta/feast-driver-demo","owner":"zseta","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-18T13:23:04.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-18T14:33:07.558Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zseta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-07-28T13:08:17.000Z","updated_at":"2025-08-18T13:23:07.000Z","dependencies_parsed_at":"2025-08-18T14:33:09.769Z","dependency_job_id":"5a038844-139a-4719-a0b9-d14d0daa861b","html_url":"https://github.com/zseta/feast-driver-demo","commit_stats":null,"previous_names":["zseta/feast-driver-demo"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/zseta/feast-driver-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zseta%2Ffeast-driver-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zseta%2Ffeast-driver-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zseta%2Ffeast-driver-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zseta%2Ffeast-driver-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zseta","download_url":"https://codeload.github.com/zseta/feast-driver-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zseta%2Ffeast-driver-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271767989,"owners_count":24817592,"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","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-08-23T20:36:23.789Z","updated_at":"2025-08-23T20:36:24.722Z","avatar_url":"https://github.com/zseta.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003e **Note:** This repo is a fork of https://github.com/franciscojavierarceo/Python/tree/main/demos/feast.\n\n\n# A Feast Risk Feature Store Demo\n\nhttps://github.com/franciscojavierarceo/Python/assets/4163062/394f6f7b-34d1-4c4e-ae69-28c3ec3bf3e4\n\nThis is a modification of [Feast's feature store demo](https://docs.feast.dev/getting-started/quickstart) \nto create an OpenAPI wrapper that allows you to browse the endpoints, simulate a user experience, and \nrun a real-time machine learning model.\n\n*Note: this example uses a simple weighted sum of integers that stay between [0,1] for simplicity.\nIn practice, a real machine learning model can be swamped in but that is not the focus of this demonstration.*\n\n## Motiviation\nI built this demo for a talk I gave at Tecton's apply(risk) conferene and the motivation was to show what\nsome real risk ml systems may look like. This is an extremely trivialized example but it helps highlight the \ndifferent components.\n\nThe 5 non-technical (though arguably still technical) takeaways are:\n1. It is good to separate feature retrieval, featurization, and model inference inference as much as possible\n  - Notice that in the example the output of the features `feature_vector` is a true numpy vector and not non-numeric\n2. In this example, the little `batch_job.py` script is trivial but in general data/feature pipelines are rich in business \nlogic, context, and (typically) bugs, so it is worth emphasizing that the creation of batch features is non-trivial\n3. Notice that this model has an explicit `is_valid_state` feature. What happens if the business enables a new state? \nThe model would be wrong and it would unnecessarily penalize customers. This is bad and it's important to understand that\na model works within the context of a product experience.\n4. This code and these features are untested. This is a terrible practice. Features should be \nrigorously tested for any production model that will make some sort of risk decision about your customer.\n5. Feast is doing a lot of work here for us. The registry/metadata, materialization, online feature execution, and serving.\nIt is worth emphasizing this point.\n\n## Goals\n\n0. Build Feast using Poetry\n1. Use Feast to query Batch and On-Demand features \n2. Materialize data into Feast's Online Store\n3. Retrieving online features to run an online model\n4. Simulate the a simple batch job to generate more features and materialize them\n5. Run a batch model on some cadence to update a user experience\n\n## Installation via PyEnv and Poetry\n\nThis demo assumes you have Pyenv (2.3.10) and Poetry (1.4.1) installed on your machine as well as Python 3.8.\n\n```bash\npyenv use 3.8\npoetry shell\npoetry install\n```\n## Setting up the data and Feast\n\nWe start by generating some mock data via:\n```bash\n% python generate_data.py\n% python batch_job.py\n```\n\nThen you can run apply the changes to feast's registry \n```bash\n% cd feature_repo/\n% feast apply\nCreated entity ssn\nCreated entity dl\nCreated entity driver\nCreated feature view driver_hourly_stats\nCreated feature view driver_dl_entities\nCreated feature view driver_yesterdays_stats\nCreated feature view driver_ssn_entities\nCreated on demand feature view transformed_onboarding\nCreated on demand feature view ondemand_ssn_lookup\nCreated on demand feature view ondemand_dl_lookup\n\nCreated sqlite table feature_repo_driver_dl_entities\nCreated sqlite table feature_repo_driver_hourly_stats\nCreated sqlite table feature_repo_driver_ssn_entities\nCreated sqlite table feature_repo_driver_yesterdays_stats\n```\n\nThen to insert records into the table you can run\n```bash\n% CURRENT_TIME=$(date -u +\"%Y-%m-%dT%H:%M:%S\")\n% feast materialize-incremental $CURRENT_TIME\nMaterializing 4 feature views to 2023-05-26 11:27:36-07:00 into the sqlite online store.\n\ndriver_hourly_stats from 2013-05-28 18:27:45-07:00 to 2023-05-26 11:27:36-07:00:\n100%|████████████████████████████████████████████████████████████████| 5/5 [00:00\u003c00:00, 436.53it/s]\ndriver_dl_entities from 2013-05-28 18:27:46-07:00 to 2023-05-26 11:27:36-07:00:\n100%|████████████████████████████████████████████████████████████████| 1/1 [00:00\u003c00:00, 531.06it/s]\ndriver_yesterdays_stats from 2023-05-24 18:27:46-07:00 to 2023-05-26 11:27:36-07:00:\n100%|████████████████████████████████████████████████████████████████| 1/1 [00:00\u003c00:00, 329.82it/s]\ndriver_ssn_entities from 2013-05-28 18:27:46-07:00 to 2023-05-26 11:27:36-07:00:\n100%|████████████████████████████████████████████████████████████████| 1/1 [00:00\u003c00:00, 508.89it/s]\n```\nAnd you're done! Your data from the parquet file has been inserted into Feast\n\n# Flask Demo\n\nAfter getting Feast configured and materialized, you can then run a web server to demo our little Driver Risk application.\n\nThis can be done by running\n```bash\n[main]% python app.py\n * Serving Flask app 'app'\n * Debug mode: on\nWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.\n * Running on http://127.0.0.1:5000\nPress CTRL+C to quit\n * Restarting with stat\n```\n\nThen navigate to http://127.0.0.1:5000/apidocs/ and you can see the endpoints.\n\n![feast_flasgger](https://github.com/franciscojavierarceo/Python/assets/4163062/04f351ef-a982-4565-9967-f35418fceb54)\n\nAs shown in the video above, if you navigate to the main page http://127.0.0.1:5000 you can submit a form that will \nreturn a decision about whether or not you are approved to drive; below is an example.\n\n![high_risk](https://github.com/franciscojavierarceo/Python/assets/4163062/f2238891-30aa-4a88-8147-3fc887966221)\n\n## Data Details \nThis example uses Feast's pre-generated mock data for driver metrics.\n\nThe data looks something like the sample below (the time stamp may differ)\n```\n            event_timestamp  driver_id  conv_rate  acc_rate  avg_daily_trips                 created\n0 2022-04-13 21:00:00+00:00       1005   0.409039  0.631994              359 2022-04-28 21:29:55.788\n1 2022-04-13 22:00:00+00:00       1005   0.524565  0.317398              297 2022-04-28 21:29:55.788\n2 2022-04-13 23:00:00+00:00       1005   0.300072  0.376808              295 2022-04-28 21:29:55.788\n3 2022-04-14 00:00:00+00:00       1005   0.533681  0.984958              727 2022-04-28 21:29:55.788\n4 2022-04-14 01:00:00+00:00       1005   0.999158  0.559122              745 2022-04-28 21:29:55.788\n```\n\nI generate additional samples of this data using some very trivial scripts to simulate what happens in live customer-facing experiences and what happens behind the scenes through common batch jobs.\n\n## Feast UI\n\nThis demo uses Feast 0.28.0 which means you can render a Feast UI by simply running.\n```\nfeast ui\n```\n\nYou'll notice that the feature views are nicely documented. 👍\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzseta%2Ffeast-driver-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzseta%2Ffeast-driver-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzseta%2Ffeast-driver-demo/lists"}