15#include <Eigen/SparseCore>
34 std::vector<SlopeFit> fits;
61 assert(step < fits.size());
76 const bool original_scale =
true)
const
78 std::vector<Eigen::VectorXd> intercepts;
80 for (
const auto& fit : fits) {
81 intercepts.emplace_back(fit.getIntercepts(original_scale));
97 std::vector<Eigen::SparseMatrix<double>>
getCoefs(
98 const bool original_scale =
true)
const
100 std::vector<Eigen::SparseMatrix<double>> coefs;
102 for (
const auto& fit : fits) {
103 coefs.emplace_back(fit.getCoefs(original_scale));
116 std::vector<Clusters> clusters;
118 for (
const auto& fit : fits) {
119 clusters.emplace_back(fit.getClusters());
131 Eigen::ArrayXd alphas(fits.size());
133 for (
size_t i = 0; i < fits.size(); i++) {
134 alphas(i) = fits[i].getAlpha();
143 const Eigen::ArrayXd&
getLambda()
const {
return fits.front().getLambda(); }
150 std::vector<double> deviances;
152 for (
const auto& fit : fits) {
153 deviances.emplace_back(fit.getDeviance());
169 std::vector<std::vector<double>> primals;
171 for (
const auto& fit : fits) {
172 primals.emplace_back(fit.getPrimals());
183 std::vector<std::vector<double>> duals;
185 for (
const auto& fit : fits) {
186 duals.emplace_back(fit.getDuals());
195 std::vector<std::vector<double>>
getTime()
const
197 std::vector<std::vector<double>> time;
199 for (
const auto& fit : fits) {
200 time.emplace_back(fit.getTime());
211 std::vector<int> passes;
213 for (
const auto& fit : fits) {
214 passes.emplace_back(fit.getPasses());
227 std::vector<double> ratios;
229 for (
const auto& fit : fits) {
230 ratios.emplace_back(fit.getDevianceRatio());
241 std::vector<std::vector<double>>
getGaps()
const
243 std::vector<std::vector<double>> gaps;
245 for (
const auto& fit : fits) {
246 gaps.emplace_back(fit.getGaps());
256 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.