-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinnow.h
36 lines (32 loc) · 946 Bytes
/
winnow.h
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
#ifndef WINNOW_H
#define WINNOW_H
#include <base.h>
#include <mine.h>
namespace TDatastream {
///////////////////////////////
// Winnow
ClassTP(TWinnow, PWinnow) // {
private:
TWinnow(const int& FeaturesN, const double& Treshold, const double& Alpha)
: Treshold(Treshold), Alpha(Alpha) { WeightV.Reserve(FeaturesN, FeaturesN); }
public:
static PWinnow New(const int& FeaturesN, const double& Treshold, const double& Alpha = 2.0) {
return new TWinnow(FeaturesN, Treshold, Alpha);
}
static PWinnow New(const int& FeaturesN, const double& Alpha = 2.0) {
return new TWinnow(FeaturesN, FeaturesN/2.0, Alpha);
}
void Process(const TIntV& Example);
int Classify(const TIntV& Example);
void SetWeighs(TFltV& Model) const {
Model = WeightV;
}
private:
static double Dot(const TFltV& WeightV, const TIntV& BoolV);
private:
TFltV WeightV;
double Treshold;
double Alpha;
};
} // namespace TDatastream
#endif