Mercurial > hg > machine-learning-hw5
view polyFeatures.m @ 5:eddd33e57f6a default tip
Justify loop in trainLinearReg
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Sun, 27 Nov 2011 15:58:14 -0500 |
parents | 7f4c22114134 |
children |
line wrap: on
line source
function [X_poly] = polyFeatures(X, p) ##POLYFEATURES Maps X (1D vector) into the p-th power ## [X_poly] = POLYFEATURES(X, p) takes a data matrix X (size m x 1) and ## maps each example into its polynomial features where ## X_poly(i, :) = [X(i) X(i).^2 X(i).^3 ... X(i).^p]; ## X_poly = bsxfun (@power, X, 1:p); endfunction