吴恩达机器学习编程题ex1上 单变量线性回归: (python版含题目要求、代码、注解)

不得不说安卓老师是真的用心良苦,给我们把编程题弄成了填空题,但是很可惜原版使用的是OctaveMATLAB所以作为初学者我就直接当编程题用python去做了

问题:让你绘制一个5阶单位阵

答案:

 

 

在本练习的这一部分,你将应用线性回归来实现通过用一个变量x(人口)预测y(食品卡车的利润)。假设你是一位首席执行官,餐饮连锁店正在考虑不同的城市开设新的出口。这个连锁已经把卡车开到了各个城市,现在你有来自城市的利润和人口的数据了。你希望使用这些数据来帮助你选择扩展哪个城市。

你希望通过这些数据来辅助你决定下一步选择扩展哪个城市。

文件EX1DATA1.TXT包含了我们的线性回归问题的数据集。第一列是城市的人口,第二列是那个城市的食品卡车的利润。利润的负值表示损失。

 

 

在开始任何任务之前,通过数据可视化来理解数据是有很有用的。对于这个数据集,可以使用散点图来可视化他。因为它只只有两个属性需要绘制(利润和人口)。

而在现实生活中你会遇到很多其他问题是不能在二维图上绘制的。

EX1.M中,将数据集从数据文件加载到变量X中和Y

问题:让你绘制一个数据集的散点图

答案:

  • 3
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
Programming Exercise 1: Linear Regression Machine Learning Introduction In this exercise, you will implement linear regression and get to see it work on data. Before starting on this programming exercise, we strongly recom- mend watching the video lectures and completing the review questions for the associated topics. To get started with the exercise, you will need to download the starter code and unzip its contents to the directory where you wish to complete the exercise. If needed, use the cd command in Octave/MATLAB to change to this directory before starting this exercise. You can also find instructions for installing Octave/MATLAB in the “En- vironment Setup Instructions” of the course website. Files included in this exercise ex1.m - Octave/MATLAB script that steps you through the exercise ex1 multi.m - Octave/MATLAB script for the later parts of the exercise ex1data1.txt - Dataset for linear regression with one variable ex1data2.txt - Dataset for linear regression with multiple variables submit.m - Submission script that sends your solutions to our servers [?] warmUpExercise.m - Simple example function in Octave/MATLAB [?] plotData.m - Function to display the dataset [?] computeCost.m - Function to compute the cost of linear regression [?] gradientDescent.m - Function to run gradient descent [†] computeCostMulti.m - Cost function for multiple variables [†] gradientDescentMulti.m - Gradient descent for multiple variables [†] featureNormalize.m - Function to normalize features [†] normalEqn.m - Function to compute the normal equations ? indicates files you will need to complete † indicates optional exercises
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值