top of page

Coding Demo

Step 1 - Go to https://jupyter.org/try

Before starting code, download the file first.

Step 2 - Click on Try Classic Notebook

Demo01.png

Step 3 - Go to file open.

Demo02.png

Step 4 - Upload the downloaded file.

Step 5 - Go to your Jupiter Notebook and click on + button as displayed below. At the end new cell will be added.

Demo03.png

Step 6 - Copy the code below and paste in the cell.

# import libraries

import numpy as np

import pandas as pd

from sklearn.linear_model import LinearRegression

from sklearn import metrics

 

# Read the dataset from csv file

df1 = pd.read_csv('ds.csv')

df1.head()

Step 7 - Click on Run Button and you will see the data.

Demo04.png

Step 8 - Click on + sign to create new cell and paste the below code.

# Features

X = df1.drop(['MEDV', 'ID'], axis = 1)

# Target

y = df1['MEDV']

 

# Create a model

lr = LinearRegression()

# Fit the model

lr.fit(X, y) 

# make predictions

pred = lr.predict(X)

Step 9 - Click on Run button.

Step 10 - Click on + sign to create new cell and paste the below code.

features = [[0.06, 14, 6, 0, 0.5, 6, 22, 7, 4, 900, 19, 3690, 8]]

print('The predicted price:', lr.predict(features)[0])

Step 11 - Click on Run button.

See the output.

The predicted price: 40.54991636423439

.

bottom of page