12. TensorFlow Tutorial---Linear Regression

In this chapter, we will focus on basic examples of linear regression using TensorFlow. Logistic regression or linear regression is a supervised machine learning method used to classify ordered discrete categories. The goal of this chapter is to build a model that allows the user to predict the relationship between independent variables and one or more dependent variables.

The relationship between these two variables is considered linear. If y is the dependent variable and x is considered as the independent variable, then the linear regression relationship between these two variables is shown in the equation below −

Y = Ax + b

We will design an algorithm for linear regression. This will enable us to understand the following two important concepts -

1. Loss function
2. Gradient descent algorithm

The schematic representation of linear regression is as follows −

The graphical view of the linear regression equation is shown below −

Steps in Designing a Linear Regression Algorithm
Now, we will learn the steps that will help in designing a linear regression algorithm.

Step 1
It is important to import the necessary modules to plot the linear regression model. We start by importing the Python libraries NumPy and Matplotlib.

import numpy as np 
import matplotlib.pyplot as plt

Step 2
defines the number of coefficients required for logistic regression.

number_of_points = 500 
x_point = [] 
y_point = [] 
a = 0.22 
b = 0.78</

Guess you like

Origin blog.csdn.net/Knowledgebase/article/details/133433099