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 & BOOST_SERIALIZATION_NVP(mean);
This normalization class performs overall mean normalization on raw ratings.
double Denormalize(const size_t, const size_t, const double rating) const
Denormalize computed rating by adding mean.
OverallMeanNormalization()
void Normalize(arma::mat &data)
Normalize the data by subtracting the mean of all existing ratings.
void Denormalize(const arma::Mat< size_t > &, arma::vec &predictions) const
Denormalize computed rating by adding mean.
void Normalize(arma::sp_mat &cleanedData)
Normalize the data by subtracting the mean of all existing ratings.
double Mean() const
Return mean.
void serialize(Archive &ar, const unsigned int)
Serialization.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.