Skip to content

Instantly share code, notes, and snippets.

@pluskid
Created April 25, 2012 13:51
Show Gist options
  • Save pluskid/2489859 to your computer and use it in GitHub Desktop.
Save pluskid/2489859 to your computer and use it in GitHub Desktop.
experimental shogun labels design
template <typename LabelType, LabelStoreType>
class CLabels: public CSGObject
{
public:
virtual int32_t get_num_classes() const = 0;
virtual const LabelType& get_label(int32_t index) const
{
check_out_of_range(index);
return cast_label(m_labels[index]);
}
protected:
virtual const LabelType& cast_label(const LabelStoreType& label)=0;
SGVector<LabelStoreType> m_labels;
};
class CBinaryLabels: public CLabels<bool, float64_t>
{
public:
virtual int32_t get_num_classes() const { return 2; }
protected:
virtual const bool& cast_label(const float64_t& label) { return label > 0; }
};
class CRealLabels: public CLabels<float64_t, float64_t>
{
public:
virtual int32_t get_num_classes() const { return inf; }
protected:
virtual const float64_t& cast_label(const float64_t label) { return label; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment