[3615] | 1 | // $Id: poisson.cc 3615 2017-02-06 02:31:36Z peter $ |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | Copyright (C) 2017 Jari Häkkinen |
---|
| 5 | |
---|
| 6 | This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
| 7 | |
---|
| 8 | The yat library is free software; you can redistribute it and/or |
---|
| 9 | modify it under the terms of the GNU General Public License as |
---|
| 10 | published by the Free Software Foundation; either version 3 of the |
---|
| 11 | License, or (at your option) any later version. |
---|
| 12 | |
---|
| 13 | The yat library is distributed in the hope that it will be useful, |
---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 16 | General Public License for more details. |
---|
| 17 | |
---|
| 18 | You should have received a copy of the GNU General Public License |
---|
| 19 | along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #include <config.h> |
---|
| 23 | |
---|
| 24 | #include "Suite.h" |
---|
| 25 | |
---|
| 26 | #include "yat/regression/Poisson.h" |
---|
| 27 | #include "yat/utility/Matrix.h" |
---|
| 28 | #include "yat/utility/Vector.h" |
---|
| 29 | |
---|
| 30 | using namespace theplu::yat; |
---|
| 31 | |
---|
| 32 | int main(int argc, char* argv[]) |
---|
| 33 | { |
---|
| 34 | test::Suite suite(argc, argv); |
---|
| 35 | |
---|
| 36 | regression::Poisson model; |
---|
| 37 | size_t n = 20; |
---|
| 38 | size_t p = 4; |
---|
| 39 | utility::Vector y(n); |
---|
| 40 | utility::Matrix X(n, p); |
---|
| 41 | model.fit(X, y); |
---|
| 42 | if (model.fit_parameters().size() != p+1) { |
---|
| 43 | suite.add(false); |
---|
| 44 | suite.err() << "error: size of fit_parameters: " |
---|
| 45 | << model.fit_parameters().size() |
---|
| 46 | << " expected " << p+1 << "\n"; |
---|
| 47 | } |
---|
| 48 | model.predict(X.row_const_view(0)); |
---|
| 49 | |
---|
| 50 | return suite.return_value(); |
---|
| 51 | } |
---|