Utilities and types for working with features. More...
Typedefs | |
| typedef std::pair< Eigen::Index, double > | IndexedFeatureValue |
| Used to sort feature vectors. | |
| template<typename T > | |
| using | VectorRange = std::pair< typename std::vector< T >::iterator, typename std::vector< T >::iterator > |
| Pair of vector iterators. | |
Functions | |
| template<typename T > | |
| VectorRange< T > | from_vector (std::vector< T > &v) |
| void | set_to_nth (Eigen::Ref< const Eigen::MatrixXd > X, Eigen::Index n, VectorRange< IndexedFeatureValue > features) |
Copies the n-th coordinate to features. More... | |
| void | swap_columns (Eigen::Ref< Eigen::MatrixXd > X, Eigen::Index i1, Eigen::Index i2) |
| Swaps two columns in feature matrix. More... | |
| Eigen::Index | partition (Eigen::Ref< Eigen::MatrixXd > X, Eigen::Index pivot_idx, Eigen::Index k) |
| Partitions features (in columns) so that those with x[k] < pivot[k] are before the pivot, and those with x[k] > pivot[k] are after it. More... | |
| Eigen::Index | partition (Eigen::Ref< Eigen::MatrixXd > X, Eigen::Ref< Eigen::VectorXd > y, Eigen::Index pivot_idx, Eigen::Index k) |
| Partitions features (in columns) and labels so that those with x[k] < pivot[k] are before the pivot, and those with x[k] > pivot[k] are after it. More... | |
Utilities and types for working with features.
| VectorRange<T> ml::Features::from_vector | ( | std::vector< T > & | v | ) |
Creates an iterator pair containing begin() and end().
| void ml::Features::set_to_nth | ( | Eigen::Ref< const Eigen::MatrixXd > | X, |
| Eigen::Index | n, | ||
| VectorRange< IndexedFeatureValue > | features | ||
| ) |
Copies the n-th coordinate to features.
| [in] | X | Features matrix, with data points in columns. |
| [in] | n | Coordinate index. |
| [out] | features | Iterator range for indexed feature values. |
| std::invalid_argument | If size of the iterator range is different from the number of data points, or n is too large. |
| void ml::Features::swap_columns | ( | Eigen::Ref< Eigen::MatrixXd > | X, |
| Eigen::Index | i1, | ||
| Eigen::Index | i2 | ||
| ) |
Swaps two columns in feature matrix.
| X | Feature matrix. |
| i1 | Index of the 1st column. |
| i2 | Index of the 2nd column. |
| std::out_of_range | If i1 >= X.cols() or i2 >= X.cols(). |
| Eigen::Index ml::Features::partition | ( | Eigen::Ref< Eigen::MatrixXd > | X, |
| Eigen::Index | pivot_idx, | ||
| Eigen::Index | k | ||
| ) |
Partitions features (in columns) so that those with x[k] < pivot[k] are before the pivot, and those with x[k] > pivot[k] are after it.
pivot = X.col(pivot_idx).
| X | Features with data points in columns. |
| pivot_idx | Pivot index. |
| k | Dimension used for comparison. |
| std::out_of_range | If pivot_idx >= X.cols() or k >= X.rows(). |
| Eigen::Index ml::Features::partition | ( | Eigen::Ref< Eigen::MatrixXd > | X, |
| Eigen::Ref< Eigen::VectorXd > | y, | ||
| Eigen::Index | pivot_idx, | ||
| Eigen::Index | k | ||
| ) |
Partitions features (in columns) and labels so that those with x[k] < pivot[k] are before the pivot, and those with x[k] > pivot[k] are after it.
pivot = X.col(pivot_idx).
| X | Features with data points in columns. |
| y | Vector of labels. |
| pivot_idx | Pivot index. |
| k | Dimension used for comparison. |
| std::out_of_range | If pivot_idx >= X.cols() or k >= X.rows(). |
| std::invalid_argument | If X.cols() != y.size(). |