Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wepe committed Sep 22, 2015
1 parent 3df6d4c commit 2195202
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions logistic regression/use_cpp_and_eigen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,43 @@


###Usage
```
//data prepare,10 samples

//data prepare,10 samples
MatrixXd X(10,2);
X<<1.0,0.8,2.0,1.7,3.0,2.5,4.0,3.6,5.0,4.9,
1.0,1.2,2.0,2.5,3.0,3.4,4.0,4.5,5.0,6.0;
1.0,1.2,2.0,2.5,3.0,3.4,4.0,4.5,5.0,6.0;
VectorXi y(10);
y<<0,0,0,0,0,1,1,1,1,1;
//train and save the weights
LR clf1 = LR(200,0.01,0.05,0.01); //max_iter=200,alpha=0.01(learning rate),l2_lambda=0.05,tolerance=0.01
clf1.fit(X,y);
cout<<"weights:\n"<<clf1.getW()<<endl;
clf1.saveWeights("test.weights");
//load the weights and predict
LR clf2 = LR();
clf2.loadWeights("test.weights");
cout<<"Predict:\n"<<clf2.predict(X)<<endl;

```


###DirTree

```
.
|-- common_functions.h
|-- common_functions.cc
|-- lr.h
|-- lr.cc
|-- main.cc
|-- makefile
|-- weights [direction where save the weights]
| `-- test.weights
|-- eigen_tutorial [show the basic usage of Eigen]
`-- eigen_usage.cc
```

.
|-- common_functions.h
|-- common_functions.cc
|-- lr.h
|-- lr.cc
|-- main.cc
|-- makefile
|-- weights [direction where save the weights]
| `-- test.weights
|-- eigen_tutorial [show the basic usage of Eigen]
`-- eigen_usage.cc





0 comments on commit 2195202

Please sign in to comment.