15 #include "generalmod.h" 29 , canbeneg_(canbeneg) {}
31 void add(
int val,T wt=1);
33 bool valid()
const {
return wts_; }
36 void clear() {
delete wts_; wts_ = 0; }
49 const int arridx = !canbeneg_ ? val
50 : (val < 0 ? -1 - 2 * val : 2 * val);
53 if ( !wts_ || wts_->size() <= arridx )
59 OD::memCopy( wts_->arr(), tmp->
arr(), tmp->
size() *
sizeof(T) );
62 T& curwt = (*wts_)[arridx];
73 if ( !valid() )
return 0;
75 int winner = -1; T maxwt = -1;
76 for (
int idx=0; idx<wts_->size(); idx++ )
78 if ( (*wts_)[idx] > maxwt )
79 { winner = idx; maxwt = (*wts_)[idx]; }
87 if ( winner % 2 ) res = -res;
#define mExpClass(module)
Definition: commondefs.h:160
bool canbeneg_
Definition: classify.h:40
void clear()
Definition: classify.h:36
void add(int val, T wt=1)
Definition: classify.h:47
virtual T * arr()
3rd party access
Definition: typeset.h:92
TypeSet< T > * wts_
Definition: classify.h:41
Set of (small) copyable elements.
Definition: commontypes.h:30
bool valid() const
Definition: classify.h:33
WeightedClassCounter(bool canbeneg=true)
Definition: classify.h:27
Finds out which class is the best from a series of weighted data points.
Definition: classify.h:24
int result() const
Definition: classify.h:71