13 #ifndef MLPACK_METHODS_CF_NORMALIZATION_OVERALL_MEAN_NORMALIZATION_HPP 14 #define MLPACK_METHODS_CF_NORMALIZATION_OVERALL_MEAN_NORMALIZATION_HPP 52 mean = arma::mean(data.row(2));
56 data.row(2).for_each([](
double& x)
59 x = std::numeric_limits<double>::min();
71 if (cleanedData.n_nonzero != 0)
73 mean = arma::accu(cleanedData) / cleanedData.n_nonzero;
75 arma::sp_mat::iterator it = cleanedData.begin();
76 arma::sp_mat::iterator it_end = cleanedData.end();
77 for (; it != it_end; ++it)
79 double tmp = *it - mean;
84 tmp = std::numeric_limits<float>::min();
105 const double rating)
const 107 return rating + mean;
117 arma::vec& predictions)
const 133 template<
typename Archive>
136 ar(CEREAL_NVP(mean));
OverallMeanNormalization()
double Denormalize(const size_t, const size_t, const double rating) const
Denormalize computed rating by adding mean.
Linear algebra utility functions, generally performed on matrices or vectors.
void Normalize(arma::sp_mat &cleanedData)
Normalize the data by subtracting the mean of all existing ratings.
double Mean() const
Return mean.
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Denormalize(const arma::Mat< size_t > &, arma::vec &predictions) const
Denormalize computed rating by adding mean.
This normalization class performs overall mean normalization on raw ratings.
void Normalize(arma::mat &data)
Normalize the data by subtracting the mean of all existing ratings.
void serialize(Archive &ar, const uint32_t)
Serialization.