SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ParameterCombination.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2011-2012 Heiko Strathmann
8  * Written (W) 2012 Jacob Walker
9  * Written (W) 2013 Roman Votyakov
10  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
11  */
12 
14 #include <shogun/base/Parameter.h>
15 #include <shogun/machine/Machine.h>
16 #include <set>
17 #include <string>
18 
19 using namespace shogun;
20 using namespace std;
21 
23 {
24  init();
25 }
26 
28 {
29  init();
30 
31  m_param=param;
32 }
33 
35 {
36  init();
37 
38  Parameter* gradient_params=obj->m_gradient_parameters;
39 
40  for (index_t i=0; i<gradient_params->get_num_parameters(); i++)
41  {
42  TParameter* param=gradient_params->get_parameter(i);
43  TSGDataType type=param->m_datatype;
44 
45  if (type.m_ptype==PT_FLOAT64 || type.m_ptype==PT_FLOAT32 ||
46  type.m_ptype==PT_FLOATMAX)
47  {
48  if (type.m_ctype==CT_SGVECTOR || type.m_ctype==CT_VECTOR)
49  {
50  Parameter* p=new Parameter();
51  p->add_vector((float64_t**)param->m_parameter, type.m_length_y,
52  param->m_name);
53 
54  m_child_nodes->append_element(new CParameterCombination(p));
55  m_parameters_length+=*(type.m_length_y);
56  }
57  else if (type.m_ctype==CT_SGMATRIX || type.m_ctype==CT_MATRIX)
58  {
59  Parameter* p=new Parameter();
60  p->add_matrix((float64_t**)param->m_parameter, type.m_length_y,
61  type.m_length_x, param->m_name);
62 
63  m_child_nodes->append_element(new CParameterCombination(p));
64  m_parameters_length+=type.get_num_elements();
65  }
66  else if (type.m_ctype==CT_SCALAR)
67  {
68  Parameter* p=new Parameter();
69  p->add((float64_t*)param->m_parameter, param->m_name);
70 
71  m_child_nodes->append_element(new CParameterCombination(p));
72  m_parameters_length++;
73  }
74  else
75  {
76  SG_WARNING("Parameter %s.%s was not added to parameter combination, "
77  "since it isn't a type currently supported\n", obj->get_name(),
78  param->m_name);
79  }
80  }
81  else
82  {
83  SG_WARNING("Parameter %s.%s was not added to parameter combination, "
84  "since it isn't of floating point type\n", obj->get_name(),
85  param->m_name);
86  }
87  }
88 
89  Parameter* modsel_params=obj->m_model_selection_parameters;
90 
91  for (index_t i=0; i<modsel_params->get_num_parameters(); i++)
92  {
93  TParameter* param=modsel_params->get_parameter(i);
94  TSGDataType type=param->m_datatype;
95 
96  if (type.m_ptype==PT_SGOBJECT)
97  {
98  if (type.m_ctype==CT_SCALAR)
99  {
100  CSGObject* child=*((CSGObject**)(param->m_parameter));
101 
103  {
105 
106  comb->m_param=new Parameter();
107  comb->m_param->add((CSGObject**)(param->m_parameter),
108  param->m_name);
109 
110  m_child_nodes->append_element(comb);
111  m_parameters_length+=comb->m_parameters_length;
112  }
113  }
114  else
115  {
117  }
118  }
119  }
120 }
121 
122 void CParameterCombination::init()
123 {
124  m_parameters_length=0;
125  m_param=NULL;
126  m_child_nodes=new CDynamicObjectArray();
127  SG_REF(m_child_nodes);
128 
129  SG_ADD((CSGObject**)&m_child_nodes, "child_nodes", "Children of this node",
131 }
132 
134 {
135  delete m_param;
136  SG_UNREF(m_child_nodes);
137 }
138 
140 {
141  m_child_nodes->append_element(child);
142 }
143 
145  const char* name, bool value, index_t index)
146 {
147  if (m_param)
148  {
149  for (index_t i = 0; i < m_param->get_num_parameters(); ++i)
150  {
151  void* param = m_param->get_parameter(i)->m_parameter;
152 
153  if (!strcmp(m_param->get_parameter(i)->m_name, name))
154  {
155  if (m_param->get_parameter(i)->m_datatype.m_ptype
156  != PT_BOOL)
157  SG_ERROR("Parameter %s not a boolean parameter", name)
158 
159  if (index < 0)
160  *((bool*)(param)) = value;
161 
162  else
163  (*((bool**)(param)))[index] = value;
164 
165  return true;
166  }
167  }
168 
169  }
170 
171  return false;
172 }
173 
175  const char* name, int32_t value, index_t index)
176 {
177  if (m_param)
178  {
179  for (index_t i = 0; i < m_param->get_num_parameters(); ++i)
180  {
181  void* param = m_param->get_parameter(i)->m_parameter;
182 
183  if (!strcmp(m_param->get_parameter(i)->m_name, name))
184  {
185  if (m_param->get_parameter(i)->m_datatype.m_ptype
186  != PT_INT32)
187  SG_ERROR("Parameter %s not a integer parameter", name)
188 
189  if (index < 0)
190  *((int32_t*)(param)) = value;
191 
192  else
193  (*((int32_t**)(param)))[index] = value;
194 
195  return true;
196  }
197  }
198  }
199 
200  return false;
201 }
202 
204  const char* name, float64_t value, index_t index)
205 {
206  if (m_param)
207  {
208  for (index_t i = 0; i < m_param->get_num_parameters(); ++i)
209  {
210  void* param = m_param->get_parameter(i)->m_parameter;
211 
212  if (!strcmp(m_param->get_parameter(i)->m_name, name))
213  {
214  if (m_param->get_parameter(i)->m_datatype.m_ptype
215  != PT_FLOAT64)
216  SG_ERROR("Parameter %s not a double parameter", name)
217 
218  if (index < 0)
219  *((float64_t*)(param)) = value;
220 
221  else
222  (*((float64_t**)(param)))[index] = value;
223 
224  return true;
225  }
226  }
227 
228  }
229 
230  return false;
231 }
232 
233 
235 {
236  if (m_param)
237  {
238  for (index_t i = 0; i < m_param->get_num_parameters(); i++)
239  {
240  if (!strcmp(m_param->get_parameter(i)->m_name, name))
241  return m_param->get_parameter(i);
242  }
243 
244  }
245 
246  return NULL;
247 }
248 
249 
251  CSGObject* parent)
252 {
253  bool match = false;
254 
255  if (m_param)
256  {
257  for (index_t i = 0; i < m_param->get_num_parameters(); i++)
258  {
259  if (m_param->get_parameter(i)->m_datatype.m_ptype==PT_SGOBJECT)
260  {
261  CSGObject* obj =
262  (*((CSGObject**)m_param->get_parameter(i)->m_parameter));
263  if (parent == obj)
264  match = true;
265  }
266  }
267 
268  }
269 
270  for (index_t i = 0; i < m_child_nodes->get_num_elements(); ++i)
271  {
273  m_child_nodes->get_element(i);
274 
275  TParameter* p;
276 
277  if (!match)
278  p = child->get_parameter(name, parent);
279 
280  else
281  p = child->get_parameter_helper(name);
282 
283  if (p)
284  {
285  SG_UNREF(child);
286  return p;
287  }
288 
289  SG_UNREF(child);
290  }
291 
292  return NULL;
293 }
294 
295 
297 {
298  for (index_t i=0; i<node->m_child_nodes->get_num_elements(); ++i)
299  {
300  CParameterCombination* child=
302  append_child(child->copy_tree());
303  SG_UNREF(child);
304  }
305 }
306 
307 void CParameterCombination::print_tree(int prefix_num) const
308 {
309  /* prefix is enlarged */
310  char* prefix=SG_MALLOC(char, prefix_num+1);
311  for (index_t i=0; i<prefix_num; ++i)
312  prefix[i]='\t';
313 
314  prefix[prefix_num]='\0';
315 
316  /* cases:
317  * -node with a Parameter instance and a possible children
318  * -root node with children
319  */
320 
321  if (m_param)
322  {
323  SG_SPRINT("%s", prefix)
324  for (index_t i=0; i<m_param->get_num_parameters(); ++i)
325  {
326  EContainerType ctype = m_param->get_parameter(i)->m_datatype.m_ctype;
327 
328  /* distinction between sgobject and values */
329  if (m_param->get_parameter(i)->m_datatype.m_ptype==PT_SGOBJECT)
330  {
331  TParameter* param=m_param->get_parameter(i);
332  CSGObject* current_sgobject=*((CSGObject**) param->m_parameter);
333  SG_SPRINT("\"%s\":%s at %p ", param->m_name,
334  current_sgobject->get_name(), current_sgobject);
335  }
336  else if (ctype==CT_SGVECTOR || ctype==CT_VECTOR || ctype==CT_SGMATRIX || ctype==CT_MATRIX)
337  {
338  SG_SPRINT("\"%s\"=", m_param->get_parameter(i)->m_name)
339  float64_t** param = (float64_t**)(m_param->
340  get_parameter(i)->m_parameter);
341 
342  index_t length = m_param->get_parameter(i)->m_datatype.get_num_elements();
343 
344  for (index_t j = 0; j < length; j++)
345  SG_SPRINT("%f ", (*param)[j])
346  }
347 
348  else
349  {
350  SG_SPRINT("\"%s\"=", m_param->get_parameter(i)->m_name)
351  void* param=m_param->get_parameter(i)->m_parameter;
352 
353  if (m_param->get_parameter(i)->m_datatype.m_ptype==PT_FLOAT64)
354  SG_SPRINT("%f ", *((float64_t*)param))
355  else if (m_param->get_parameter(i)->m_datatype.m_ptype==PT_INT32)
356  SG_SPRINT("%i ", *((int32_t*)param))
357  else if (m_param->get_parameter(i)->m_datatype.m_ptype==PT_BOOL)
358  SG_SPRINT("%s ", *((bool*)param ? "true" : "false"))
359  else
361  }
362 
363  }
364 
365  }
366  else
367  SG_SPRINT("%sroot", prefix)
368 
369  SG_SPRINT("\n")
370 
371  for (index_t i=0; i<m_child_nodes->get_num_elements(); ++i)
372  {
374  m_child_nodes->get_element(i);
375  child->print_tree(prefix_num+1);
376  SG_UNREF(child);
377  }
378 
379  SG_FREE(prefix);
380 }
381 
383  const DynArray<Parameter*>& set_1, const DynArray<Parameter*>& set_2)
384 {
385  SG_SDEBUG("entering CParameterCombination::parameter_set_multiplication()\n")
386 
387  SG_SDEBUG("set 1:\n")
388  for (index_t i=0; i<set_1.get_num_elements(); ++i)
389  {
390  for (index_t j=0; j<set_1.get_element(i)->get_num_parameters(); ++j)
391  SG_SDEBUG("\t%s\n", set_1.get_element(i)->get_parameter(j)->m_name)
392  }
393 
394  SG_SDEBUG("set 2:\n")
395  for (index_t i=0; i<set_2.get_num_elements(); ++i)
396  {
397  for (index_t j=0; j<set_2.get_element(i)->get_num_parameters(); ++j)
398  SG_SDEBUG("\t%s\n", set_2.get_element(i)->get_parameter(j)->m_name)
399  }
400 
402 
403  for (index_t i=0; i<set_1.get_num_elements(); ++i)
404  {
405  for (index_t j=0; j<set_2.get_num_elements(); ++j)
406  {
407  Parameter* p=new Parameter();
408  p->add_parameters(set_1[i]);
409  p->add_parameters(set_2[j]);
410  result->append_element(p);
411  }
412  }
413 
414  SG_SDEBUG("leaving CParameterCombination::parameter_set_multiplication()\n")
415  return result;
416 }
417 
419  const CDynamicObjectArray& sets, const CParameterCombination* new_root)
420 {
422 
423  /* check marginal cases */
424  if (sets.get_num_elements()==1)
425  {
426  CDynamicObjectArray* current_set=
428 
429  /* just use the only element into result array.
430  * put root node before all combinations*/
431  *result=*current_set;
432 
433  SG_UNREF(current_set);
434 
435  for (index_t i=0; i<result->get_num_elements(); ++i)
436  {
437  /* put new root as root into the tree and replace tree */
439  result->get_element(i);
440  CParameterCombination* root=new_root->copy_tree();
441  root->append_child(current);
442  result->set_element(root, i);
443  SG_UNREF(current);
444  }
445  }
446  else if (sets.get_num_elements()>1)
447  {
448  /* now the case where at least two sets are given */
449 
450  /* first, extract Parameter instances of given sets */
451  DynArray<DynArray<Parameter*>*> param_sets;
452 
453  for (index_t set_nr=0; set_nr<sets.get_num_elements(); ++set_nr)
454  {
456  sets.get_element(set_nr);
457  DynArray<Parameter*>* new_param_set=new DynArray<Parameter*> ();
458  param_sets.append_element(new_param_set);
459 
460  for (index_t i=0; i<current_set->get_num_elements(); ++i)
461  {
463  current_set->get_element(i);
464 
465  if (current_node->m_child_nodes->get_num_elements())
466  {
467  SG_SERROR("leaf sets multiplication only possible if all "
468  "trees are leafs");
469  }
470 
471  Parameter* current_param=current_node->m_param;
472 
473  if (current_param)
474  new_param_set->append_element(current_param);
475  else
476  {
477  SG_SERROR("leaf sets multiplication only possible if all "
478  "leafs have non-NULL Parameter instances\n");
479  }
480 
481  SG_UNREF(current_node);
482  }
483 
484  SG_UNREF(current_set);
485  }
486 
487  /* second, build products of all parameter sets */
488  DynArray<Parameter*>* param_product=parameter_set_multiplication(
489  *param_sets[0], *param_sets[1]);
490 
491  delete param_sets[0];
492  delete param_sets[1];
493 
494  /* build product of all remaining sets and collect results. delete all
495  * parameter instances of interim products*/
496  for (index_t i=2; i<param_sets.get_num_elements(); ++i)
497  {
498  DynArray<Parameter*>* old_temp_result=param_product;
499  param_product=parameter_set_multiplication(*param_product,
500  *param_sets[i]);
501 
502  /* delete interim result parameter instances */
503  for (index_t j=0; j<old_temp_result->get_num_elements(); ++j)
504  delete old_temp_result->get_element(j);
505 
506  /* and dyn arrays of interim result and of param_sets */
507  delete old_temp_result;
508  delete param_sets[i];
509  }
510 
511  /* at this point there is only one DynArray instance remaining:
512  * param_product. contains all combinations of parameters of all given
513  * sets */
514 
515  /* third, build tree sets with the given root and the parameter product
516  * elements */
517  for (index_t i=0; i<param_product->get_num_elements(); ++i)
518  {
519  /* build parameter node from parameter product to append to root */
521  param_product->get_element(i));
522 
523  /* copy new root node, has to be a new one each time */
524  CParameterCombination* root=new_root->copy_tree();
525 
526  /* append both and add them to result set */
527  root->append_child(param_node);
528  result->append_element(root);
529  }
530 
531  /* this is not needed anymore, because the Parameter instances are now
532  * in the resulting tree sets */
533  delete param_product;
534  }
535 
536  return result;
537 }
538 
540  const CDynamicObjectArray* sets,
541  const CParameterCombination* new_root)
542 {
543  SG_SDEBUG("entering CParameterCombination::non_value_tree_multiplication()\n")
545 
546  /* first step: get all names in the sets */
547  set<string> names;
548 
549  for (index_t j=0;
550  j<sets->get_num_elements(); ++j)
551  {
552  CDynamicObjectArray* current_set=
554  sets->get_element(j);
555 
556  for (index_t k=0; k
557  <current_set->get_num_elements(); ++k)
558  {
560  current_set->get_element(k);
561 
562  names.insert(string(current_tree->m_param->get_parameter(0)->m_name));
563 
564  SG_UNREF(current_tree);
565  }
566 
567  SG_UNREF(current_set);
568  }
569 
570  SG_SDEBUG("all names\n")
571  for (set<string>::iterator it=names.begin(); it!=names.end(); ++it)
572  SG_SDEBUG("\"%s\"\n", (*it).c_str())
573 
574  /* only do stuff if there are names */
575  if (!names.empty())
576  {
577  /* next step, build temporary structure where all elements with first
578  * name are put. Elements of that structure will be extend iteratively
579  * per name */
580 
581 
582  /* extract all trees with first name */
583  const char* first_name=(*(names.begin())).c_str();
584  CDynamicObjectArray* trees=
586 
587  SG_SDEBUG("adding trees for first name \"%s\":\n", first_name)
588  for (index_t i=0; i<trees->get_num_elements(); ++i)
589  {
590  CParameterCombination* current_tree=
592 
593  CParameterCombination* current_root=new_root->copy_tree();
594  current_root->append_child(current_tree);
595  result->append_element(current_root);
596 
597  // current_tree->print_tree(1);
598  SG_UNREF(current_tree);
599  }
600  SG_UNREF(trees);
601 
602  /* now iterate over the remaining names and build products */
603  SG_SDEBUG("building products with remaining trees:\n")
604  set<string>::iterator it=names.begin();
605  for (++it; it!=names.end(); ++it)
606  {
607  SG_SDEBUG("processing \"%s\"\n", (*it).c_str())
608 
609  /* extract all trees with current name */
610  const char* current_name=(*it).c_str();
612  current_name);
613 
614  /* create new set of trees where each element is put once for each
615  * of the just generated trees */
616  CDynamicObjectArray* new_result=new CDynamicObjectArray();
617  for (index_t i=0; i<result->get_num_elements(); ++i)
618  {
619  for (index_t j=0; j<trees->get_num_elements(); ++j)
620  {
621  CParameterCombination* to_copy=
622  (CParameterCombination*)result->get_element(i);
623 
624  /* create a copy of current element */
625  CParameterCombination* new_element=to_copy->copy_tree();
626  SG_UNREF(to_copy);
627 
628  CParameterCombination* to_add=
630  new_element->append_child(to_add);
631  SG_UNREF(to_add);
632  new_result->append_element(new_element);
633  // SG_SDEBUG("added:\n")
634  // new_element->print_tree();
635  }
636  }
637 
638  /* clean up */
639  SG_UNREF(trees);
640 
641  /* replace result by new_result */
642  SG_UNREF(result);
643  result=new_result;
644  }
645  }
646 
647  SG_SDEBUG("leaving CParameterCombination::non_value_tree_multiplication()\n")
648  return result;
649 }
650 
652  const CDynamicObjectArray* sets, const char* desired_name)
653 {
655 
656  for (index_t j=0;
657  j<sets->get_num_elements(); ++j)
658  {
659  CDynamicObjectArray* current_set=
660  (CDynamicObjectArray*) sets->get_element(j);
661 
662  for (index_t k=0; k<current_set->get_num_elements(); ++k)
663  {
665  current_set->get_element(k);
666 
667  char* current_name=current_tree->m_param->get_parameter(0)->m_name;
668 
669  if (!strcmp(current_name, desired_name))
670  result->append_element(current_tree);
671 
672  SG_UNREF(current_tree);
673  }
674 
675  SG_UNREF(current_set);
676  }
677 
678  return result;
679 }
680 
682 {
684 
685  /* but build new Parameter instance */
686 
687  /* only call add_parameters() argument is non-null */
688  if (m_param)
689  {
690  copy->m_param=new Parameter();
691  copy->m_param->add_parameters(m_param);
692  } else
693  copy->m_param=NULL;
694 
695  /* recursively copy all children */
696  for (index_t i=0; i<m_child_nodes->get_num_elements(); ++i)
697  {
699  m_child_nodes->get_element(i);
700  copy->m_child_nodes->append_element(child->copy_tree());
701  SG_UNREF(child);
702  }
703 
704  return copy;
705 }
706 
708 {
709  apply_to_modsel_parameter(machine->m_model_selection_parameters);
710 }
711 
713  Parameter* parameter) const
714 {
715  /* case root node */
716  if (!m_param)
717  {
718  /* iterate over all children and recursively set parameters from
719  * their values to the current parameter input (its just handed one
720  * recursion level downwards) */
721  for (index_t i=0; i<m_child_nodes->get_num_elements(); ++i)
722  {
724  m_child_nodes->get_element(i);
725  child->apply_to_modsel_parameter(parameter);
726  SG_UNREF(child);
727  }
728  }
729  /* case parameter node */
730  else if (m_param)
731  {
732  /* set parameters */
733  parameter->set_from_parameters(m_param);
734 
735  /* does this node has sub parameters? */
736  if (has_children())
737  {
738  /* if a parameter node has children, it has to have ONE CSGObject as
739  * parameter */
740  if (m_param->get_num_parameters()>1 ||
741  m_param->get_parameter(0)->m_datatype.m_ptype!=PT_SGOBJECT)
742  {
743  SG_SERROR("invalid CParameterCombination node type, has children"
744  " and more than one parameter or is not a "
745  "CSGObject.\n");
746  }
747 
748  /* cast is now safe */
749  CSGObject* current_sgobject=
750  *((CSGObject**)(m_param->get_parameter(0)->m_parameter));
751 
752  /* iterate over all children and recursively set parameters from
753  * their values */
754  for (index_t i=0; i<m_child_nodes->get_num_elements(); ++i)
755  {
757  m_child_nodes->get_element(i);
759  current_sgobject->m_model_selection_parameters);
760  SG_UNREF(child);
761  }
762  }
763  }
764  else
765  SG_SERROR("CParameterCombination node has illegal type.\n")
766 }
767 
770 {
771  if (m_param)
772  {
773  for (index_t i=0; i<m_param->get_num_parameters(); i++)
774  {
775  TParameter* param=m_param->get_parameter(i);
776  TSGDataType type=param->m_datatype;
777 
778  if (type.m_ptype==PT_FLOAT64 || type.m_ptype==PT_FLOAT32 ||
779  type.m_ptype==PT_FLOATMAX)
780  {
781  if (type.m_ctype==CT_SGVECTOR || type.m_ctype==CT_VECTOR ||
782  type.m_ctype==CT_SGMATRIX || type.m_ctype==CT_MATRIX)
783  {
784  SGVector<float64_t> value(*((float64_t **)param->m_parameter),
785  type.get_num_elements(), false);
786  dict->add(param, value);
787  }
788  else if (type.m_ctype==CT_SCALAR)
789  {
790  SGVector<float64_t> value(1);
791  value.set_const(*((float64_t *)param->m_parameter));
792  dict->add(param, value);
793  }
794  }
795  }
796  }
797 
798  for (index_t i=0; i<m_child_nodes->get_num_elements(); i++)
799  {
801  m_child_nodes->get_element(i);
802  child->build_parameter_values_map(dict);
803  SG_UNREF(child);
804  }
805 }
806 
809 {
810  CSGObject* parent=NULL;
811 
812  if (m_param)
813  {
814  for (index_t i=0; i<m_param->get_num_parameters(); i++)
815  {
816  TParameter* param=m_param->get_parameter(i);
817  TSGDataType type=param->m_datatype;
818 
819  if (type.m_ptype==PT_SGOBJECT)
820  {
821  if (type.m_ctype==CT_SCALAR)
822  {
823  parent=(*(CSGObject**)param->m_parameter);
824  break;
825  }
826  else
827  {
829  }
830  }
831  }
832  }
833 
834  for (index_t i=0; i<m_child_nodes->get_num_elements(); i++)
835  {
837  m_child_nodes->get_element(i);
838 
839  for (index_t j=0; j<child->m_param->get_num_parameters(); j++)
840  {
841  TParameter* param=child->m_param->get_parameter(j);
842  TSGDataType type=param->m_datatype;
843 
844  if (type.m_ptype==PT_SGOBJECT)
845  {
846  if (type.m_ctype==CT_SCALAR)
847  {
848  child->build_parameter_parent_map(dict);
849  }
850  else
851  {
853  }
854  }
855  else
856  {
857  dict->add(param, parent);
858  }
859  }
860  SG_UNREF(child);
861  }
862 }
virtual const char * get_name() const =0
T get_element(int32_t index) const
Definition: DynArray.h:142
bool append_element(T element)
Definition: DynArray.h:244
int32_t index_t
Definition: common.h:62
virtual int32_t get_num_parameters()
void apply_to_modsel_parameter(Parameter *parameter) const
TParameter * get_parameter(const char *name, CSGObject *parent)
TParameter * get_parameter(int32_t idx)
index_t * m_length_x
Definition: DataType.h:80
parameter struct
#define SG_ERROR(...)
Definition: SGIO.h:129
#define SG_NOTIMPLEMENTED
Definition: SGIO.h:139
int64_t get_num_elements()
Definition: DataType.cpp:464
int32_t get_num_elements() const
Definition: DynArray.h:130
void print_tree(int prefix_num=0) const
CParameterCombination * copy_tree() const
#define SG_REF(x)
Definition: SGObject.h:51
bool set_element(CSGObject *e, int32_t idx1, int32_t idx2=0, int32_t idx3=0)
Datatypes that shogun supports.
Definition: DataType.h:68
A generic learning machine interface.
Definition: Machine.h:143
int32_t add(const K &key, const T &data)
Definition: Map.h:101
void add(bool *param, const char *name, const char *description="")
Definition: Parameter.cpp:37
TSGDataType m_datatype
#define SG_SPRINT(...)
Definition: SGIO.h:180
Parameter class.
CDynamicObjectArray * m_child_nodes
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:112
void merge_with(CParameterCombination *node)
Template Dynamic array class that creates an array that can be used like a list or an array...
Definition: DynArray.h:32
static CDynamicObjectArray * extract_trees_with_name(const CDynamicObjectArray *sets, const char *desired_name)
double float64_t
Definition: common.h:50
void append_child(CParameterCombination *child)
bool set_parameter_helper(const char *name, bool value, index_t index)
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
Class that holds ONE combination of parameters for a learning machine. The structure is organized as ...
Parameter * m_model_selection_parameters
Definition: SGObject.h:508
index_t * m_length_y
Definition: DataType.h:78
virtual void build_parameter_parent_map(CMap< TParameter *, CSGObject * > *parent_map)
void set_from_parameters(Parameter *params)
Definition: Parameter.cpp:2827
EContainerType m_ctype
Definition: DataType.h:71
#define SG_UNREF(x)
Definition: SGObject.h:52
void add_vector(bool **param, index_t *length, const char *name, const char *description="")
Definition: Parameter.cpp:334
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
#define SG_SDEBUG(...)
Definition: SGIO.h:168
#define SG_SERROR(...)
Definition: SGIO.h:179
TParameter * get_parameter_helper(const char *name)
void add_parameters(Parameter *params)
Definition: Parameter.cpp:2961
CSGObject * get_element(int32_t index) const
virtual void build_parameter_values_map(CMap< TParameter *, SGVector< float64_t > > *values_map)
EPrimitiveType m_ptype
Definition: DataType.h:75
#define SG_WARNING(...)
Definition: SGIO.h:128
#define SG_ADD(...)
Definition: SGObject.h:81
Parameter * m_gradient_parameters
Definition: SGObject.h:511
void apply_to_machine(CMachine *machine) const
static CDynamicObjectArray * non_value_tree_multiplication(const CDynamicObjectArray *sets, const CParameterCombination *new_root)
void add_matrix(bool **param, index_t *length_y, index_t *length_x, const char *name, const char *description="")
Definition: Parameter.cpp:943
static DynArray< Parameter * > * parameter_set_multiplication(const DynArray< Parameter * > &set_1, const DynArray< Parameter * > &set_2)
void set_const(T const_elem)
Definition: SGVector.cpp:152
void add(const SGVector< T > x)
Definition: SGVector.cpp:281
bool append_element(CSGObject *e)
the class CMap, a map based on the hash-table. w: http://en.wikipedia.org/wiki/Hash_table ...
Definition: SGObject.h:36
static CDynamicObjectArray * leaf_sets_multiplication(const CDynamicObjectArray &sets, const CParameterCombination *new_root)

SHOGUN Machine Learning Toolbox - Documentation