20170221机器学习代码1. LMS(Least mean squares)最小均方值. MATLAB

参考课程:斯坦福吴恩达《机器学习》

讲义链接:http://download.csdn.net/detail/puluotianyi/7651271

cs229-notes1.pdf  P4


最新更新时间: 20170222


X是样本的矩阵,每列是一个样本,列向量中的元素是该样本的特征。

只有1个特征的9组样本示例:

% Introduction of Least mean squares
% features' number of each sample (like sizes, areas, floors of a house) : n = 1
% samples' number (like datas collected in Beijing, Shanghai, Shenzhen...): m = 8
% h(x) is the model, n influences h

function LMS

% Samples: 1 feature, 8 sample
% every column is a sample 
X = [1 2 3 4 5 6 7 8 9]; % X(行序, 列序)
Y = [3 2 9 4 5 2 7 8 10];

for i_f = 1:9
    %X(i_f,1) = i_f;
    %Y(i_f,1) = i_f*i_f;
    plot(i_f , Y(i_f), '.');
    hold on;
end

% Parameters:
n = 1; % number of features
m = 9; % number of samples
tolerance = 50; % 
a

你可能感兴趣的:(机器学习)