11 #ifndef LEASTANGLEREGRESSION_H__
12 #define LEASTANGLEREGRESSION_H__
109 m_max_l1_norm =
norm;
116 return m_max_l1_norm;
126 SG_ERROR(
"cannot swith estimator before training")
127 if (
size_t(num_variable) >= m_beta_idx.size() || num_variable < 0)
128 SG_ERROR(
"cannot switch to an estimator of %d non-zero coefficients", num_variable)
131 std::copy(m_beta_path[m_beta_idx[num_variable]].begin(),
132 m_beta_path[m_beta_idx[num_variable]].end(),
w.
vector);
145 return m_beta_idx.size();
172 virtual const char*
get_name()
const {
return "LeastAngleRegression"; }
178 void activate_variable(int32_t v)
181 m_active_set.push_back(v);
182 m_is_active[v] =
true;
184 void deactivate_variable(int32_t v_idx)
187 m_is_active[m_active_set[v_idx]] =
false;
188 m_active_set.erase(m_active_set.begin() + v_idx);
191 SGMatrix<float64_t> cholesky_insert(SGMatrix<float64_t> X, SGMatrix<float64_t> R, int32_t i_max_corr);
192 SGMatrix<float64_t> cholesky_delete(SGMatrix<float64_t> R, int32_t i_kick);
200 std::vector<std::vector<float64_t> > m_beta_path;
201 std::vector<int32_t> m_beta_idx;
203 std::vector<int32_t> m_active_set;
204 std::vector<bool> m_is_active;
205 int32_t m_num_active;
210 #endif // HAVE_LAPACK
211 #endif // LEASTANGLEREGRESSION_H__
MACHINE_PROBLEM_TYPE(PT_REGRESSION)
double norm(double *v, double p, int n)
virtual ~CLeastAngleRegression()
virtual bool train_machine(CFeatures *data=NULL)
virtual EMachineType get_classifier_type()
void switch_w(int32_t num_variable)
int32_t get_path_size() const
float64_t get_max_l1_norm() const
Class for Least Angle Regression, can be used to solve LASSO.
Class LinearMachine is a generic interface for all kinds of linear machines like classifiers.
void set_max_l1_norm(float64_t norm)
int32_t get_max_non_zero() const
all of classes and functions are contained in the shogun namespace
CLeastAngleRegression(bool lasso=true)
SGVector< float64_t > get_w_for_var(int32_t num_var)
The class Features is the base class of all feature objects.
virtual const char * get_name() const
void set_max_non_zero(int32_t n)