28 register_parameters();
40 register_parameters();
59 void CMulticlassMachine::register_parameters()
85 if (dynamic_cast<CLinearMachine*>(machine))
87 if (dynamic_cast<CKernelMachine*>(machine))
95 SG_DEBUG(
"entering %s::apply_multiclass(%s at %p)\n",
112 if (num_machines <= 0)
113 SG_ERROR(
"num_machines = %d, did you train your machine?", num_machines)
130 for (int32_t i=0; i<num_machines; ++i)
150 for (int32_t i=0; i<num_vectors; i++)
152 for (int32_t j=0; j<num_machines; j++)
153 output_for_i[j] = outputs[j]->get_value(i);
157 r_output_for_i = output_for_i;
167 for (int32_t r=0; r<num_classes; r++)
168 r_output_for_i[r] = output_for_i[r];
170 SG_DEBUG(
"%s::apply_multiclass(): sum(r_output_for_i) = %f\n",
179 for (int32_t i=0; i < num_machines; ++i)
184 return_labels=result;
190 SG_DEBUG(
"leaving %s::apply_multiclass(%s at %p)\n",
192 return return_labels;
211 if (num_machines <= 0)
212 SG_ERROR(
"num_machines = %d, did you train your machine?", num_machines)
213 REQUIRE(n_outputs<=num_machines,
"You request more outputs than machines available")
218 for (int32_t i=0; i < num_machines; ++i)
222 for (int32_t i=0; i<num_vectors; i++)
224 for (int32_t j=0; j<num_machines; j++)
225 output_for_i[j] = outputs[j]->get_value(i);
230 for (int32_t i=0; i < num_machines; ++i)
235 return_labels=result;
240 return return_labels;
248 SG_ERROR(
"Please provide training data.\n")
void allocate_confidences_for(int32_t n_classes)
virtual const char * get_name() const =0
CMachine * get_machine(int32_t num) const
virtual ~CMulticlassMachine()
The class Labels models labels, i.e. class assignments of objects.
virtual CMulticlassLabels * apply_multiclass(CFeatures *data=NULL)
CDynamicObjectArray * m_machines
virtual int32_t get_num_vectors() const =0
virtual void rescale_outputs(SGVector< float64_t > outputs)
int32_t get_num_elements() const
A generic KernelMachine interface.
virtual CMachine * get_machine_from_trained(CMachine *machine)=0
virtual void add_machine_subset(SGVector< index_t > subset)=0
virtual float64_t get_submachine_output(int32_t i, int32_t num)
A generic learning machine interface.
bool set_label(int32_t idx, float64_t label)
Multiclass Labels for multi-class classification.
virtual bool init_machine_for_train(CFeatures *data)=0
virtual CBinaryLabels * apply_binary(CFeatures *data=NULL)
static SigmoidParamters fit_sigmoid(SGVector< float64_t > scores)
void set_num_classes(int32_t num_classes)
virtual bool is_ready()=0
Class SGObject is the base class of all shogun objects.
virtual void train_stop()
CMulticlassStrategy * m_multiclass_strategy
virtual CBinaryLabels * get_submachine_outputs(int32_t i)
virtual CMultilabelLabels * apply_multilabel_output(CFeatures *data=NULL, int32_t n_outputs=5)
virtual void remove_subset()
virtual void add_subset(SGVector< index_t > subset)
virtual bool init_machines_for_apply(CFeatures *data)=0
Class LinearMachine is a generic interface for all kinds of linear machines like classifiers.
virtual float64_t apply_one(int32_t vec_idx)
virtual void remove_machine_subset()=0
void set_multiclass_confidences(int32_t i, SGVector< float64_t > confidences)
int32_t get_num_classes() const
all of classes and functions are contained in the shogun namespace
void set_label(int32_t j, SGVector< int32_t > label)
The class Features is the base class of all feature objects.
virtual bool train(CFeatures *data=NULL)
void scores_to_probabilities(float64_t a=0, float64_t b=0)
Binary Labels for binary classification.
CSGObject * get_element(int32_t index) const
class MulticlassStrategy used to construct generic multiclass classifiers with ensembles of binary cl...
EProbHeuristicType get_prob_heuris()
virtual bool train_has_more()=0
void resize_vector(int32_t n)
void push_back(CSGObject *e)
virtual SGVector< int32_t > train_prepare_next()
multiclass one vs rest strategy used to train generic multiclass machines for K-class problems with b...
virtual bool train_machine(CFeatures *data=NULL)
virtual const char * get_name() const
virtual int32_t get_num_rhs_vectors()=0
Multilabel Labels for multi-label classification.
virtual SGVector< index_t > decide_label_multiple_output(SGVector< float64_t > outputs, int32_t n_outputs)
virtual void set_labels(CLabels *lab)
static CMulticlassLabels * to_multiclass(CLabels *base_labels)
virtual void set_labels(CLabels *lab)
virtual void train_start(CMulticlassLabels *orig_labels, CBinaryLabels *train_labels)
virtual int32_t decide_label(SGVector< float64_t > outputs)=0