Machine learning吴恩达第二周coding作业(选做)
1.Feature Normalization:
归一化的处理
function [X_norm, mu, sigma] = featureNormalize(X)
%FEATURENORMALIZE Normalizes the features in X
% FEATURENORMALIZE(X) returns a normalized version of X where
% the mean value of each feature is 0 and the standard deviation
% is 1. This is often a good preprocessing step to do when
% working with learning algorithms. % You need to set these values correctly
X_norm = X;
mu = zeros(1, size(X, 2));
sigma = zeros(1, size(X, 2)); % ====================== YOUR CODE HERE ======================
% Instructions: First, for each feature dimension, compute the mean
% of the feature and subtract it from the dataset,
% storing the mean value in mu. Next, compute the
% standard deviation of each feature and divide
% each feature by it's standard deviation, storing
% the standard deviation in sigma.
%
% Note that X is a matrix where each column is a
% feature and each row is an example. You need
% to perform the normalization separately for
% each feature.
%
% Hint: You might find the 'mean' and 'std' functions useful.
% for i=1:size(X,2),
mu(i)=mean(X(:,i));
sigma(i)=std(X(:,i));
X_norm(:,i)=(X_norm(:,i)-mu(i))/sigma(i);
end; % ============================================================ end
2. Computing Cost (for Multiple Variables) && Gradient Descent (for Multiple Variables)
由于我们单变量的时候就是用矩阵形式处理的,所以代码与单变量相同;
3.Normal Equations
正规方程就比较简单了;
function [theta] = normalEqn(X, y)
%NORMALEQN Computes the closed-form solution to linear regression
% NORMALEQN(X,y) computes the closed-form solution to linear
% regression using the normal equations. theta = zeros(size(X, 2), 1); % ====================== YOUR CODE HERE ======================
% Instructions: Complete the code to compute the closed form solution
% to linear regression and put the result in theta.
% % ---------------------- Sample Solution ---------------------- theta=inv(X'*X)*X'*y; % ------------------------------------------------------------- % ============================================================ end
Machine learning吴恩达第二周coding作业(选做)的更多相关文章
- Machine learning 吴恩达第二周coding作业(必做题)
1.warmUpExercise: function A = warmUpExercise() %WARMUPEXERCISE Example function in octave % A = WAR ...
- Machine Learning——吴恩达机器学习笔记(酷
[1] ML Introduction a. supervised learning & unsupervised learning 监督学习:从给定的训练数据集中学习出一个函数(模型参数), ...
- Machine learning吴恩达第三周 Logistic Regression
1. Sigmoid function function g = sigmoid(z) %SIGMOID Compute sigmoid function % g = SIGMOID(z) compu ...
- Deap Learning (吴恩达) 第一章深度学习概论 学习笔记
Deap Learning(Ng) 学习笔记 author: 相忠良(Zhong-Liang Xiang) start from: Sep. 8st, 2017 1 深度学习概论 打字太麻烦了,索性在 ...
- 吴恩达机器学习笔记38-决策下一步做什么(Deciding What to Do Next Revisited)
我们已经讨论了模型选择问题,偏差和方差的问题.那么这些诊断法则怎样帮助我们判断,哪些方法可能有助于改进学习算法的效果,而哪些可能是徒劳的呢? 让我们再次回到最开始的例子,在那里寻找答案,这就是我们之前 ...
- Github | 吴恩达新书《Machine Learning Yearning》完整中文版开源
最近开源了周志华老师的西瓜书<机器学习>纯手推笔记: 博士笔记 | 周志华<机器学习>手推笔记第一章思维导图 [博士笔记 | 周志华<机器学习>手推笔记第二章&qu ...
- 我在 B 站学机器学习(Machine Learning)- 吴恩达(Andrew Ng)【中英双语】
我在 B 站学机器学习(Machine Learning)- 吴恩达(Andrew Ng)[中英双语] 视频地址:https://www.bilibili.com/video/av9912938/ t ...
- 【吴恩达课后编程作业】第二周作业 - Logistic回归-识别猫的图片
1.问题描述 有209张图片作为训练集,50张图片作为测试集,图片中有的是猫的图片,有的不是.每张图片的像素大小为64*64 吴恩达并没有把原始的图片提供给我们 而是把这两个图片集转换成两个.h5文件 ...
- 【吴恩达课后测验】Course 1 - 神经网络和深度学习 - 第二周测验【中英】
[中英][吴恩达课后测验]Course 1 - 神经网络和深度学习 - 第二周测验 第2周测验 - 神经网络基础 神经元节点计算什么? [ ]神经元节点先计算激活函数,再计算线性函数(z = Wx + ...
随机推荐
- Openssl CA.pl命令
一.简介 CA.pl是证书操作的友好接口,简化了一些相似的证书创建或管理操作 二.语法 CA.pl [-?] [-h] [-help] [-newcert] [-newreq][-newreq-nod ...
- [转]Python-__builtin__与__builtins__的区别与关系(超详细,经典)
在学习Python时,很多人会问到__builtin__.__builtins__和builtins之间有什么关系.百度或Google一下,有很 多答案,但是这些答案要么不准确,要么只说了一点点,并不 ...
- [原创]SOUI GDI+渲染引擎下的字体特效,抛砖引玉
由于SOUI是一种双渲染引擎的DUI库,默认在SKIA渲染引擎下是支持特效字体的,具体请参考DEMO中的源码. 但是使用GDI+渲染时是没有这些特效的,着实比较苦恼,此代抛砖引玉,细节实现 请自己再去 ...
- u盘安装Linux系统详细教程
2012-05-06 02:30:44 分类: LINUX 想不想体验一下Linux下呢?刻盘太浪费钱,而U盘却可以多次利用.本文就是要介绍如何通过U盘安装Linux系统的.只要用Universal- ...
- BBS项目之后台管理
一:后台管理,添加文章样式编写 创建 一个后台管理模板前段页面 <!DOCTYPE html> <html lang="en"> <head> ...
- CentOS下的Git服务器
[Gitosis]CentOS下的Git服务器:Gitosis [摘要] 详细介绍如何在CentOS上配置Gitosis 我们很多人知道Git可能是从Github开始的 ...
- WordPaster2-Chrome 45安装说明
下载地址:http://www.ncmem.com/download/WordPaster2/WordPaster.exe 安装方法: 运行WordPaster.exe进行安装,WordPaste ...
- zrender源码分析--初探如何画一个圆
今天是想看看使用zrender框架如何去,画一个圆,再加“circle”的文字在圆心. 然后开始代码: 如何部署代码,让zrender跑起来这边就不说了,官方例子就有写,地址是:https://git ...
- CodeForces 122G Lucky Array(一脸懵逼的树状数组)
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal re ...
- VC++下的Unicode编程
ASCII是用来表示英文字符的一种编码规范.每个ASCII字符占用1个字节,因此,ASCII编码可以表示的最大字符数是255(00H—FFH). 其实,英文字符并没有那么多,一般只用前128个(00H ...