Examples

Regression project with python

In this example we are going to use a database of used car sales in the UK, to predict the market value of an used car. The data set can be found here: https://www.kaggle.com/adityadesai13/used-car-dataset-ford-and-mercedes . for simplicity and for ilustration purposes, we are going to use only the Audi brand.

Our CSV file data.csv looks like this (just the top lines shown for brevity):

model,year,transmission,mileage,fuelType,tax,mpg,engineSize,price
A1,2017,Manual,15735,Petrol,150,55.4,1.4,12500
A6,2016,Automatic,36203,Diesel,20,64.2,2,16500
A1,2016,Manual,29946,Petrol,30,55.4,1.4,11000
A4,2017,Automatic,25952,Diesel,145,67.3,2,16800
A3,2019,Manual,1998,Petrol,145,49.6,1,17300
...

Our target variable is the last column price.

In order to see iktera in action, we are going to set a few example rows aside so we can run predictions on them. You don't need to do this. We remove the last ten lines of our CSV file and paste them in separate file, examples.csv. This is just for ilustrative purposes. If you want to know the performance of your model, you can check its Mean Absolute Percentage Error on the project page.

examples.csv contents:

A3,2016,Manual,39750,Petrol,30,57.6,1.4,14995
A6,2018,Semi-Auto,27500,Petrol,150,39.8,2,27995
A4,2011,Automatic,78000,Diesel,305,39.8,3,9995
A4,2011,Manual,95000,Diesel,145,53.3,2,6995
A3,2013,Manual,31500,Petrol,125,53.3,1.4,12695
A3,2020,Manual,4018,Petrol,145,49.6,1,16999
A3,2020,Manual,1978,Petrol,150,49.6,1,16999
A3,2020,Manual,609,Petrol,150,49.6,1,17199
Q3,2017,Automatic,8646,Petrol,150,47.9,1.4,19499
Q3,2016,Manual,11855,Petrol,150,47.9,1.4,15999

Creating your project

Creating a machine learning project on iktera takes just a few seconds. On your dashboard, click the "Create new Project" button. Pick a name of your choice. Select "regression" option as your project type and chose your CSV file. That's it! You model is ready to use.

Running predictions via Iktera's HTTP API

Requirements

This example uses Python 3 and requests HTTP library.

Install requests library.

pip3 install requests

For alternative installation options, refer to requests documentation.

Authenticating

In order to use Iktera's api you need to create an api key. Create one here: https://iktera.com/dashboard/api.

Once you have it, you can use to retrieve a token you can use in subsequent API calls.

api_url = "https://iktera.com/api"
api_key = "YRE0psgvCfLlDSSb8EnUptYibUfwtDSKkTnMOeuodj2kd3Cs6F3OFoyuZFkv"
response = requests.post(api_url + "/token?key=" + api_key)
token = response.json()['access_token']

Running predictions

We can now use the token to run predictions.

Let's ask our model to predict the price of one of the examples:


predict_url = api_url + "/predict?project_id=" + project_id
data = { "input": ["A3",2016,"Manual",39750,"Petrol",30 , 57.6 ,1.4] }
headers = {
	'Authorization': "Bearer " + token,
	'Content-Type': 'application/json'
}
response = requests.post( predict_url , headers=headers, json=data)
print(response.text)

This will output:

[[10866.660750955343]]

The model predicted the price of this car is £10867.