Regression

本文深入探讨了回归分析的基本原理和应用,包括线性回归、逻辑回归等方法,以及如何在实际问题中运用这些统计工具进行预测和数据分析。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//李宏毅视频官网:http://speech.ee.ntu.edu.tw/~tlkagk/courses.html                                                    点击此处返回总目录

//邱锡鹏《神经网络与深度学习》官网:https://nndl.github.io

 

 

 

今天主要讲的是Regression。会通过一个例子讲Regression是怎么用的,顺便引出Machine Learning里面的一些重要概念。

-------------------------------------------------------------------------------------------------------------------------------

首先,Regression可以做什么?除了作业里面的可以预测PM2.5以外,还有很多非常有用的task:

举例来说,股票预测系统。如果要做股票预测系统的话,要做的事情就是找到一个function,这个function的input可能是过去十年各种股票起伏的资料或者是公司并购的信息。希望这个function在input这些资料之后,output呢,是明天的道琼斯工业平均指数。

 

 

另一个例子就是现在很火的无人驾驶,也可以想为Regression的例子。input是无人车看到的各种场景(包括红外线感受到的场景、摄像头拍摄到的场景等),output是方向盘旋转的角度。

 

 

另外一个例子就是推荐系统,也可以想象成Regression的问题。输入是使用者A浏览商品B或者A购买B的记录,输出是使用者A买商品B的可能性。这样就可以推荐给用户最有可能购买的商品。

 

-------------------------------------------------------------------------------------------------------------------------------

上面是Regression的种种应用,今天我们要讲一个更实用的应用:预测宝可梦进化后的CP值。

 

                         

CP值就是战斗力。当我们抓到一只宝可梦之后,给它吃一些东西,它就会进化,进化之后CP值就会变了。

 

为什么我们希望预测进化后的CP值呢?因为如果我们能够预测进化后的CP值,我们就可以评估是否选择进化这只宝可梦。如果某一只宝可梦进化后的CP值预测的比较低,那就不去进化它了,就可以省下食物了~~

 

今天要做的事情就是,找到一个function,input为一只宝可梦的信息,output是这只宝可梦进化后的CP值。

x       表示一只宝可梦。

  表示这只宝可梦进化前的CP值,图中为14。 //我们用下标表示一个完整的东西里面的某一部分。csdn没法写下标,所以截图了。

   表示物种。图中这只宝可梦是妙蛙种子。

  表示生命值。图中这只宝可梦生命值为10。

   表示重量。

   表示高度。

 

怎么解决这个问题呢?我们知道(第一堂课讲过)做meahine learning就是3个步骤:

1.找到一个model。model就是function的集合。

2.从model中拿一个function,可以evaluate它的好坏。

3.找一个最好的function。

 

------------------------------------------------------------------------------------------------------------------------------- 

首先从第一步开始,Step1:Model。

 

一个model,就是一个function set。一个model里面有很多个function f1,f2...

            

在这个task里面,我们的model应该长什么样呢?

我们先胡乱写一个:

                                           (1)

即,进化后的值y等于某个常数b加上w乘以进化前的cp值。w和b是参数,可以是任意的数值。

在这个model里面,w和b是未知的,可以把任意的数字填进去。填进不同的数值就得到了不同的function。比如,当b = 10.0,w = 9.0时为f1,当b = 9.8, w=9.2时为f2,...如果b和w可以带任何值的话,function可以有无穷个。用式子(1)代表这些function的集合。

            

在这些function中,显然有一些是不太正确的,比如f3,当进化前cp为正的,进化后变成了负的,这显然是说不通的。这就是后面要靠training data告诉我们这些function里面哪一个才是合理的function。

 

(1)这样的model是一种linear model。所谓的linear model,简单来说,是指我们可以把一个function写成如下形式:                       

             

     其中,代表x的不同的属性,叫做feature。

 

-------------------------------------------------------------------------------------------------------------------------------

 我们要收集training data才能够找出这个function。这是一个supervised learning,所以要收集的是function的input和output。

因为这是一个Regression的task,所以output是一个数值。

举例来说,当抓了一只杰尼龟,用来表示它。         //我们上标来表示一个完整的个体的编号。

杰尼龟进化为卡咪龟,杰尼龟进化后的cp值为979,用

### Network Regression in Machine Learning or Deep Learning Network regression refers to a type of supervised learning problem where the goal is to predict continuous-valued outputs based on input features. In both machine learning and deep learning, network regression can be implemented using various algorithms such as linear regression, neural networks, decision trees, etc., depending on the complexity of the data and the desired accuracy. In the context of machine learning, one common approach involves utilizing libraries like `scikit-learn` for implementing simple models. For instance, consider the following example that demonstrates how to perform linear regression: ```python import numpy as np from sklearn.linear_model import LinearRegression from sklearn.preprocessing import StandardScaler # Generate random dataset with noise np.random.seed(1) X = np.random.rand(100, 1) * 2 - 1 epsilon = np.random.randn(*X.shape) * 0.1 y = np.sin(np.pi * X) + epsilon # Scale the inputs scaler = StandardScaler() X_scaled = scaler.fit_transform(X) # Initialize and fit the model model = LinearRegression() model.fit(X_scaled, y.ravel()) # Predictions predictions = model.predict(X_scaled) ``` This code snippet illustrates generating synthetic data, scaling it appropriately, fitting a linear regression model, and making predictions accordingly[^2]. For more complex scenarios involving non-linear relationships between variables, artificial neural networks (ANNs), particularly those incorporating activation functions like ReLU, are often employed within deep learning frameworks. These ANNs consist of multiple layers—input layer(s), hidden layer(s), output layer—and employ backpropagation along with optimization techniques during training phases to adjust weights iteratively until convergence criteria are met[^3]. Hyperparameters play an essential role here; they include but not limited to learning rate (`learningrate`) controlling step size at each iteration while moving toward minimizing loss function value over epochs count among others affecting overall performance significantly when tuning these settings manually versus automated methods available today through tools provided by TensorFlow/Keras API packages designed specifically around simplifying this process further without losing flexibility needed per project requirements individually tailored solutions possible too!
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值