13 #include "generalmod.h" 27 , canbeneg_(canbeneg) {}
29 void add(
int val,T wt=1);
31 bool valid()
const {
return wts_; }
34 void clear() {
delete wts_; wts_ = 0; }
47 const int arridx = !canbeneg_ ? val
48 : (val < 0 ? -1 - 2 * val : 2 * val);
51 if ( !wts_ || wts_->size() <= arridx )
57 OD::memCopy( wts_->arr(), tmp->
arr(), tmp->
size() *
sizeof(T) );
60 T& curwt = (*wts_)[arridx];
71 if ( !valid() )
return 0;
73 int winner = -1; T maxwt = -1;
74 for (
int idx=0; idx<wts_->size(); idx++ )
76 if ( (*wts_)[idx] > maxwt )
77 { winner = idx; maxwt = (*wts_)[idx]; }
85 if ( winner % 2 ) res = -res;
#define mExpClass(module)
Definition: commondefs.h:157
bool canbeneg_
Definition: classify.h:38
void clear()
Definition: classify.h:34
void add(int val, T wt=1)
Definition: classify.h:45
virtual T * arr()
3rd party access
Definition: typeset.h:86
TypeSet< T > * wts_
Definition: classify.h:39
Set of (small) copyable elements.
Definition: commontypes.h:26
bool valid() const
Definition: classify.h:31
WeightedClassCounter(bool canbeneg=true)
Definition: classify.h:25
Finds out which class is the best from a series of weighted data points.
Definition: classify.h:22
int result() const
Definition: classify.h:69