15#include <Eigen/SparseCore>
33 std::vector<SlopeFit> fits;
60 assert(step < fits.size());
75 const bool original_scale =
true)
const
77 std::vector<Eigen::VectorXd> intercepts;
79 for (
const auto& fit : fits) {
80 intercepts.emplace_back(fit.getIntercepts(original_scale));
96 std::vector<Eigen::SparseMatrix<double>>
getCoefs(
97 const bool original_scale =
true)
const
99 std::vector<Eigen::SparseMatrix<double>> coefs;
101 for (
const auto& fit : fits) {
102 coefs.emplace_back(fit.getCoefs(original_scale));
115 std::vector<Clusters> clusters;
117 for (
const auto& fit : fits) {
118 clusters.emplace_back(fit.getClusters());
130 Eigen::ArrayXd alphas(fits.size());
132 for (
size_t i = 0; i < fits.size(); i++) {
133 alphas(i) = fits[i].getAlpha();
142 const Eigen::ArrayXd&
getLambda()
const {
return fits.front().getLambda(); }
149 std::vector<double> deviances;
151 for (
const auto& fit : fits) {
152 deviances.emplace_back(fit.getDeviance());
168 std::vector<std::vector<double>> primals;
170 for (
const auto& fit : fits) {
171 primals.emplace_back(fit.getPrimals());
182 std::vector<std::vector<double>> duals;
184 for (
const auto& fit : fits) {
185 duals.emplace_back(fit.getDuals());
194 std::vector<std::vector<double>>
getTime()
const
196 std::vector<std::vector<double>> time;
198 for (
const auto& fit : fits) {
199 time.emplace_back(fit.getTime());
210 std::vector<int> passes;
212 for (
const auto& fit : fits) {
213 passes.emplace_back(fit.getPasses());
226 std::vector<double> ratios;
228 for (
const auto& fit : fits) {
229 ratios.emplace_back(fit.getDevianceRatio());
240 std::vector<std::vector<double>>
getGaps()
const
242 std::vector<std::vector<double>> gaps;
244 for (
const auto& fit : fits) {
245 gaps.emplace_back(fit.getGaps());
255 std::size_t
size()
const {
return fits.size(); }
A class representing the results of SLOPE (Sorted L1 Penalized Estimation) fitting.
Container class for SLOPE regression solution paths.
std::vector< Eigen::VectorXd > getIntercepts(const bool original_scale=true) const
Returns the vector of intercept terms for each solution in the path.
std::vector< double > getDeviance() const
Gets the deviance values for each solution.
const SlopeFit & operator()(const size_t step) const
Get one of the coefficients along the path.
std::vector< std::vector< double > > getGaps() const
Computes the duality gaps (primal - dual objectives) for each solution.
std::vector< std::vector< double > > getDuals() const
Gets the dual objective values during optimization.
std::vector< int > getPasses() const
Gets the number of iterations for each solution.
std::vector< std::vector< double > > getPrimals() const
Gets the primal objective values during optimization.
std::vector< std::vector< double > > getTime() const
Gets the computation times for each solution.
const std::vector< double > getDevianceRatios() const
Computes the deviance ratio (explained deviance) for each solution.
SlopePath()=default
Constructs an empty SlopePath object.
const Eigen::ArrayXd & getLambda() const
Gets the lambda (regularization) weights.
Eigen::ArrayXd getAlpha() const
Gets the alpha parameter sequence.
std::size_t size() const
Gets the number of solutions in the path.
std::vector< Clusters > getClusters() const
Returns the clusters for each solution in the path.
std::vector< Eigen::SparseMatrix< double > > getCoefs(const bool original_scale=true) const
Returns the vector of coefficient matrices for each solution in the path.
SlopePath(const std::vector< SlopeFit > &fits)
Constructs a SlopePath object containing SLOPE regression solution path data.
double getNullDeviance() const
Gets the null model deviance.
Namespace containing SLOPE regression implementation.
SLOPE (Sorted L-One Penalized Estimation) fitting results.