inline const SizeMat size(const uword n_rows, const uword n_cols) { arma_extra_debug_sigprint(); return SizeMat(n_rows, n_cols); }
inline typename enable_if2< is_arma_sparse_type<T1>::value, const SizeMat >::result size(const T1& X) { arma_extra_debug_sigprint(); const SpProxy<T1> P(X); return SizeMat( P.get_n_rows(), P.get_n_cols() ); }
inline typename enable_if2< is_arma_type<T1>::value, uword >::result size(const T1& X, const uword dim) { arma_extra_debug_sigprint(); const Proxy<T1> P(X); return SizeMat( P.get_n_rows(), P.get_n_cols() )( dim ); }
/* "getBestStump()" function saves the best decision stump's threshold, weak hypothesis and its error; */ void DSC::getBestStump(Threshold &threshold, ivec &hypothesis, double &error) { /* Separating weights by classes: */ mat class1Weights = weights(find(classes == -1)); mat class2Weights = weights(find(classes == +1)); /* Accumulate weights for given thresholds ("number of thresholds" x "number of features"): */ mat thresholdWeights1 = accumarray(join_rows(class1Thresholds, featureIndexes1), repmat(class1Weights, features.n_cols, 1), SizeMat(N_THRESHOLDS, features.n_cols)); mat thresholdWeights2 = accumarray(join_rows(class2Thresholds, featureIndexes2), repmat(class2Weights, features.n_cols, 1), SizeMat(N_THRESHOLDS, features.n_cols)); /* Looking for threshold with minimum error; Here we construct cummulative sum of weights for seaprate classes, then we add them; In order to find the smallest error, we consider both directions of a threshold; */ mat thresholdErrors = flipud(cumsum(flipud(thresholdWeights1))) + cumsum(thresholdWeights2); thresholdErrors = join_cols(thresholdErrors, sum(weights) - thresholdErrors); uword index; uword featureType; error = thresholdErrors.min(index, featureType); threshold.featureType = featureType; if (index > N_THRESHOLDS - 1) { threshold.direction = -1; index -= N_THRESHOLDS; } else { threshold.direction = +1; } threshold.value = minFeatures(featureType) + (ranges(featureType) / N_THRESHOLDS) * index; /* Evaluating hypothesis for derived threshold: */ classify(threshold, features, hypothesis); return; }
arma_warn_unused inline uword size(const Base<typename T1::elem_type,T1>& X, const uword dim) { arma_extra_debug_sigprint(); const Proxy<T1> P(X.get_ref()); return SizeMat( P.get_n_rows(), P.get_n_cols() )( dim ); }
arma_warn_unused inline const SizeMat size(const SpBase<typename T1::elem_type,T1>& X) { arma_extra_debug_sigprint(); const SpProxy<T1> P(X.get_ref()); return SizeMat( P.get_n_rows(), P.get_n_cols() ); }