|
@@ -0,0 +1,94 @@
|
|
|
|
+/**
|
|
|
|
+ * @file VectorFeature.h
|
|
|
|
+ * @brief feature class to use feature raw data stored in Examples
|
|
|
|
+ * @author Johannes Ruehle
|
|
|
|
+ * @date 04/11/2014
|
|
|
|
+
|
|
|
|
+ */
|
|
|
|
+#ifndef VectorFeatureINCLUDE
|
|
|
|
+#define VectorFeatureINCLUDE
|
|
|
|
+
|
|
|
|
+#include "vislearning/cbaselib/Feature.h"
|
|
|
|
+
|
|
|
|
+namespace OBJREC {
|
|
|
|
+
|
|
|
|
+class VectorFeature : public Feature
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ protected:
|
|
|
|
+ //! feature dimension
|
|
|
|
+ int dimension;
|
|
|
|
+
|
|
|
|
+ //! index of the feature
|
|
|
|
+ int feature_index;
|
|
|
|
+
|
|
|
|
+ public:
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * internally used by VectorFeature::explode
|
|
|
|
+ * @param _dimension new dimension
|
|
|
|
+ * @param _feature_index new featureindex
|
|
|
|
+ */
|
|
|
|
+ VectorFeature ( int _dimension, int _feature_index = 0 ):
|
|
|
|
+ dimension(_dimension), feature_index(_feature_index)
|
|
|
|
+ {}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * simple destructor
|
|
|
|
+ */
|
|
|
|
+ virtual ~VectorFeature();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * returns the value of the sparse feature stored in example
|
|
|
|
+ * @param example input example
|
|
|
|
+ * @return feature value
|
|
|
|
+ */
|
|
|
|
+ double val( const Example *example ) const;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * creates for each feature a own SparseVectorFeature in featurepool
|
|
|
|
+ * @param featurePool the feature pool
|
|
|
|
+ * @param variableWindow
|
|
|
|
+ */
|
|
|
|
+ void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Feature *clone() const;
|
|
|
|
+ Feature *generateFirstParameter () const;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * store the data
|
|
|
|
+ * @param is input stream
|
|
|
|
+ * @param format
|
|
|
|
+ */
|
|
|
|
+ void restore (std::istream & is, int format = 0);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * read the data
|
|
|
|
+ * @param os
|
|
|
|
+ * @param format
|
|
|
|
+ */
|
|
|
|
+ void store (std::ostream & os, int format = 0) const;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * does nothing
|
|
|
|
+ */
|
|
|
|
+ void clear ();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * returns the feature index and the dimension
|
|
|
|
+ * @param feature_index
|
|
|
|
+ * @param dimension
|
|
|
|
+ */
|
|
|
|
+ void getStump ( int & feature_index, int & dimension ) const;
|
|
|
|
+
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+} // namespace
|
|
|
|
+
|
|
|
|
+#endif
|