41 void CNearestCentroid::init()
58 SG_ERROR(
"Number of training vectors does not match number of labels\n")
74 int64_t* num_per_class =
new int64_t[num_classes];
75 for (int32_t i=0 ; i<num_classes ; i++)
80 for (int32_t idx=0 ; idx<num_vectors ; idx++)
88 num_per_class[current_class]++;
93 for (int32_t i=0 ; i<num_classes ; i++)
96 int32_t total = num_per_class[i];
113 SG_FREE(num_per_class);
bool m_is_trained
Tells if the classifier has been trained or not.
virtual ELabelType get_label_type() const =0
Class Distance, a base class for all the distances used in the Shogun toolbox.
The class Labels models labels, i.e. class assignments of objects.
virtual int32_t get_num_labels() const =0
multi-class labels 0,1,...
void set_feature_matrix(SGMatrix< ST > matrix)
virtual void remove_lhs()
takes all necessary steps if the lhs is removed from distance matrix
virtual int32_t get_num_vectors() const =0
float64_t m_shrinking
Shrinking parameter.
A generic DistanceMachine interface.
static void scale_vector(T alpha, T *vec, int32_t len)
Scale vector inplace.
Multiclass Labels for multi-class classification.
void set_num_vectors(int32_t num)
virtual EFeatureClass get_feature_class() const =0
void set_num_features(int32_t num)
CDenseFeatures< float64_t > * m_centroids
The centroids of the trained features.
virtual bool train_machine(CFeatures *data=NULL)
all of classes and functions are contained in the shogun namespace
The class Features is the base class of all feature objects.
void set_distance(CDistance *d)
void scale(Matrix A, Matrix B, typename Matrix::Scalar alpha)
virtual ~CNearestCentroid()
void free_feature_matrix()
virtual bool init(CFeatures *lhs, CFeatures *rhs)
virtual void set_labels(CLabels *lab)
void add(const SGVector< T > x)