source: trunk/test/nbc_test.cc @ 1437

Last change on this file since 1437 was 1437, checked in by Peter, 13 years ago

merge patch release 0.4.2 to trunk. Delta 0.4.2-0.4.1

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1// $Id: nbc_test.cc 1437 2008-08-25 17:55:00Z peter $
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 2 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 this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22  02111-1307, USA.
23*/
24
25#include "Suite.h"
26
27#include "yat/classifier/MatrixLookup.h"
28#include "yat/classifier/MatrixLookupWeighted.h"
29#include "yat/classifier/NBC.h"
30#include "yat/classifier/Target.h"
31#include "yat/utility/Matrix.h"
32
33#include <cassert>
34#include <fstream>
35#include <iostream>
36#include <string>
37
38using namespace theplu::yat;
39
40int main(int argc, char* argv[])
41{ 
42  test::Suite suite(argc, argv);
43  suite.err() << "testing ncc" << std::endl;
44
45  std::ifstream is(test::filename("data/nm_data_centralized.txt").c_str());
46  utility::Matrix data_core(is);
47  is.close();
48  classifier::MatrixLookup data(data_core);
49
50  is.open(test::filename("data/nm_target_bin.txt").c_str());
51  classifier::Target target(is);
52  is.close();
53
54  suite.err() << "Constructing NBC" << std::endl;
55  classifier::NBC nbc;
56  suite.err() << "Training NBC" << std::endl;
57  nbc.train(data,target);
58  utility::Matrix res;
59  suite.err() << "Predicting" << std::endl;
60  nbc.predict(data, res);
61
62  return suite.return_value();
63}
Note: See TracBrowser for help on using the repository browser.