19 using namespace shogun;
70 SG_ERROR(
"Number of training vectors does not match number of labels\n");
116 SG_INFO(
"%d test examples\n", num_lab);
142 for (j=0; j<
m_k; j++)
144 classes[train_lab[j]]+= multiplier;
145 multiplier*= multiplier;
154 if (out_max< classes[j])
192 SG_INFO(
"%d test examples\n", num_lab);
211 if (distances[j]<min_dist)
213 min_dist = distances[j];
244 SG_INFO(
"%d test examples\n", num_lab);
264 for (int32_t j=0; j<
m_k; j++)
266 classes[train_lab[j]]++;
274 if (out_max< classes[c])
294 SG_ERROR(
"No distance assigned!\n");
299 SG_ERROR(
"No vectors on left hand side\n");
virtual void store_model_features()
virtual bool save(FILE *dstfile)
Class Distance, a base class for all the distances used in the Shogun toolbox.
bool set_label(int32_t idx, float64_t label)
void init_distance(CFeatures *data)
The class Labels models labels, i.e. class assignments of objects.
static void qsort_index(T1 *output, T2 *index, uint32_t size)
SGMatrix< int32_t > classify_for_multiple_k()
virtual int32_t get_num_vectors() const =0
void distances_lhs(float64_t *result, int32_t idx_a1, int32_t idx_a2, int32_t idx_b)
virtual CLabels * classify_NN()
virtual CFeatures * duplicate() const =0
virtual bool train_machine(CFeatures *data=NULL)
A generic DistanceMachine interface.
virtual bool load(FILE *srcfile)
virtual CLabels * apply()
int32_t get_num_vec_rhs()
void add(bool *param, const char *name, const char *description="")
int32_t m_k
the k parameter in KNN
virtual void free_vector()
virtual void set_store_model_features(bool store_model)
SGVector< int32_t > get_int_labels()
int32_t num_classes
number of classes (i.e. number of values labels can take)
int32_t min_label
smallest label, i.e. -1
static void clear_cancel()
SGVector< int32_t > train_labels
static T * clone_vector(const T *vec, int32_t len)
static T max(T a, T b)
return the maximum of two integers
static bool cancel_computations()
float64_t m_q
parameter q of rank weighting
The class Features is the base class of all feature objects.
static T min(T a, T b)
return the minimum of two integers
void set_distance(CDistance *d)
virtual bool init(CFeatures *lhs, CFeatures *rhs)
virtual void set_labels(CLabels *lab)
#define SG_MALLOC(type, len)