Linear Regression using Turicreate
Last Updated :
02 Jun, 2021
Linear Regression is a method or approach for Supervised Learning.Supervised Learning takes the historical or past data and then train the model and predict the things according to the past results.Linear Regression comes from the word ‘Linear’ and ‘Regression’.Regression concept deals with predicting the future using the past data.Linear means the able to represented by a straight line on graph.Linear Regression has two things one independent variable and other dependent variable and Linear Regression is a relationship between the two.
In this article, we are going to learn about how we can implement Linear Regression with the help of Turicreate. Turicreate is Library in Python which helps the beginners to learn and implement Machine Learning Algorithm easily as well as efficiently.
Step 1: Importing the Turicreate Library
Step 2: Reading the datasets.
Python3
data_sets = tc.SFrame( "data.csv" )
|
Link for the data is=https://www.kaggle.com/mirichoi0218/insurance
Step 3: Exploring the data
Output:
datasets first few lines
Step 4: Make a Linear Regression model .
Python3
model = tc.linear_regression.create(
data, target = "charges" , features = [ 'region' ])
|
Step 5: Now evaluate the model
Output:
Max error and Rmse
Step 6: Now predicting the charges according to the B.M.I of person
Python3
bmi_person = data[data[ 'bmi' ] = = 27.9 ]
model.predict(bmi_person)
|
Output:
The Prediction of the charges
Share your thoughts in the comments
Please Login to comment...