没有合适的资源?快使用搜索试试~ 我知道了~
Programming Exercise(代码作业)1
需积分: 0 0 下载量 65 浏览量
2022-08-03
14:57:14
上传
评论
收藏 2.59MB PDF 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/86288373/0001-1208c54b91387ffde68ee65edc9ea78e_thumbnail.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
118页
Programming Exercise 3:Multi-class Classification and Neural Networks .... 29Pro
资源详情
资源评论
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/86288373/bg1.jpg)
Machine Learning
(Programming Exercise)
Andrew Ng
Stanford University
![](https://csdnimg.cn/release/download_crawler_static/86288373/bg2.jpg)
Contents
Programming Exercise 1: Linear Regression ................................................. 1
Programming Exercise 2: Logistic Regression ............................................. 16
Programming Exercise 3:Multi-class Classification and Neural Networks .... 29
Programming Exercise 4:Neural Networks Learning .................................... 41
Programming Exercise 5:Regularized Linear Regression and Bias v.s.
Variance ....................................................................................................... 56
Programming Exercise 6:Support Vector Machines ..................................... 70
Programming Exercise 7:K-means Clustering and Principal Component
Analysis ........................................................................................................ 86
Programming Exercise 8:Anomaly Detection and Recommender Systems
..................................................................................................................... 102
![](https://csdnimg.cn/release/download_crawler_static/86288373/bg3.jpg)
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 to change to this directory
before starting this exercise.
You can also find instructions for installing Octave on the “Octave In-
stallation” page on the course website.
Files included in this exercise
ex1.m - Octave script that will help step you through the exercise
ex1 multi.m - Octave 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
[?] 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 extra credit exercises
1
1
![](https://csdnimg.cn/release/download_crawler_static/86288373/bg4.jpg)
Throughout the exercise, you will be using the scripts ex1.m and ex1 multi.m.
These scripts set up the dataset for the problems and make calls to functions
that you will write. You do not need to modify either of them. You are only
required to modify functions in other files, by following the instructions in
this assignment.
For this programming exercise, you are only required to complete the first
part of the exercise to implement linear regression with one variable. The
second part of the exercise, which you may complete for extra credit, covers
linear regression with multiple variables.
Where to get help
The exercises in this course use Octave,
1
a high-level programming language
well-suited for numerical computations. If you do not have Octave installed,
please refer to the installation instructons at the “Octave Installation” page
on the course website.
At the Octave command line, typing help followed by a function name
displays documentation for a built-in function. For example, help plot will
bring up help information for plotting. Further documentation for Octave
functions can be found at the Octave documentation pages.
We also strongly encourage using the online Q&A Forum to discuss
exercises with other students. However, do not look at any source code
written by others or share your source code with others.
1 Simple octave function
The first part of ex1.m gives you practice with Octave syntax and the home-
work submission process. In the file warmUpExercise.m, you will find the
outline of an Octave function. Modify it to return a 5 x 5 identity matrix by
filling in the following code:
A = eye(5);
When you are finished, run ex1.m (assuming you are in the correct direc-
tory, type “ex1” at the Octave prompt) and you should see output similar
to the following:
1
Octave is a free alternative to MATLAB. For the programming exercises, you are free
to use either Octave or MATLAB.
2
2
![](https://csdnimg.cn/release/download_crawler_static/86288373/bg5.jpg)
ans =
Diagonal Matrix
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
Now ex1.m will pause until you press any key, and then will run the code
for the next part of the assignment. If you wish to quit, typing ctrl-c will
stop the program in the middle of its run.
1.1 Submitting Solutions
After completing a part of the exercise, you can submit your solutions for
grading by typing submit at the Octave command line. The submission
script will prompt you for your username and password and ask you which
files you want to submit. You can obtain a submission password from the
website’s “Programming Exercises” page.
You should now submit the warm up exercise.
You are allowed to submit your solutions multiple times, and we will take
only the highest score into consideration. To prevent rapid-fire guessing, the
system enforces a minimum of 5 minutes between submissions.
2 Linear regression with one variable
In this part of this exercise, you will implement linear regression with one
variable to predict profits for a food truck. Suppose you are the CEO of a
restaurant franchise and are considering different cities for opening a new
outlet. The chain already has trucks in various cities and you have data for
profits and populations from the cities.
You would like to use this data to help you select which city to expand
to next.
3
3
剩余117页未读,继续阅读
![avatar](https://profile-avatar.csdnimg.cn/9968d1675c3141c3a6402080bcaa9a37_weixin_35796461.jpg!1)
天使的梦魇
- 粉丝: 32
- 资源: 321
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)
评论0