boost_error(useless).cpp
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
27  #include "peddetect.h"
28 
29 int main (int argc, char **argv)
30 {
31 
32 /* STEP 2. Opening the file */
33 //1. Declare a structure to keep the data
34  CvMLData cvml;
35 //2. Read the file
36  cvml.read_csv ("/home/pedrobatista/workingcopy/lar3/perception/pedestrians/PedestrianDetect/train_seed1234_rand.csv");
37 //3. Indicate which column is the response
38  cvml.set_response_idx (0);
39 
40 /* STEP 3. Splitting the samples */
41 //1. Select 40 for the training
42  CvTrainTestSplit cvtts (8000, true);
43 //2. Assign the division to the data
44  cvml.set_train_test_split (&cvtts);
45 
46  printf ("Training ... ");
47 /* STEP 4. The training */
48 //1. Declare the classifier
49  CvBoost boost;
50 //2. Train it with 100 features
51  boost.train (&cvml, CvBoostParams (CvBoost::REAL,1500, 0.95, 2, false, 0),
52  false);
53 
54 /* STEP 5. Calculating the testing and training error */
55 // 1. Declare a couple of vectors to save the predictions of each sample
56  std::vector<float> train_responses, test_responses;
57 // 2. Calculate the training error
58  float fl1 = boost.calc_error (&cvml, CV_TRAIN_ERROR, &train_responses);
59 // 3. Calculate the test error
60  float fl2 = boost.calc_error (&cvml, CV_TEST_ERROR, &test_responses);
61 
62  cout<<"Error train: "<<fl1<<endl;
63 
64  cout<<"Error test: "<<fl2<<endl;
65 
66 /* STEP 6. Save your classifier */
67 // Save the trained classifier
68 // boost.save ("./trained_boost_8000samples-1000ftrs.xml", "boost");
69 
70  return 0;
71 }
int main(int argc, char **argv)


pedestrian_detect
Author(s): Pedro Batista
autogenerated on Mon Mar 2 2015 01:32:33