【2023年】第29天 Supervised Learning with TensorFlow 1(用TensorFlow进行监督学习 1)

2023/6/18 21:22:10

本文主要是介绍【2023年】第29天 Supervised Learning with TensorFlow 1(用TensorFlow进行监督学习 1),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1.What Is Supervised Machine Learning? 什么是监督学习?

Machine learning is a part of artificial intelligence (AI) and mainly comprises three types:
机器学习是人工智能(AI)的一部分,主要包括三种类型。包括三种类型:

  • Supervised machine learning 监督学习
  • Unsupervised machine learning 非监督学习
  • Reinforcement learning 强化学习
    In the machine world, supervised learning is done by providing a machine inputs and labels and asking it to learn from them.
    在机器世界中,监督学习是通过向机器提供输入和标签并要求它从中学习来完成的。
    Supervised learning usually comprises two phases: training and testing/prediction.
    监督学习通常包括两个阶段:训练和测试/预测。
    In the training phase, a set of the total data, called a training set, is provided to the machine learning algorithm, made up of input data (features) as well as output data (labels).
    在训练阶段,一组被称为训练集的总数据被提供给机器学习算法,由输入数据(特征)以及输出数据(标签)组成。
    The aim of the training phase is to make sure the algorithm learns as much as possible from the input data and forms a mapping between input and output, such that it can be used to make predictions.
    训练阶段的目的是确保算法尽可能多地从输入数据中学习,并在输入和输出之间形成映射,这样就可以用来进行预测了。
    In the test/prediction phase, the remaining set of data, called a test set, is provided to the algorithm and comprises only the input data (features) and not the labels.
    在测试/预测阶段,剩下的数据集,称为测试集,被提供给算法,只包括输入数据(特征),不包括标签。
    The aim of the test/prediction phase is to check how well the model is able to learn and generalize.
    测试/预测阶段的目的是检查模型的学习和概括能力如何。
    If the accuracy of the training and test sets differs too much, we can infer that the model might have mapped the input and output of training data too closely, and, therefore, it was not able to generalize the unseen data (test set) well.
    如果训练集和测试集的准确度相差太大,我们可以推断,模型可能将训练数据的输入和输出映射得太紧密,因此,它不能很好地概括未见过的数据(测试集)。
    This is generally known as overfitting.
    这通常被称为过拟合。
    A typical supervised machine learning architecture is shown in Figure.
    一个典型的监督式机器学习架构如图所示。
    图片描述
    Within supervised learning, if we are to predict numeric values, this is called regression, whereas if we are to predict classes or categorical variables, we call that classification.
    在监督学习中,如果我们要预测数值,这被称为回归,而如果我们要预测类别或分类变量,我们称之为分类。
    For example, if the aim is to predict the sales (in dollars) a company is going to earn (numeric value), this comes under regression.
    例如,如果目的是预测一个公司将获得的销售额(以美元计)(数值),这属于回归。
    If the aim is to determine whether a customer will buy a product from an online store or to check if an employee is going to churn or not (categorical yes or no), this is a classification problem.
    如果目的是确定一个客户是否会从网上商店购买产品,或者检查一个员工是否会流失(分类的是或不是),这是一个分类问题。
    Classification can be further divided as binary and multi-class.
    分类可以进一步划分为二元和多元两类。
    Binary classification deals with classifying two outcomes, i.e., either yes or no. Multi-class classification yields multiple outcomes.
    二元分类涉及对两个结果的分类,即是或不是。多级分类则产生多种结果。
    For example, a customer is categorized as a hot prospect, warm prospect, or cold prospect, etc.
    例如,一个客户被归类为热的潜在客户、温暖的潜在客户或冷的潜在客户,等等。

2.Linear Regression with TensorFlow 2.0 用TensorFlow 2.0进行线性回归

In linear regression, as with any other regression problem, we are trying to map the inputs and the output, such that we are able to predict the numeric output.
在线性回归中,与其他回归问题一样,我们试图映射输入和输出,这样我们就能预测数字输出。
We try to form a simple linear regression equation:
我们尝试建立一个简单的线性回归方程:
y = mx + b
In this equation, y is the numeric output that we are interested in, and x is the input variable, i.e., part of the features set.
在这个方程中,y是我们感兴趣的数字输出,x是输入变量,也就是特征集的一部分。
m is the slope of the line, and b is the intercept.
m是直线的斜率,b是截距。
For multi-variate input features (multiple linear regression), we can generalize the equation, as follows:
对于多变量输入特征(多元线性回归),我们可以将该方程概括如下:
y = m1 x1 + m2 x2+ m3x3 + … + mnxn + b
where x1, x2, x3, …, xn are different input features, m1, m2, m3, … mn are the slopes for different features, and b is the intercept.
其中x是不同的输入特征,m是不同特征的斜率,b是截距。
图片描述
Here, we can clearly see that there is a linear relation between label y and feature inputs X.



这篇关于【2023年】第29天 Supervised Learning with TensorFlow 1(用TensorFlow进行监督学习 1)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程