TensorFlow Basics-Linear Regression

Linear regression data model

Insert image description here
Insert image description here

The value of β0 (also called the intercept) shows the point at which the estimated regression line crosses the y-axis, while the value of β1 determines the slope of the estimated regression line. The random error
describes the random component of the linear relationship between the dependent variable and the independent variable (the model's perturbation, part y that x
cannot explain). The true regression model is usually unknown (because we cannot capture all effects that affect the dependent variable), so the values ​​of the random error terms corresponding to the observed data points remain unknown. However, a regression model can be estimated by computing the parameters of the model for the observed data set.

The idea behind regression is to estimate the parameters β0 and β1 from the sample. If we are able to determine the best values ​​of these two parameters, we will have a line of best fit that
can be used to predict the value of y , given the value of X. In other words, we try to fit a line to observe the relationship between input and output variables and then further use it to predict the output of unseen inputs.

Insert image description here
Reference: https://blog.csdn.net/weixin_39638014/article/details/111044762

Linear regression model implementation

1. Read data

import pandas as pd
import numpy as np
from PIL import Image
from sklearn.model_selection import train_test_split
from matplotlib import pyplot as plt
from tensorflow.keras.layers import Activation,Dense, Flatten, Input
from tensorflow.keras import Model
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.utils import to_categorical 

# 读取CSV文件
CsvFile = pd.read_csv('./master_file.csv')

# 查看csv数据结构
CsvFile.head()

Insert image description here

CsvFile.hist()

Guess you like

Origin blog.csdn.net/Super_RD/article/details/123307382