Skip to content

Add comments to linalg_utils #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions include/albatross/src/utils/linalg_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,37 @@ namespace details {

constexpr double DEFAULT_EIGEN_VALUE_PRINT_THRESHOLD = 1e-3;

/*
* When building models it can be helpful to understand what the
* model is good (or bad) at predicting. This provides one way of
* understanding a model's predictions by looking at the predicted
* covariance. So, for example, if you have a model and make a
* prediction,
*
* pred = model.predict(features).joint();
*
* you could then call:
*
* print_large_eigen_directions(pred.covariance, features, 1);
*
* this will compute the eigen decomposition of the covariance,
*
* V D V^T = pred.covariance
*
* Here D is diagonal and holds the eigen values and V is orthonormal
* holding the eigen vectors. In this function we print out the
* largest (or smallest depending on `comp`) eigen value along with
* any of the features which have non-zero values in the corresponding
* eigen vector, something like:
*
* eigen value: D[0]
* V[0, 0] features[0]
* V[1, 0] features[1]
* ...
*
* Note that any V[i, j] which is smaller in magnitude than `print_if_above`
* will be ignored in the interest of brevity.
*/
template <typename FeatureType, typename Comparator>
inline void _print_eigen_directions(const Eigen::MatrixXd &matrix,
const std::vector<FeatureType> &features,
Expand Down