source: orange/source/orange/trindex.hpp @ 11703:9b8d8ab7820c

Revision 11703:9b8d8ab7820c, 3.7 KB checked in by janezd <janez.demsar@…>, 7 months ago (diff)

Removed the GPL copyright notice from all files except orangeqt.

Line 
1#ifndef __TRINDEX_HPP
2#define __TRINDEX_HPP
3
4#include <vector>
5#include "orvector.hpp"
6#include "random.hpp"
7using namespace std;
8
9WRAPPER(ExampleGenerator);
10
11
12// For compatibility ...
13#define TFoldIndices TLongList
14#define PFoldIndices PLongList
15#define PRandomIndices PLongList
16
17class ORANGE_API TMakeRandomIndices : public TOrange {
18public:
19  __REGISTER_CLASS
20  CLASSCONSTANTS(Stratification: StratifiedIfPossible=-1; NotStratified; Stratified)
21
22  enum { STRATIFIED_IF_POSSIBLE=-1, NOT_STRATIFIED, STRATIFIED};
23
24  int stratified;  //P(&MakeRandomIndices_Stratification) requests stratified distributions
25  int randseed; //P a seed for random generator
26  PRandomGenerator randomGenerator; //P a random generator
27
28  TMakeRandomIndices(const int &stratified=STRATIFIED_IF_POSSIBLE, const int &randseed=-1);
29  TMakeRandomIndices(const int &stratified, PRandomGenerator);
30};
31
32WRAPPER(MakeRandomIndices)
33
34// Prepares a vector of 0's and 1's with given distribution.
35class ORANGE_API TMakeRandomIndices2 : public TMakeRandomIndices {
36public:
37  __REGISTER_CLASS
38
39  float p0; //P a proportion or a number of 0's
40
41  TMakeRandomIndices2(const float &p0=1.0, const int &stratified=TMakeRandomIndices::STRATIFIED_IF_POSSIBLE, const int &randseed=-1);
42  TMakeRandomIndices2(const float &p0, const int &stratified, PRandomGenerator);
43
44  PRandomIndices operator()(const int &n);
45  PRandomIndices operator()(const int &n, const float &p0);
46
47  PRandomIndices operator()(PExampleGenerator);
48  PRandomIndices operator()(PExampleGenerator, const float &p0);
49};
50
51
52
53/*  Prepares a vector of indices with given distribution. Similar to TMakeRandomIndices2, this object's constructor
54    is given the size of vector and the required distribution of indices. */
55class ORANGE_API TMakeRandomIndicesN : public TMakeRandomIndices {
56public:
57  __REGISTER_CLASS
58
59  PFloatList p; //P probabilities of indices (last is 1-sum(p))
60
61  TMakeRandomIndicesN(const int &stratified=TMakeRandomIndices::STRATIFIED_IF_POSSIBLE, const int &randseed=-1);
62  TMakeRandomIndicesN(PFloatList p, const int &stratified=TMakeRandomIndices::STRATIFIED_IF_POSSIBLE, const int &randseed=-1);
63
64  TMakeRandomIndicesN(const int &stratified, PRandomGenerator);
65  TMakeRandomIndicesN(PFloatList p, const int &stratified, PRandomGenerator);
66
67  PRandomIndices operator()(const int &n);
68  PRandomIndices operator()(const int &n, PFloatList p);
69
70  PRandomIndices operator()(PExampleGenerator);
71  PRandomIndices operator()(PExampleGenerator, PFloatList p);
72};
73
74
75// Indices for cross validation
76class ORANGE_API TMakeRandomIndicesCV : public TMakeRandomIndices {
77public:
78  __REGISTER_CLASS
79
80  int folds; //P number of folds
81
82  TMakeRandomIndicesCV(const int &folds=10, const int &stratified=TMakeRandomIndices::STRATIFIED_IF_POSSIBLE, const int &randseed=-1);
83  TMakeRandomIndicesCV(const int &folds, const int &stratified, PRandomGenerator);
84
85  PRandomIndices operator()(const int &n);
86  PRandomIndices operator()(const int &n, const int &folds);
87
88  PRandomIndices operator()(PExampleGenerator);
89  PRandomIndices operator()(PExampleGenerator, const int &folds);
90};
91
92
93// Prepares a vector of 0's and 1's with given distribution.
94class ORANGE_API TMakeRandomIndicesMultiple : public TMakeRandomIndices {
95public:
96  __REGISTER_CLASS
97
98  float p0; // proportion/number of examples
99
100  TMakeRandomIndicesMultiple(const float &p0=1.0, const int &stratified=TMakeRandomIndices::STRATIFIED_IF_POSSIBLE, const int &randseed=-1);
101  TMakeRandomIndicesMultiple(const float &p0, const int &stratified, PRandomGenerator);
102
103  PRandomIndices operator()(const int &n);
104  PRandomIndices operator()(const int &n, const float &p0);
105
106  PRandomIndices operator()(PExampleGenerator);
107  PRandomIndices operator()(PExampleGenerator, const float &p0);
108
109};
110
111
112#endif
113
Note: See TracBrowser for help on using the repository browser.