SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LabelsFactory.cpp
Go to the documentation of this file.
00001 #include <shogun/labels/LabelsFactory.h>
00002 
00003 #include <shogun/labels/BinaryLabels.h>
00004 #include <shogun/labels/LatentLabels.h>
00005 #include <shogun/labels/MulticlassLabels.h>
00006 #include <shogun/labels/RegressionLabels.h>
00007 #include <shogun/labels/StructuredLabels.h>
00008 #include <shogun/labels/MulticlassMultipleOutputLabels.h>
00009 #include <shogun/structure/MulticlassSOLabels.h>
00010 
00011 using namespace shogun;
00012 
00013 CBinaryLabels* CLabelsFactory::to_binary(CLabels* base_labels)
00014 {
00015     ASSERT(base_labels != NULL)
00016     if (base_labels->get_label_type() == LT_BINARY)
00017         return static_cast<CBinaryLabels*>(base_labels);
00018     else
00019         SG_SERROR("base_labels must be of dynamic type CBinaryLabels")
00020 
00021     return NULL;
00022 }
00023 
00024 CLatentLabels* CLabelsFactory::to_latent(CLabels* base_labels)
00025 {
00026     ASSERT(base_labels != NULL)
00027     if (base_labels->get_label_type() == LT_LATENT)
00028         return static_cast<CLatentLabels*>(base_labels);
00029     else
00030         SG_SERROR("base_labels must be of dynamic type CLatentLabels\n")
00031 
00032     return NULL;
00033 }
00034 
00035 CMulticlassLabels* CLabelsFactory::to_multiclass(CLabels* base_labels)
00036 {
00037     ASSERT(base_labels != NULL)
00038     if (base_labels->get_label_type() == LT_MULTICLASS)
00039         return static_cast<CMulticlassLabels*>(base_labels);
00040     else
00041         SG_SERROR("base_labels must be of dynamic type CMulticlassLabels\n")
00042 
00043     return NULL;
00044 }
00045 
00046 CRegressionLabels* CLabelsFactory::to_regression(CLabels* base_labels)
00047 {
00048     ASSERT(base_labels != NULL)
00049     if (base_labels->get_label_type() == LT_REGRESSION)
00050         return static_cast<CRegressionLabels*>(base_labels);
00051     else
00052         SG_SERROR("base_labels must be of dynamic type CRegressionLabels")
00053 
00054     return NULL;
00055 }
00056 
00057 CStructuredLabels* CLabelsFactory::to_structured(CLabels* base_labels)
00058 {
00059     ASSERT(base_labels != NULL)
00060     if (base_labels->get_label_type() == LT_STRUCTURED)
00061         return static_cast<CStructuredLabels*>(base_labels);
00062     else
00063         SG_SERROR("base_labels must be of dynamic type CStructuredLabels\n")
00064 
00065     return NULL;
00066 }
00067 
00068 
00069 CMulticlassMultipleOutputLabels* CLabelsFactory::to_multiclass_multiple_output(CLabels* base_labels)
00070 {
00071     ASSERT(base_labels != NULL)
00072     if (base_labels->get_label_type() == LT_MULTICLASS_MULTIPLE_OUTPUT)
00073         return static_cast<CMulticlassMultipleOutputLabels*>(base_labels);
00074     else
00075         SG_SERROR("base_labels must be of dynamic type CMulticlassMultipleOutputLabels\n")
00076 
00077     return NULL;
00078 }
00079 
00080 CMulticlassSOLabels* CLabelsFactory::to_multiclass_structured(CLabels* base_labels)
00081 {
00082     ASSERT(base_labels != NULL)
00083     CMulticlassSOLabels* labels = dynamic_cast<CMulticlassSOLabels*>(base_labels);
00084     if (labels == NULL)
00085         SG_SERROR("base_labels must be of dynamic type CMulticlassMultipleOutputLabels\n")
00086 
00087     return labels;
00088 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation