Skip to content

Commit

Permalink
Fix SWIG error of not recognizing class hierarchy.
Browse files Browse the repository at this point in the history
  • Loading branch information
pluskid committed Apr 29, 2012
1 parent 48ac9a1 commit 1cac205
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Expand Up @@ -23,12 +23,18 @@ def classifier_multiclasslinearmachine_modular (fm_train_real=traindat,fm_test_r

mc_classifier = LinearMulticlassMachine(MulticlassOneVsRestStrategy(), feats_train, classifier, labels)
mc_classifier.train()
out_mc = mc_classifier.apply().get_labels()
out_mc = mc_classifier.apply(feats_test).get_labels()

ecoc_strategy = ECOCStrategy(ECOCOVREncoder(), ECOCHDDecoder())
ecoc_classifier = LinearMulticlassMachine(ecoc_strategy, feats_train, classifier, labels)
ecoc_classifier.train()
out_ecoc = ecoc_classifier.apply().get_labels()
out_ecoc = ecoc_classifier.apply(feats_test).get_labels()

n_diff = (out_mc != out_ecoc).sum()
if n_diff == 0:
print("Same results for OvR and ECOCOvR")
else:
print("Different results for OvR and ECOCOvR (%d out of %d are different)" % (n_diff, len(out_mc)))

return out_ecoc, out_mc

Expand Down
4 changes: 4 additions & 0 deletions src/shogun/multiclass/ecoc/ECOCStrategy.h
Expand Up @@ -18,6 +18,10 @@
namespace shogun
{

// those two lines are put here to help SWIG
class CECOCEncoder;
class CECOCDecoder;

class CECOCStrategy: public CMulticlassStrategy
{
public:
Expand Down

0 comments on commit 1cac205

Please sign in to comment.