/usr/include/dforest.h is in libalglib-dev 2.6.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | /*************************************************************************
Copyright (c) 2009, Sergey Bochkanov (ALGLIB project).
>>> SOURCE LICENSE >>>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation (www.fsf.org); either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
A copy of the GNU General Public License is available at
http://www.fsf.org/licensing/licenses
>>> END OF LICENSE >>>
*************************************************************************/
#ifndef _dforest_h
#define _dforest_h
#include "ap.h"
#include "ialglib.h"
#include "tsort.h"
#include "descriptivestatistics.h"
#include "bdss.h"
struct decisionforest
{
int nvars;
int nclasses;
int ntrees;
int bufsize;
ap::real_1d_array trees;
};
struct dfreport
{
double relclserror;
double avgce;
double rmserror;
double avgerror;
double avgrelerror;
double oobrelclserror;
double oobavgce;
double oobrmserror;
double oobavgerror;
double oobavgrelerror;
};
struct dfinternalbuffers
{
ap::real_1d_array treebuf;
ap::integer_1d_array idxbuf;
ap::real_1d_array tmpbufr;
ap::real_1d_array tmpbufr2;
ap::integer_1d_array tmpbufi;
ap::integer_1d_array classibuf;
ap::integer_1d_array varpool;
ap::boolean_1d_array evsbin;
ap::real_1d_array evssplits;
};
/*************************************************************************
This subroutine builds random decision forest.
INPUT PARAMETERS:
XY - training set
NPoints - training set size, NPoints>=1
NVars - number of independent variables, NVars>=1
NClasses - task type:
* NClasses=1 - regression task with one
dependent variable
* NClasses>1 - classification task with
NClasses classes.
NTrees - number of trees in a forest, NTrees>=1.
recommended values: 50-100.
R - percent of a training set used to build
individual trees. 0<R<=1.
recommended values: 0.1 <= R <= 0.66.
OUTPUT PARAMETERS:
Info - return code:
* -2, if there is a point with class number
outside of [0..NClasses-1].
* -1, if incorrect parameters was passed
(NPoints<1, NVars<1, NClasses<1, NTrees<1, R<=0
or R>1).
* 1, if task has been solved
DF - model built
Rep - training report, contains error on a training set
and out-of-bag estimates of generalization error.
-- ALGLIB --
Copyright 19.02.2009 by Bochkanov Sergey
*************************************************************************/
void dfbuildrandomdecisionforest(const ap::real_2d_array& xy,
int npoints,
int nvars,
int nclasses,
int ntrees,
double r,
int& info,
decisionforest& df,
dfreport& rep);
void dfbuildinternal(const ap::real_2d_array& xy,
int npoints,
int nvars,
int nclasses,
int ntrees,
int samplesize,
int nfeatures,
int flags,
int& info,
decisionforest& df,
dfreport& rep);
/*************************************************************************
Procesing
INPUT PARAMETERS:
DF - decision forest model
X - input vector, array[0..NVars-1].
OUTPUT PARAMETERS:
Y - result. Regression estimate when solving regression task,
vector of posterior probabilities for classification task.
Subroutine does not allocate memory for this vector, it is
responsibility of a caller to allocate it. Array must be
at least [0..NClasses-1].
-- ALGLIB --
Copyright 16.02.2009 by Bochkanov Sergey
*************************************************************************/
void dfprocess(const decisionforest& df,
const ap::real_1d_array& x,
ap::real_1d_array& y);
/*************************************************************************
Relative classification error on the test set
INPUT PARAMETERS:
DF - decision forest model
XY - test set
NPoints - test set size
RESULT:
percent of incorrectly classified cases.
Zero if model solves regression task.
-- ALGLIB --
Copyright 16.02.2009 by Bochkanov Sergey
*************************************************************************/
double dfrelclserror(const decisionforest& df,
const ap::real_2d_array& xy,
int npoints);
/*************************************************************************
Average cross-entropy (in bits per element) on the test set
INPUT PARAMETERS:
DF - decision forest model
XY - test set
NPoints - test set size
RESULT:
CrossEntropy/(NPoints*LN(2)).
Zero if model solves regression task.
-- ALGLIB --
Copyright 16.02.2009 by Bochkanov Sergey
*************************************************************************/
double dfavgce(const decisionforest& df,
const ap::real_2d_array& xy,
int npoints);
/*************************************************************************
RMS error on the test set
INPUT PARAMETERS:
DF - decision forest model
XY - test set
NPoints - test set size
RESULT:
root mean square error.
Its meaning for regression task is obvious. As for
classification task, RMS error means error when estimating posterior
probabilities.
-- ALGLIB --
Copyright 16.02.2009 by Bochkanov Sergey
*************************************************************************/
double dfrmserror(const decisionforest& df,
const ap::real_2d_array& xy,
int npoints);
/*************************************************************************
Average error on the test set
INPUT PARAMETERS:
DF - decision forest model
XY - test set
NPoints - test set size
RESULT:
Its meaning for regression task is obvious. As for
classification task, it means average error when estimating posterior
probabilities.
-- ALGLIB --
Copyright 16.02.2009 by Bochkanov Sergey
*************************************************************************/
double dfavgerror(const decisionforest& df,
const ap::real_2d_array& xy,
int npoints);
/*************************************************************************
Average relative error on the test set
INPUT PARAMETERS:
DF - decision forest model
XY - test set
NPoints - test set size
RESULT:
Its meaning for regression task is obvious. As for
classification task, it means average relative error when estimating
posterior probability of belonging to the correct class.
-- ALGLIB --
Copyright 16.02.2009 by Bochkanov Sergey
*************************************************************************/
double dfavgrelerror(const decisionforest& df,
const ap::real_2d_array& xy,
int npoints);
/*************************************************************************
Copying of DecisionForest strucure
INPUT PARAMETERS:
DF1 - original
OUTPUT PARAMETERS:
DF2 - copy
-- ALGLIB --
Copyright 13.02.2009 by Bochkanov Sergey
*************************************************************************/
void dfcopy(const decisionforest& df1, decisionforest& df2);
/*************************************************************************
Serialization of DecisionForest strucure
INPUT PARAMETERS:
DF - original
OUTPUT PARAMETERS:
RA - array of real numbers which stores decision forest,
array[0..RLen-1]
RLen - RA lenght
-- ALGLIB --
Copyright 13.02.2009 by Bochkanov Sergey
*************************************************************************/
void dfserialize(const decisionforest& df, ap::real_1d_array& ra, int& rlen);
/*************************************************************************
Unserialization of DecisionForest strucure
INPUT PARAMETERS:
RA - real array which stores decision forest
OUTPUT PARAMETERS:
DF - restored structure
-- ALGLIB --
Copyright 13.02.2009 by Bochkanov Sergey
*************************************************************************/
void dfunserialize(const ap::real_1d_array& ra, decisionforest& df);
#endif
|