%% Train Sparse Autoencoder
% Load the sample data.

X = abalone_dataset;

% X is an 8-by-4177 matrix defining eight attributes for 4177 different abalone shells: sex (M, F, and I (for infant)), length, diameter, height, whole weight, shucked weight, viscera weight, shell weight. For more information on the dataset, type help abalone_dataset in the command line.
%
% Train a sparse autoencoder with default settings.

autoenc = trainAutoencoder(X);

%
% Reconstruct the abalone shell ring data using the trained autoencoder.

XReconstructed = predict(autoenc,X);

%
% Compute the mean squared reconstruction error.

mseError = mse(X-XReconstructed)

% Copyright 2015 The MathWorks, Inc.