Created
October 11, 2012 13:02
-
-
Save garydoranjr/3872119 to your computer and use it in GitHub Desktop.
MATLAB function to load datasets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [examples classifications] = dataset_load(dataset_name) | |
% dataset_load(dataset_name) | |
% Returns the example feature vectors (as rows) and corresponding | |
% classifications. Automatically strips the first column (example ids). | |
% Load dataset into a structure array | |
mat_struct = load(dataset_name); | |
% Syntax to get the field of a structure array by name | |
% http://www.mathworks.com/help/matlab/ref/getfield.html | |
X = mat_struct.(dataset_name); | |
% Skip the first feature (example id) | |
examples = X(:, 2:end-1); | |
% Adjust {0, 1} labels to {-1, 1} labels | |
classifications = 2*X(:, end) - 1; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment