source: trunk/test/nbc_test.cc @ 1658

Last change on this file since 1658 was 1487, checked in by Jari Häkkinen, 13 years ago

Addresses #436. GPL license copy reference should also be updated.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1// $Id: nbc_test.cc 1487 2008-09-10 08:41:36Z jari $
2
3/*
4  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
5  Copyright (C) 2008 Peter Johansson, Markus Ringnér
6
7  This file is part of the yat library, http://dev.thep.lu.se/yat
8
9  The yat library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 3 of the
12  License, or (at your option) any later version.
13
14  The yat library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with yat. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include "Suite.h"
24
25#include "yat/classifier/MatrixLookup.h"
26#include "yat/classifier/MatrixLookupWeighted.h"
27#include "yat/classifier/NBC.h"
28#include "yat/classifier/Target.h"
29#include "yat/utility/Matrix.h"
30
31#include <cassert>
32#include <fstream>
33#include <iostream>
34#include <string>
35
36using namespace theplu::yat;
37
38int main(int argc, char* argv[])
39{ 
40  test::Suite suite(argc, argv);
41  suite.err() << "testing ncc" << std::endl;
42
43  std::ifstream is(test::filename("data/nm_data_centralized.txt").c_str());
44  utility::Matrix data_core(is);
45  is.close();
46  classifier::MatrixLookup data(data_core);
47
48  is.open(test::filename("data/nm_target_bin.txt").c_str());
49  classifier::Target target(is);
50  is.close();
51
52  suite.err() << "Constructing NBC" << std::endl;
53  classifier::NBC nbc;
54  suite.err() << "Training NBC" << std::endl;
55  nbc.train(data,target);
56  utility::Matrix res;
57  suite.err() << "Predicting" << std::endl;
58  nbc.predict(data, res);
59
60  return suite.return_value();
61}
Note: See TracBrowser for help on using the repository browser.