ElasticNetModel.h
Go to the documentation of this file.
1 #ifndef WIRECELLRESS_ELASTICNETMODEL_H
2 #define WIRECELLRESS_ELASTICNETMODEL_H
3 
5 #include <vector>
6 #include <Eigen/Dense>
7 
8 namespace WireCell {
9 
11 public:
12  ElasticNetModel(double lambda=1., double alpha=1., int max_iter=100000, double TOL=1e-3, bool non_negtive=true);
14 
15  double lambda; // regularization parameter
16  double alpha; // L1 ratio (L2 ratio = 1 - alpha)
17  int max_iter; // maximum iteration
18  double TOL;
20  Eigen::VectorXd lambda_weight; // each beta can have a weight on its regularization, default weight is 1;
21 
22  void SetLambdaWeight(Eigen::VectorXd w) { lambda_weight = w; }
23  void SetLambdaWeight(int i, double weight) { lambda_weight(i) = weight; }
24  void SetX(Eigen::MatrixXd X) { LinearModel::SetX(X); SetLambdaWeight(Eigen::VectorXd::Zero(X.cols()) + Eigen::VectorXd::Constant(X.cols(),1.)); }
25  virtual void Fit();
26 
27 protected:
28  double _soft_thresholding(double x, double lambda_);
29  std::vector<bool> _active_beta;
30 };
31 
32 }
33 
34 #endif
std::vector< bool > _active_beta
void SetLambdaWeight(Eigen::VectorXd w)
virtual void SetX(Eigen::MatrixXd X)
Definition: LinearModel.h:20
const double e
ElasticNetModel(double lambda=1., double alpha=1., int max_iter=100000, double TOL=1e-3, bool non_negtive=true)
void SetX(Eigen::MatrixXd X)
double _soft_thresholding(double x, double lambda_)
void SetLambdaWeight(int i, double weight)
Definition: Main.h:22
Eigen::VectorXd lambda_weight
list x
Definition: train.py:276
weight
Definition: test.py:257