Mercurial > hg > machine-learning-hw5
view polyFeatures.m @ 0:0f14514e907f
initial commit
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Sun, 20 Nov 2011 23:26:16 -0500 |
parents | |
children | 7f4c22114134 |
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]; % % You need to return the following variables correctly. X_poly = zeros(numel(X), p); % ====================== YOUR CODE HERE ====================== % Instructions: Given a vector X, return a matrix X_poly where the p-th % column of X contains the values of X to the p-th power. % % % ========================================================================= end