Class LinearClassifier is a generic interface for all kinds of linear classifiers.
A linear classifier computes
where are the weights assigned to each feature in training and
the bias.
To implement a linear classifier all that is required is to define the train() function that delivers above.
Note that this framework works with linear classifiers of arbitraty feature type, e.g. dense and sparse and even string based features. This is implemented by using CDotFeatures that may provide a mapping function encapsulating all the required operations (like the dot product). The decision function is thus
The following linear classifiers are implemented
在文件LinearClassifier.h第60行定义。
公有成员 | |
CLinearClassifier () | |
virtual | ~CLinearClassifier () |
virtual float64_t | classify_example (int32_t vec_idx) |
get output for example "vec_idx" | |
void | get_w (float64_t *&dst_w, int32_t &dst_dims) |
void | get_w (float64_t **dst_w, int32_t *dst_dims) |
void | set_w (float64_t *src_w, int32_t src_w_dim) |
void | set_bias (float64_t b) |
float64_t | get_bias () |
virtual bool | load (FILE *srcfile) |
virtual bool | save (FILE *dstfile) |
virtual void | set_features (CDotFeatures *feat) |
virtual CLabels * | classify () |
virtual CLabels * | classify (CFeatures *data) |
virtual CDotFeatures * | get_features () |
保护属性 | |
int32_t | w_dim |
float64_t * | w |
float64_t | bias |
CDotFeatures * | features |
default constructor
在文件LinearClassifier.cpp第15行定义。
~CLinearClassifier | ( | ) | [virtual] |
在文件LinearClassifier.cpp第20行定义。
CLabels * classify | ( | ) | [virtual] |
classify objects
data | (test)data to be classified |
实现了CClassifier。
在文件LinearClassifier.cpp第58行定义。
virtual float64_t classify_example | ( | int32_t | vec_idx ) | [virtual] |
float64_t get_bias | ( | ) |
virtual CDotFeatures* get_features | ( | ) | [virtual] |
void get_w | ( | float64_t *& | dst_w, |
int32_t & | dst_dims | ||
) |
void get_w | ( | float64_t ** | dst_w, |
int32_t * | dst_dims | ||
) |
get w (swig compatible)
dst_w | store w in this argument |
dst_dims | dimension of w |
在文件LinearClassifier.h第90行定义。
bool load | ( | FILE * | srcfile ) | [virtual] |
load from file
srcfile | file to load from |
重载CClassifier。
在文件LinearClassifier.cpp第26行定义。
bool save | ( | FILE * | dstfile ) | [virtual] |
save to file
dstfile | file to save to |
重载CClassifier。
在文件LinearClassifier.cpp第31行定义。
void set_bias | ( | float64_t | b ) |
virtual void set_features | ( | CDotFeatures * | feat ) | [virtual] |
void set_w | ( | float64_t * | src_w, |
int32_t | src_w_dim | ||
) |
bias
在文件LinearClassifier.h第181行定义。
CDotFeatures* features [protected] |
features
在文件LinearClassifier.h第183行定义。
w
在文件LinearClassifier.h第179行定义。
int32_t w_dim [protected] |
dimension of w
在文件LinearClassifier.h第177行定义。