/ML-bookcamp-capstone

Capstone for ML-bookcamp

Primary LanguageJupyter Notebook

Project info

In this project we're predicting Co^2 emissions for car. Giving some car feautres such as cylinders, engine size, transmission etc, predicting CO2 emissions.

Data And Variable

Model

4WD/4X4 = Four-wheel drive AWD = All-wheel drive FFV = Flexible-fuel vehicle SWB = Short wheelbase LWB = Long wheelbase EWB = Extended wheelbase

Transmission

A = Automatic AM = Automated manual AS = Automatic with select shift AV = Continuously variable M = Manual 3 - 10 = Number of gears

Fuel type

X = Regular gasoline Z = Premium gasoline D = Diesel E = Ethanol (E85) N = Natural gas

Fuel Consumption

City and highway fuel consumption ratings are shown in litres per 100 kilometres (L/100 km) - the combined rating (55% city, 45% hwy) is shown in L/100 km and in miles per gallon (mpg)

Data and variable explanation source: Kaggle

File Descriptions

  • notebook.ipynb Notebook contains data preparation, EDA, parameter tuning,model selection and saving model.
  • predict.py Python file contains model file and serving as Flask app.
  • predict_test.py Python file contains one observation for CO2 emissions. (local solution)
  • cloud_predict.py Python file contains model for one observation and includes cloud endpoint. (cloud solution)
  • requirements.txt Txt file contains all dependencies for notebook.ipynb and predictions scripts.

Preparing Python Environments

git clone https://github.com/yusyel/ML-bookcamp-capstone.git
cd ML-bookcamp-capstone

Activate python environments

pipenv shell

In python environment installing python dependency:

pip install -r requirements.txt

Preparing And Running Docker Image

For building docker image:

docker build -t capstone .

After building docker image you can run docker image with this command:

docker run -it --rm -p 9696:9696 capstone 

Runing Predictions File

While docker container running In your python shell:

python3 predict_test.py
curl -X POST http://localhost:9696/predict \
-H 'Content-Type: application/json' \
-d '{"vehicle_class": "subcompact", "engine_size": "1.5", "cylinders": 3, "fuel_consumption_city": 9, "fuel_consumption_hwy": "6.3", "fuel_consumption_comb_mpg": "38"}'

Cloud test. cloud_predict.py contains server endpoint.

python3 cloud_predict.py
  • cloud deployment I choose Azure. Screnshoot contanins endpoint and returning predictions.
curl -X POST https://ml-capstone.azurewebsites.net/predict \
-H 'Content-Type: application/json' \
-d '{"vehicle_class": "subcompact", "engine_size": "1.5", "cylinders": 3, "fuel_consumption_city": 9, "fuel_consumption_hwy": "6.3", "fuel_consumption_comb_mpg": "38"}'
  • I choose Azure for cloud deployment. Screnshoot contanins endpoint and returning predictions.

Screenshot

Video

https://raw.githubusercontent.com/yusyel/ML-bookcamp-capstone/master/cloud.mp4