11 #ifndef LEASTANGLEREGRESSION_H__ 12 #define LEASTANGLEREGRESSION_H__ 14 #include <shogun/lib/config.h> 111 m_max_l1_norm = norm;
118 return m_max_l1_norm;
129 REQUIRE(w.
vlen > 0,
"Please train the model (i.e. run the model's train() method) before updating its weights.\n")
130 REQUIRE(
size_t(num_variable) < m_beta_idx.size() && num_variable >= 0,
131 "Cannot switch to an estimator of %d non-zero coefficients.\n", num_variable)
135 std::copy(m_beta_path[m_beta_idx[num_variable]].begin(),
136 m_beta_path[m_beta_idx[num_variable]].end(), w.
vector);
149 return m_beta_idx.size();
189 virtual const char*
get_name()
const {
return "LeastAngleRegression"; }
203 template <
typename ST>
207 template <
typename ST>
210 template <
typename ST>
215 template <
typename ST>
216 static void find_max_abs(
const std::vector<ST> &vec,
const std::vector<bool> &ignore_mask,
217 int32_t &imax, ST& vmax);
226 template <
typename ST>
229 void activate_variable(int32_t v)
232 m_active_set.push_back(v);
233 m_is_active[v] =
true;
236 void deactivate_variable(int32_t v_idx)
239 m_is_active[m_active_set[v_idx]] =
false;
240 m_active_set.erase(m_active_set.begin() + v_idx);
248 std::vector<std::vector<float64_t> > m_beta_path;
249 std::vector<int32_t> m_beta_idx;
250 std::vector<int32_t> m_active_set;
251 std::vector<bool> m_is_active;
252 int32_t m_num_active;
258 #endif // LEASTANGLEREGRESSION_H__
MACHINE_PROBLEM_TYPE(PT_REGRESSION)
SGMatrix< ST > cholesky_delete(SGMatrix< ST > &R, int32_t i_kick)
SGMatrix< ST > cholesky_insert(const SGMatrix< ST > &X, const SGMatrix< ST > &X_active, SGMatrix< ST > &R, int32_t i_max_corr, int32_t num_active)
virtual const char * get_name() const
virtual ~CLeastAngleRegression()
static void find_max_abs(const std::vector< ST > &vec, const std::vector< bool > &ignore_mask, int32_t &imax, ST &vmax)
static void plane_rot(ST x0, ST x1, ST &y0, ST &y1, SGMatrix< ST > &G)
virtual EMachineType get_classifier_type()
void switch_w(int32_t num_variable)
Class for Least Angle Regression, can be used to solve LASSO.
int32_t get_max_non_zero() const
Class LinearMachine is a generic interface for all kinds of linear machines like classifiers.
bool train_machine(CFeatures *data)
void set_max_l1_norm(float64_t norm)
The class DenseFeatures implements dense feature matrices.
void set_epsilon(float64_t epsilon)
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 SGVector< float64_t > get_w() const
void set_max_non_zero(int32_t n)
int32_t get_path_size() const
float64_t get_max_l1_norm() const