diff options
| author | leshe4ka46 <alex9102naid1@ya.ru> | 2025-12-13 19:41:40 +0300 |
|---|---|---|
| committer | leshe4ka46 <alex9102naid1@ya.ru> | 2025-12-13 19:41:40 +0300 |
| commit | 175ac10904d0f31c3ffeeeed507c8914f13d0b15 (patch) | |
| tree | 671c68a03354c5084470c5cfcfd4fe87aae2aff8 /R_LogR/mlclass-ex2/mapFeature.m | |
| parent | 72b4edeadeafc9c54b3db9b0961a45da3d07b77c (diff) | |
linr, logr
Diffstat (limited to 'R_LogR/mlclass-ex2/mapFeature.m')
| -rw-r--r-- | R_LogR/mlclass-ex2/mapFeature.m | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/R_LogR/mlclass-ex2/mapFeature.m b/R_LogR/mlclass-ex2/mapFeature.m new file mode 100644 index 0000000..d02a72a --- /dev/null +++ b/R_LogR/mlclass-ex2/mapFeature.m @@ -0,0 +1,21 @@ +function out = mapFeature(X1, X2) +% MAPFEATURE Feature mapping function to polynomial features +% +% MAPFEATURE(X1, X2) maps the two input features +% to quadratic features used in the regularization exercise. +% +% Returns a new feature array with more features, comprising of +% X1, X2, X1.^2, X2.^2, X1*X2, X1*X2.^2, etc.. +% +% Inputs X1, X2 must be the same size +% + +degree = 6; +out = ones(size(X1(:,1))); +for i = 1:degree + for j = 0:i + out(:, end+1) = (X1.^(i-j)).*(X2.^j); + end +end + +end
\ No newline at end of file |
