You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

featureNormalize.m 1.3 kB

8 years ago
12345678910111213141516171819202122232425262728293031323334353637383940
  1. function [X_norm, mu, sigma] = featureNormalize(X)
  2. %FEATURENORMALIZE Normalizes the features in X
  3. % FEATURENORMALIZE(X) returns a normalized version of X where
  4. % the mean value of each feature is 0 and the standard deviation
  5. % is 1. This is often a good preprocessing step to do when
  6. % working with learning algorithms.
  7. % You need to set these values correctly
  8. X_norm = X;
  9. mu = zeros(1, size(X, 2));
  10. sigma = zeros(1, size(X, 2));
  11. % ====================== YOUR CODE HERE ======================
  12. % Instructions: First, for each feature dimension, compute the mean
  13. % of the feature and subtract it from the dataset,
  14. % storing the mean value in mu. Next, compute the
  15. % standard deviation of each feature and divide
  16. % each feature by it's standard deviation, storing
  17. % the standard deviation in sigma.
  18. %
  19. % Note that X is a matrix where each column is a
  20. % feature and each row is an example. You need
  21. % to perform the normalization separately for
  22. % each feature.
  23. %
  24. % Hint: You might find the 'mean' and 'std' functions useful.
  25. %
  26. mu = mean(X_norm);
  27. sigma = std(X_norm);
  28. X_norm = (X_norm .- mu) ./ sigma;
  29. % ============================================================
  30. end

机器学习

Contributors (1)