12 #ifndef _MLPACK_METHODS_AMF_VALIDATIONRMSETERMINATION_HPP_INCLUDED 13 #define _MLPACK_METHODS_AMF_VALIDATIONRMSETERMINATION_HPP_INCLUDED 36 template <
class MatType>
51 size_t num_test_points,
52 double tolerance = 1e-5,
53 size_t maxIterations = 10000,
54 size_t reverseStepTolerance = 3)
55 : tolerance(tolerance),
56 maxIterations(maxIterations),
57 num_test_points(num_test_points),
58 reverseStepTolerance(reverseStepTolerance)
64 test_points.zeros(num_test_points, 3);
67 for (
size_t i = 0; i < num_test_points; ++i)
78 }
while ((t_val = V(t_row, t_col)) == 0);
81 test_points(i, 0) = t_row;
82 test_points(i, 1) = t_col;
83 test_points(i, 2) = t_val;
105 reverseStepCount = 0;
126 for (
size_t i = 0; i < num_test_points; ++i)
128 size_t t_row = test_points(i, 0);
129 size_t t_col = test_points(i, 1);
130 double t_val = test_points(i, 2);
131 double temp = (t_val - WH(t_row, t_col));
135 rmse /= num_test_points;
143 if ((rmseOld - rmse) / rmseOld < tolerance && iteration > 4)
146 if (reverseStepCount == 0 && isCopy ==
false)
153 c_indexOld = rmseOld;
163 reverseStepCount = 0;
165 if (rmse <= c_indexOld && isCopy ==
true)
172 if (reverseStepCount == reverseStepTolerance || iteration > maxIterations)
188 const double&
Index()
const {
return rmse; }
208 size_t maxIterations;
210 size_t num_test_points;
216 arma::mat test_points;
223 size_t reverseStepTolerance;
225 size_t reverseStepCount;
242 #endif // _MLPACK_METHODS_AMF_VALIDATIONRMSETERMINATION_HPP_INCLUDED const size_t & Iteration() const
Get current iteration count.
void Initialize(const MatType &)
Initializes the termination policy before stating the factorization.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
This class implements validation termination policy based on RMSE index.
const double & Index() const
Get current value of residue.
const size_t & NumTestPoints() const
Get number of validation points.
const double & Tolerance() const
Access tolerance value.
const size_t & MaxIterations() const
Access upper limit of iteration count.
ValidationRMSETermination(MatType &V, size_t num_test_points, double tolerance=1e-5, size_t maxIterations=10000, size_t reverseStepTolerance=3)
Create a validation set according to given parameters and nullifies this set in data matrix(training ...
bool IsConverged(arma::mat &W, arma::mat &H)
Check if termination criterio is met.