Git Product home page Git Product logo

new-york-taxi-fare-prediction's Introduction

new-york-taxi-fare-prediction

Predicting Taxi Fares of New York City and deploying it on ServiceFoundry

Useful Links

Taxi Fare Prediction model Deployment Video

Link to Live Demo

Colab Notebook

Blog with instructions on the run (Coming Soon)

Description of the problem

The aim is the predict the taxi fares of New York with input features like pickup & dropoff co-ordinates, passenger count & the timestamp.

Dataset Description

Here is link to the Kaggle Dataset: https://www.kaggle.com/competitions/new-york-city-taxi-fare-prediction

Sample Data:

1665543865574

Model Trained

We trained a XGBRegressor model. The model is trained using xgboost library and is deployed on the cloud using ServiceFoundry ๐Ÿš€

Instructions to deploy on ServiceFoundry

Setting up servicefoundry

Install and setup servicefoundry on your computer.

pip install servicefoundry

servicefoundry use server https://app.develop.truefoundry.tech

servicefoundry login
Training model

To deploy using the python API run the following command in terminal

  1. Change working directory to train folder

cd train

  1. Create workspace and API key on the TrueFoundry platform
  2. Replace the MLF_API_KEY value in the train.yaml file with the API Key found in secrets tab of your TrueFoundry account and it it in the train.yaml file <i>(Instructions here)</i>
  3. Copy the workspace fqn of the workspace that you want to use from the workspace tab of TrueFoundry <i>(Instructions here) and add it in the train.yaml file </i>
  4. To deploy using python script:

python train_deploy.py

To deploy using CLI:


servicefoundry deploy --file train_deploy.yaml

  1. Click on the dashboard link in the terminal
  2. Click on the <b>"Trigger Job"</b> on the dashboard to run the training job
Deploying realtime inference

Note: <i>It is necessary to train a model before being able to deploy it as a service </i>

  1. Change working directory to infer_realtime folder

cd infer_realtime

  1. Create workspace and API key on the TrueFoundry platform
  2. Replace the MLF_API_KEY value in the infer_realtime_deploy.py file with the API Key found in secrets tab of your TrueFoundry account and add it in infer.yaml file <i>(Instructions here)</i>
  3. Copy the workspace_fqn of the workspace that you want to use from the workspace tab of TrueFoundry <i>(Instructions here) and add it in infer.yaml file </i>
  4. Find the model_version_fqn of the model that you want to deploy from
  • Go to experiments tracking tab of TrueFoundry
  • Click on the project name that you trained (<i>taxi-fare-train by default </i>)
  • Click on models tab
  • Click on the model name to the model trained to open the tab showing different versions of the model
  • Copy the FQN of the latest version of the model
  • Add the latest version in the infer.yaml file
  1. To deploy using python script:

python infer_deploy.py

To deploy using CLI:


servicefoundry deploy --file infer/infer_deploy.yaml

  1. Click on the dashboard link in the terminal to open the service deployment page with FastAPI EndPoint
Querying the deployed model

This can either be done via the fastapi endpoint directly via browser.

You can also query with python script:

request_url = "https://taxi-fare-infer-vishank-betatest-ws.tfy-ctl-euwe1-develop.develop.truefoundry.tech"

features= {

"pickup_datetime":"2015-01-27 13:08:24 UTC",

"pickup_latitude":40.7638053894043,

"pickup_longitude":-73.973320007324219,

"dropoff_latitude":40.74383544921875,

"dropoff_longitude":-73.981430053710938,

"passenger_count":3

}

  

predictions_list = requests.post(

url=urljoin(request_url, "/predict"), json=features

).json()
Deploying Demo

Note: <i>It is necessary to deploy live inference model before being able to deploy a demo </i>

  1. Create workspace and API key on the TrueFoundry platform
  2. Replace the MLF_API_KEY value in the infer_realtime_deploy.py file with the API Key found in secrets tab of your TrueFoundry account and add it in the demo.yaml file <i>(Instructions here)</i>
  3. Copy the workspace_fqn of the workspace that you want to use from the workspace tab of TrueFoundry and add it in the train.yaml file <i>(Instructions here)</i>
  4. Copy the inference_server_url from:
  • Go to deployment tab of TrueFoundry
  • Open the service that was deployment as live inference model <i>("taxi-fare-prediction" by default)</i>
  • Copy the Endpoint link
  1. To deploy using python script:

python demo/demo_deploy.py

To deploy using CLI:


servicefoundry deploy --file demo/demo_deploy.yaml

  1. Click on the dashboard link in the terminal
  2. Click on the <b>"Endpoint"</b> link on the dashboard to open the streamlit demo

new-york-taxi-fare-prediction's People

Contributors

vishank97 avatar

Stargazers

Roman avatar

Watchers

 avatar

Forkers

cheemsingh

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.