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());
132 Eigen::ArrayXd alphas(fits.size());
134 for (
size_t i = 0; i < fits.size(); i++) {
135 alphas(i) = fits[i].getAlpha();
144 const Eigen::ArrayXd&
getLambda()
const {
return fits.front().getLambda(); }
151 std::vector<double> deviances;
153 for (
const auto& fit : fits) {
154 deviances.emplace_back(fit.getDeviance());
170 std::vector<std::vector<double>> primals;
172 for (
const auto& fit : fits) {
173 primals.emplace_back(fit.getPrimals());
184 std::vector<std::vector<double>> duals;
186 for (
const auto& fit : fits) {
187 duals.emplace_back(fit.getDuals());
196 std::vector<std::vector<double>>
getTime()
const
198 std::vector<std::vector<double>> time;
200 for (
const auto& fit : fits) {
201 time.emplace_back(fit.getTime());
212 std::vector<int> passes;
214 for (
const auto& fit : fits) {
215 passes.emplace_back(fit.getPasses());
228 std::vector<double> ratios;
230 for (
const auto& fit : fits) {
231 ratios.emplace_back(fit.getDevianceRatio());
242 std::vector<std::vector<double>>
getGaps()
const
244 std::vector<std::vector<double>> gaps;
246 for (
const auto& fit : fits) {
247 gaps.emplace_back(fit.getGaps());
257 std::size_t
size()
const {
return fits.size(); }
A class representing the results of SLOPE (Sorted L1 Penalized Estimation) fitting.
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 absolute alpha penalty scales, including when the input alphas were relative to alpha_max.
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.