void CF::Train(const arma::sp_mat& data, FactorizerType factorizer, const typename boost::disable_if_c<FactorizerTraits< FactorizerType>::UsesCoordinateList>::type*) { cleanedData = data; // Check if the user wanted us to choose a rank for them. if (rank == 0) { // This is a simple heuristic that picks a rank based on the density of the // dataset between 5 and 105. const double density = (cleanedData.n_nonzero * 100.0) / cleanedData.n_elem; const size_t rankEstimate = size_t(density) + 5; // Set to heuristic value. Log::Info << "No rank given for decomposition; using rank of " << rankEstimate << " calculated by density-based heuristic." << std::endl; this->rank = rankEstimate; } Timer::Start("cf_factorization"); factorizer.Apply(cleanedData, this->rank, w, h); Timer::Stop("cf_factorization"); }
void ApplyFactorizer(FactorizerType& factorizer, const arma::mat& /* data */, const arma::sp_mat& cleanedData, const size_t rank, arma::mat& w, arma::mat& h, const typename boost::disable_if_c<FactorizerTraits< FactorizerType>::UsesCoordinateList>::type* = 0) { factorizer.Apply(cleanedData, rank, w, h); }
void ApplyFactorizer(arma::mat& data, arma::sp_mat& /* cleanedData */, FactorizerType& factorizer, const size_t rank, arma::mat& w, arma::mat& h, const typename boost::enable_if_c< FactorizerTraits<FactorizerType>::UsesCoordinateList == true, int*>::type = 0) { factorizer.Apply(data, rank, w, h); }