Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hackassin
GitHub Repository: hackassin/Coursera-Machine-Learning
Path: blob/master/Week 3/Programming Assignment - 2/machine-learning-ex2/ex2/mapFeature.m
863 views
1
function out = mapFeature(X1, X2)
2
% MAPFEATURE Feature mapping function to polynomial features
3
%
4
% MAPFEATURE(X1, X2) maps the two input features
5
% to quadratic features used in the regularization exercise.
6
%
7
% Returns a new feature array with more features, comprising of
8
% X1, X2, X1.^2, X2.^2, X1*X2, X1*X2.^2, etc..
9
%
10
% Inputs X1, X2 must be the same size
11
%
12
13
degree = 6;
14
out = ones(size(X1(:,1)));
15
for i = 1:degree
16
for j = 0:i
17
out(:, end+1) = (X1.^(i-j)).*(X2.^j);
18
end
19
end
20
21
end
22