mdiannna / Lab4_AI_UTM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lab4_AI_UTM

Lab 4 for the Fundamentals of Artificial Ingelligence Course at Technical University of Moldova.

Table of contents

Introduction

This laboratory work is based on using LinearRegression model to predict apartment prices, based on a dataset of numeric data, and deploying it to cloud. This project implements a continuous integration/delivery pipeline, using Heroku and Github actions.

Technologies

  • Python
  • Scikit-learn
  • Pandas
  • Numpy
  • Sanic framework
  • Heroku

How to use

The system is available as a HTTP REST API, with 3 routes available:

  • POST /train
  • POST /evaluate
  • POST /predict

The system can be used with curl requests - on the online server:

  • Example of POST /train request with curl on local server:

$ curl -X POST -F 'model_name=my_reg_model.sav' -F 'col_to_predict=medianCompexValue' -F 'dataset_path=https://raw.githubusercontent.com/mdiannna/Labs_UTM_AI/main/Lab3/apartmentComplexData.txt' -F 'column_names=['col1', 'col2', 'complexAge', 'totalRooms', 'totalBedrooms', 'complexInhabitants', 'apartmentsNr', 'col8', 'medianCompexValue']' https://linear-regression-diana-utm.herokuapp.com/train

  • Example of POST /predict request with curl:

$ curl -X POST -F 'model_name=my_reg_model.sav' -F 'data=[-122.250000,37.850000,52.000000,1274.000000,235.000000,558.000000,219.000000,5.643100] ' https://linear-regression-diana-utm.herokuapp.com/predict

  • Example of POST /evaluate request with curl:

$ curl -X POST -F 'model_name=my_reg_model.sav' -F 'col_to_predict=medianCompexValue' -F 'dataset_path=https://raw.githubusercontent.com/mdiannna/Labs_UTM_AI/main/Lab3/apartmentComplexData.txt' -F 'column_names=['col1', 'col2', 'complexAge', 'totalRooms', 'totalBedrooms', 'complexInhabitants', 'apartmentsNr', 'col8', 'medianCompexValue']' https://linear-regression-diana-utm.herokuapp.com/evaluate

The system can be used with curl requests - on local server:

  • Example of POST /train request with curl on local server:

$ curl -X POST -F 'model_name=my_reg_model.sav' -F 'col_to_predict=medianCompexValue' -F 'dataset_path=https://raw.githubusercontent.com/mdiannna/Labs_UTM_AI/main/Lab3/apartmentComplexData.txt' -F 'column_names=['col1', 'col2', 'complexAge', 'totalRooms', 'totalBedrooms', 'complexInhabitants', 'apartmentsNr', 'col8', 'medianCompexValue']' http://localhost:5000/train

  • Example of POST /predict request with curl:

$ curl -X POST -F 'model_name=my_reg_model.sav' -F 'data=[-122.250000,37.850000,52.000000,1274.000000,235.000000,558.000000,219.000000,5.643100] ' http://localhost:5000/predict

  • Example of POST /evaluate request with curl:

$ curl -X POST -F 'model_name=my_reg_model.sav' -F 'col_to_predict=medianCompexValue' -F 'dataset_path=https://raw.githubusercontent.com/mdiannna/Labs_UTM_AI/main/Lab3/apartmentComplexData.txt' -F 'column_names=['col1', 'col2', 'complexAge', 'totalRooms', 'totalBedrooms', 'complexInhabitants', 'apartmentsNr', 'col8', 'medianCompexValue']' http://localhost:5000/evaluate

Troubleshooting

If there are some problems with heroku deploy, login and try the following command:

$heroku ps:scale web=1 --app=linear-regression-diana-utm

Bibliography and resources

About


Languages

Language:Jupyter Notebook 99.1%Language:Python 0.9%