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作业(选做)的更多相关文章

  1. Machine learning 吴恩达第二周coding作业(必做题)

    1.warmUpExercise: function A = warmUpExercise() %WARMUPEXERCISE Example function in octave % A = WAR ...

  2. Machine Learning——吴恩达机器学习笔记(酷

    [1] ML Introduction a. supervised learning & unsupervised learning 监督学习:从给定的训练数据集中学习出一个函数(模型参数), ...

  3. Machine learning吴恩达第三周 Logistic Regression

    1. Sigmoid function function g = sigmoid(z) %SIGMOID Compute sigmoid function % g = SIGMOID(z) compu ...

  4. Deap Learning (吴恩达) 第一章深度学习概论 学习笔记

    Deap Learning(Ng) 学习笔记 author: 相忠良(Zhong-Liang Xiang) start from: Sep. 8st, 2017 1 深度学习概论 打字太麻烦了,索性在 ...

  5. 吴恩达机器学习笔记38-决策下一步做什么(Deciding What to Do Next Revisited)

    我们已经讨论了模型选择问题,偏差和方差的问题.那么这些诊断法则怎样帮助我们判断,哪些方法可能有助于改进学习算法的效果,而哪些可能是徒劳的呢? 让我们再次回到最开始的例子,在那里寻找答案,这就是我们之前 ...

  6. Github | 吴恩达新书《Machine Learning Yearning》完整中文版开源

    最近开源了周志华老师的西瓜书<机器学习>纯手推笔记: 博士笔记 | 周志华<机器学习>手推笔记第一章思维导图 [博士笔记 | 周志华<机器学习>手推笔记第二章&qu ...

  7. 我在 B 站学机器学习(Machine Learning)- 吴恩达(Andrew Ng)【中英双语】

    我在 B 站学机器学习(Machine Learning)- 吴恩达(Andrew Ng)[中英双语] 视频地址:https://www.bilibili.com/video/av9912938/ t ...

  8. 【吴恩达课后编程作业】第二周作业 - Logistic回归-识别猫的图片

    1.问题描述 有209张图片作为训练集,50张图片作为测试集,图片中有的是猫的图片,有的不是.每张图片的像素大小为64*64 吴恩达并没有把原始的图片提供给我们 而是把这两个图片集转换成两个.h5文件 ...

  9. 【吴恩达课后测验】Course 1 - 神经网络和深度学习 - 第二周测验【中英】

    [中英][吴恩达课后测验]Course 1 - 神经网络和深度学习 - 第二周测验 第2周测验 - 神经网络基础 神经元节点计算什么? [ ]神经元节点先计算激活函数,再计算线性函数(z = Wx + ...

随机推荐

  1. Openssl gendsa命令

    一.简介 gendsa命令能够根据DSA密钥参数生成DSA密钥 二.语法 openssl gendsa [-out filename] [-passout out] [-rand file(s)] [ ...

  2. 转载 MYSQL性能优化的最佳20+条经验

    转自:https://coolshell.cn/articles/1846.html 今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才 ...

  3. List 组件简单示例及其onItemsDisclosure点击事件

    来自<sencha touch权威指南>第9章,276页开始 ------------------------------------------------- app.js代码如下: E ...

  4. 2.spark-streaming实战

    park Streaming--实战篇 摘要:      Sprak Streaming属于Saprk API的扩展,支持实时数据流(live data streams)的可扩展,高吞吐(hight- ...

  5. realsense pcl git

    https://github.com/Ext4FAT/Registration vc++ pcl realsense  矿泉水瓶子 https://github.com/dBeker/PCL-Real ...

  6. sed的模式空间和保持空间

    摘自:https://blog.csdn.net/wanglelelihuanhuan/article/details/51591809 sed的模式空间和保持空间 2016年06月06日 17:15 ...

  7. Java虚拟机学习(1): 类加载机制

    转自:微信公共号ImportNew 来源:java2000_wl 链接:blog.csdn.net/java2000_wl/article/details/8040633 JVM把class文件加载的 ...

  8. JSTL 引入

    首先要明白jstl有如下版本:  jstl1.0的引入方式为: <taglib uri="http://java.sun.com/jstl/core" prefix=&quo ...

  9. 编写高质量代码改善C#程序的157个建议——建议126:用名词和名词组给类型命名

    建议126:用名词和名词组给类型命名 类型对应着现实世界中的实际对象.对象在语言中意味着它是一个名词.所以,类型也应该以名词或名词词组去命名. 类型定义了属性和行为.虽然它包含行为,但不是行为本身.所 ...

  10. 编写高质量代码改善C#程序的157个建议——建议77: 正确停止线程

    建议77: 正确停止线程 开发者总尝试对自己的代码有更多的控制.例如,“让那个还在工作的线程马上停止下来”.然而,并非我们想怎样就可以怎样的,这至少涉及两个问题. 第一个问题 正如线程不能立即启动一样 ...