#include "WireCellRess/LassoModel.h"
#include "WireCellRess/ElasticNetModel.h"
#include <Eigen/Dense>
#include <iostream>
Go to the source code of this file.
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 14 of file test_ress.cxx.
18 const int N_CELL = 40;
19 const int N_ZERO = 30;
20 const int N_WIRE =
int(N_CELL * 0.7);
23 VectorXd
C = VectorXd::Random(N_CELL)*50 + VectorXd::Constant(N_CELL, 150);
24 VectorXd
r = N_CELL / 2 * (VectorXd::Random(N_ZERO)+VectorXd::Constant(N_ZERO, 1));
25 for (
int i=0; i<N_ZERO; i++) {
30 MatrixXd
G = MatrixXd::Zero(N_WIRE, N_CELL);
31 for (
int i=0; i<N_WIRE; i++) {
32 VectorXd
t = VectorXd::Random(N_CELL);
33 for (
int j=0; j<N_CELL; j++) {
34 G(i, j) =
int(
t(j)+1);
41 cout <<
"geometry matrix:" <<
endl;
42 cout << G << endl <<
endl;
47 cout <<
"true charge of each cell:" <<
endl;
48 cout << C.transpose() << endl <<
endl;
void print_results(WireCell::LinearModel &m, VectorXd &C)
void test_lasso(WireCell::LassoModel &m, MatrixXd &G, VectorXd &W)
QTextStream & endl(QTextStream &s)
Definition at line 83 of file test_ress.cxx.
87 cout <<
"fitted charge of each cell: " << m.
name <<
endl;
88 cout << beta.transpose() <<
endl <<
endl;
93 cout <<
"average residual charge difference per wire: " << m.
name <<
": " 97 int nbeta = beta.size();
101 int n_zero_correct = 0;
103 for (
int i=0; i<nbeta; i++) {
104 if (fabs(
C(i))<0.1) n_zero_true++;
105 if (fabs(beta(i))<5) n_zero_beta++;
106 if (fabs(
C(i))<0.1 && (fabs(
C(i) - beta(i)) < 10)) n_zero_correct++;
108 cout <<
"true zeros: " << n_zero_true <<
endl;
109 cout <<
"fitted zeros: " << n_zero_beta <<
endl;
110 cout <<
"correct fitted zeros: " << n_zero_correct <<
endl;
113 }
Eigen::VectorXd & Getbeta()
QTextStream & endl(QTextStream &s)
Definition at line 69 of file test_ress.cxx.
79 cout <<
"chi2: " << m.
name <<
": base="
virtual void SetData(Eigen::MatrixXd X, Eigen::VectorXd y)
QTextStream & endl(QTextStream &s)
Definition at line 62 of file test_ress.cxx.
virtual void SetData(Eigen::MatrixXd X, Eigen::VectorXd y)