slope 6.6.0
Loading...
Searching...
No Matches
slope::SlopeFit Class Reference

A class representing the results of SLOPE (Sorted L1 Penalized Estimation) fitting. More...

#include <slope_fit.h>

Public Member Functions

 SlopeFit (const Eigen::VectorXd &intercepts, const Eigen::SparseMatrix< double > &coefs, const Clusters &clusters, const double alpha, const Eigen::ArrayXd &lambda, const double deviance, const double null_deviance, const std::vector< double > &primals, const std::vector< double > &duals, const std::vector< double > &time, const int passes, const std::string &centering_type, const std::string &scaling_type, const bool has_intercept, const Eigen::VectorXd &x_centers, const Eigen::VectorXd &x_scales)
 Construct a new Slope Fit object.
Eigen::VectorXd getIntercepts (const bool original_scale=true) const
 Gets the intercept terms for this SLOPE fit.
Eigen::SparseMatrix< double > getCoefs (const bool original_scale=true) const
 Gets the sparse coefficient matrix for this fit.
const Clusters & getClusters () const
 Gets the clusters.
const Eigen::ArrayXd & getLambda () const
 Gets the lambda (regularization) parameter used.
double getAlpha () const
 Gets the absolute alpha penalty scale used, including when the input alpha was relative to alpha_max.
double getDeviance () const
 Gets the model deviance.
const std::string & getLossType () const
 Gets the model's loss type.
double getNullDeviance () const
 Gets the null model deviance.
const std::vector< double > & getPrimals () const
 Gets the sequence of primal objective values during optimization.
const std::vector< double > & getDuals () const
 Gets the sequence of dual objective values during optimization.
const std::vector< double > & getTime () const
 Gets the sequence of computation times during optimization.
int getPasses () const
 Gets the total number of optimization iterations.
double getDevianceRatio () const
 Calculate the deviance ratio (1 - deviance/null_deviance).
std::vector< double > getGaps () const
 Calculate the duality gaps during optimization.
bool hasIntercept () const
 Checks if model has intercept.
template<typename T>
Eigen::MatrixXd predict (Eigen::EigenBase< T > &x, const std::string &type="response") const
 Predict the response for a given input matrix.

Detailed Description

A class representing the results of SLOPE (Sorted L1 Penalized Estimation) fitting.

This class stores the results of a SLOPE regression, including coefficients, intercepts, clusters (if required), regularization parameters, and optimization metrics.

Definition at line 26 of file slope_fit.h.

Constructor & Destructor Documentation

◆ SlopeFit()

slope::SlopeFit::SlopeFit ( const Eigen::VectorXd & intercepts,
const Eigen::SparseMatrix< double > & coefs,
const Clusters & clusters,
const double alpha,
const Eigen::ArrayXd & lambda,
const double deviance,
const double null_deviance,
const std::vector< double > & primals,
const std::vector< double > & duals,
const std::vector< double > & time,
const int passes,
const std::string & centering_type,
const std::string & scaling_type,
const bool has_intercept,
const Eigen::VectorXd & x_centers,
const Eigen::VectorXd & x_scales )
inline

Construct a new Slope Fit object.

Parameters
interceptsVector of intercept terms
coefsMatrix of fitted coefficients
clustersClusters of coefficients
alphaAbsolute penalty scale multiplying the lambda sequence
lambdaSequence of decreasing weights
devianceFinal model deviance
null_devianceNull model deviance
primalsHistory of primal objectives
dualsHistory of dual objectives
timeVector of optimization timestamps
passesNumber of optimization passes
centering_typeType of centering for the design matrix
scaling_typeType of scaling for the design matrix
has_interceptWhether the model has an intercept term
x_centersCenters for the design matrix
x_scalesScales for the design matrix

Definition at line 73 of file slope_fit.h.

Member Function Documentation

◆ getAlpha()

double slope::SlopeFit::getAlpha ( ) const
inline

Gets the absolute alpha penalty scale used, including when the input alpha was relative to alpha_max.

Definition at line 162 of file slope_fit.h.

◆ getClusters()

const Clusters & slope::SlopeFit::getClusters ( ) const
inline

Gets the clusters.

Definition at line 151 of file slope_fit.h.

◆ getCoefs()

Eigen::SparseMatrix< double > slope::SlopeFit::getCoefs ( const bool original_scale = true) const
inline

Gets the sparse coefficient matrix for this fit.

Parameters
original_scaleWhether to return the intercept on the original scale or not

Definition at line 133 of file slope_fit.h.

◆ getDeviance()

double slope::SlopeFit::getDeviance ( ) const
inline

Gets the model deviance.

Definition at line 167 of file slope_fit.h.

◆ getDevianceRatio()

double slope::SlopeFit::getDevianceRatio ( ) const
inline

Calculate the deviance ratio (1 - deviance/null_deviance).

Returns
double The deviance ratio, a measure of model fit (higher is better)

Definition at line 205 of file slope_fit.h.

◆ getDuals()

const std::vector< double > & slope::SlopeFit::getDuals ( ) const
inline

Gets the sequence of dual objective values during optimization.

Definition at line 187 of file slope_fit.h.

◆ getGaps()

std::vector< double > slope::SlopeFit::getGaps ( ) const
inline

Calculate the duality gaps during optimization.

Returns
std::vector<double> Vector of duality gaps (primal - dual objectives)

Definition at line 213 of file slope_fit.h.

◆ getIntercepts()

Eigen::VectorXd slope::SlopeFit::getIntercepts ( const bool original_scale = true) const
inline

Gets the intercept terms for this SLOPE fit.

Parameters
original_scaleWhether to return the intercept on the original scale or not

Definition at line 113 of file slope_fit.h.

◆ getLambda()

const Eigen::ArrayXd & slope::SlopeFit::getLambda ( ) const
inline

Gets the lambda (regularization) parameter used.

Definition at line 156 of file slope_fit.h.

◆ getLossType()

const std::string & slope::SlopeFit::getLossType ( ) const
inline

Gets the model's loss type.

Definition at line 172 of file slope_fit.h.

◆ getNullDeviance()

double slope::SlopeFit::getNullDeviance ( ) const
inline

Gets the null model deviance.

Definition at line 177 of file slope_fit.h.

◆ getPasses()

int slope::SlopeFit::getPasses ( ) const
inline

Gets the total number of optimization iterations.

Definition at line 197 of file slope_fit.h.

◆ getPrimals()

const std::vector< double > & slope::SlopeFit::getPrimals ( ) const
inline

Gets the sequence of primal objective values during optimization.

Definition at line 182 of file slope_fit.h.

◆ getTime()

const std::vector< double > & slope::SlopeFit::getTime ( ) const
inline

Gets the sequence of computation times during optimization.

Definition at line 192 of file slope_fit.h.

◆ hasIntercept()

bool slope::SlopeFit::hasIntercept ( ) const
inline

Checks if model has intercept.

Returns
bool True if model has intercept, false otherwise

Definition at line 227 of file slope_fit.h.

◆ predict()

template<typename T>
Eigen::MatrixXd slope::SlopeFit::predict ( Eigen::EigenBase< T > & x,
const std::string & type = "response" ) const
inline

Predict the response for a given input matrix.

Template Parameters
TType of input matrix (dense or sparse)
Parameters
xInput matrix of features
typeType of prediction to return ("response" or "linear")
Returns
Matrix of predicted responses
See also
Loss

Definition at line 238 of file slope_fit.h.


The documentation for this class was generated from the following file: