13 #ifndef MLPACK_METHODS_CF_NORMALIZATION_COMBINED_NORMALIZATION_HPP 14 #define MLPACK_METHODS_CF_NORMALIZATION_COMBINED_NORMALIZATION_HPP 43 template<
typename... NormalizationTypes>
47 using TupleType = std::tuple<NormalizationTypes...>;
57 template<
typename MatType>
60 SequenceNormalize<0>(data);
74 const double rating)
const 76 return SequenceDenormalize<0>(user, item, rating);
88 arma::vec& predictions)
const 90 SequenceDenormalize<0>(combinations, predictions);
98 return normalizations;
104 template<
typename Archive>
107 SequenceSerialize<0, Archive>(ar, version);
119 void SequenceNormalize(MatType& data)
121 std::get<I>(normalizations).
Normalize(data);
122 SequenceNormalize<I + 1>(data);
131 void SequenceNormalize(MatType& ) { }
137 double SequenceDenormalize(
const size_t user,
139 const double rating)
const 143 double realRating = SequenceDenormalize<I + 1>(user, item, rating);
145 std::get<I>(normalizations).
Denormalize(user, item, realRating);
154 double SequenceDenormalize(
const size_t ,
156 const double rating)
const 165 void SequenceDenormalize(
const arma::Mat<size_t>& combinations,
166 arma::vec& predictions)
const 170 SequenceDenormalize<I+1>(combinations, predictions);
171 std::get<I>(normalizations).
Denormalize(combinations, predictions);
179 void SequenceDenormalize(
const arma::Mat<size_t>& ,
180 arma::vec& )
const { }
187 void SequenceSerialize(Archive& ar,
const uint32_t version)
189 std::string tagName =
"normalization_";
190 tagName += std::to_string(I);
192 tagName.c_str(), std::get<I>(normalizations)));
193 SequenceSerialize<I + 1, Archive>(ar, version);
202 void SequenceSerialize(Archive& ,
const uint32_t )
typename enable_if< B, T >::type enable_if_t
Linear algebra utility functions, generally performed on matrices or vectors.
void serialize(Archive &ar, const uint32_t version)
Serialization.
This normalization class performs a sequence of normalization methods on raw ratings.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Denormalize(const size_t user, const size_t item, const double rating) const
Denormalize rating by calling Denormalize() in each normalization object.
const TupleType & Normalizations() const
Return normalizations tuple.
void Normalize(MatType &data)
Normalize the data by calling Normalize() in each normalization object.
std::tuple< NormalizationTypes... > TupleType
void Denormalize(const arma::Mat< size_t > &combinations, arma::vec &predictions) const
Denormalize rating by calling Denormalize() in each normalization object.