Explorar o código

*** empty log message ***

froehlich %!s(int64=15) %!d(string=hai) anos
pai
achega
3461f3e7d2
Modificáronse 4 ficheiros con 273 adicións e 0 borrados
  1. 86 0
      classifier/FPCnone.cpp
  2. 83 0
      classifier/FPCnone.h
  3. 103 0
      classifier/Makefile.inc
  4. 1 0
      classifier/libdepend.inc

+ 86 - 0
classifier/FPCnone.cpp

@@ -0,0 +1,86 @@
+#include "objrec-froehlichexp/classifier/FPCnone.h"
+
+#include <iostream>
+
+using namespace OBJREC;
+using namespace std;
+using namespace NICE;
+
+FPCnone::FPCnone ()
+{
+}
+
+FPCnone::FPCnone( const Config *_conf, string section )
+{
+	conf = _conf;
+}
+
+FPCnone::~FPCnone()
+{
+	//clean up
+}
+
+ClassificationResult FPCnone::classify ( Example & pce )
+{
+	FullVector overall_distribution(maxClassNo+1);
+	overall_distribution[maxClassNo] = 0.0;
+
+	double maxp = -numeric_limits<double>::max();
+	int classno = 0;
+	
+	double sum  = 0.0;
+		
+	for(int i = 0; i < maxClassNo; i++)
+	{
+		overall_distribution[i] = (*pce.vec)[i];
+		
+		sum += overall_distribution[i];
+
+		if(maxp < overall_distribution[i])
+		{
+			classno = i;
+			maxp = overall_distribution[i];
+		}
+	}
+
+	/*for(int i = 0; i < maxClassNo; i++)
+	{
+		overall_distribution[i] /= sum;
+	}*/
+	
+	cout << "Klasse: " << classno << " prob: " << overall_distribution[classno] << endl;
+
+	return ClassificationResult ( classno, overall_distribution );
+}
+
+void FPCnone::train ( FeaturePool & _fp, Examples & examples )
+{
+	fp = FeaturePool(_fp);
+}
+
+
+void FPCnone::restore (istream & is, int format)
+{
+}
+
+void FPCnone::store (ostream & os, int format) const
+{
+}
+
+void FPCnone::clear ()
+{
+}
+
+FeaturePoolClassifier *FPCnone::clone () const
+{
+	FPCnone *o = new FPCnone ( conf, "non" );
+
+	o->maxClassNo = maxClassNo;
+
+	return o;
+}
+
+void FPCnone::setComplexity ( int size )
+{
+	cerr << "FPCnone: no complexity to set" << endl;
+}

+ 83 - 0
classifier/FPCnone.h

@@ -0,0 +1,83 @@
+/** 
+ * @file FPCnone.h
+ * @brief bad hack, not realy a classifier, returns the first values as classification result
+ * @author Björn Fröhlich
+ * @date 18/06/2010
+
+ */
+#ifndef FPCnoneDEF
+#define FPCnoneDEF
+
+#include <objrec/nice.h>
+
+#include "objrec/classifier/classifierbase/FeaturePoolClassifier.h"
+#include "objrec/classifier/fpclassifier/logisticregression/SLR.h"
+#include "objrec/cbaselib/FeaturePool.h"
+#include "objrec/math/algebra/GMSparse2.h"
+
+namespace OBJREC {
+
+class FPCnone : public FeaturePoolClassifier
+{
+    protected:
+	
+	//! the featurepool
+	FeaturePool fp;
+		
+	//! config file;
+	const Config *conf;
+	
+    public:
+	/**
+	 * standard constructor
+	 * @param conf configfile
+	 * @param section section name in configfile for classifier
+	 */
+	FPCnone( const Config *conf, std::string section="SMLR");
+      
+	
+	/**
+	 * simple constructor -> does nothing
+	 */
+	FPCnone ();
+
+	/**
+	 * simple destructor
+	 */
+	~FPCnone();
+
+	/**
+	 * main classification function
+	 * @param pce input feature
+	 * @return a classification result
+	 */
+	ClassificationResult classify ( Example & pce );
+
+	/**
+	 * start training
+	 * @param fp a featurepool (how to handle which features...)
+	 * @param examples input features
+	 */
+	void train ( FeaturePool & _fp, Examples & examples );
+
+	/**
+	 * clone this object
+	 * @return a copy of this object
+	 */
+	FeaturePoolClassifier *clone () const;
+
+	/**
+	 * set complexity for the next training process e.g. number of weak classifiers
+	 * @param size new complexity
+	 */
+	void setComplexity ( int size );
+
+	/** IO functions */
+	void restore (istream & is, int format = 0);
+	void store (ostream & os, int format = 0) const;
+	void clear ();
+};
+
+} // namespace
+
+#endif

+ 103 - 0
classifier/Makefile.inc

@@ -0,0 +1,103 @@
+# LIBRARY-DIRECTORY-MAKEFILE
+# conventions:
+# - all subdirectories containing a "Makefile.inc" are considered sublibraries
+#   exception: "progs/" and "tests/" subdirectories!
+# - all ".C", ".cpp" and ".c" files in the current directory are linked to a
+#   library
+# - the library depends on all sublibraries 
+# - the library name is created with $(LIBNAME), i.e. it will be somehow
+#   related to the directory name and with the extension .a
+#   (e.g. lib1/sublib -> lib1_sublib.a)
+# - the library will be added to the default build list ALL_LIBRARIES
+
+# --------------------------------
+# - remember the last subdirectory
+#
+# set the variable $(SUBDIR) correctly to the current subdirectory. this
+# variable can be used throughout the current makefile.inc. The many 
+# SUBDIR_before, _add, and everything are only required so that we can recover
+# the previous content of SUBDIR before exitting the makefile.inc
+
+SUBDIR_add:=$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
+SUBDIR_before:=$(SUBDIR)
+SUBDIR:=$(strip $(SUBDIR_add))
+SUBDIR_before_$(SUBDIR):=$(SUBDIR_before)
+ifeq "$(SUBDIR)" "./"
+SUBDIR:=
+endif
+
+# ------------------------
+# - include subdirectories
+#
+# note the variables $(SUBDIRS_OF_$(SUBDIR)) are required later on to recover
+# the dependencies automatically. if you handle dependencies on your own, you
+# can also dump the $(SUBDIRS_OF_$(SUBDIR)) variable, and include the
+# makefile.inc of the subdirectories on your own...
+
+SUBDIRS_OF_$(SUBDIR):=$(patsubst %/Makefile.inc,%,$(wildcard $(SUBDIR)*/Makefile.inc))
+include $(SUBDIRS_OF_$(SUBDIR):%=%/Makefile.inc)
+
+# ----------------------------
+# - include local dependencies
+#
+# you can specify libraries needed by the individual objects or by the whole
+# directory. the object specific additional libraries are only considered
+# when compiling the specific object files
+# TODO: update documentation...
+
+-include $(SUBDIR)libdepend.inc
+
+$(foreach d,$(filter-out %progs %tests,$(SUBDIRS_OF_$(SUBDIR))),$(eval $(call PKG_DEPEND_INT,$(d))))
+
+# ---------------------------
+# - objects in this directory
+#
+# the use of the variable $(OBJS) is not mandatory. it is mandatory however
+# to update $(ALL_OBJS) in a way that it contains the path and name of
+# all objects. otherwise we can not include the appropriate .d files.
+
+OBJS:=$(patsubst %.cpp,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.cpp))) \
+      $(patsubst %.C,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.C))) \
+	  $(shell grep -ls Q_OBJECT $(SUBDIR)*.h | sed -e's@^@/@;s@.*/@$(OBJDIR)moc_@;s@\.h$$@.o@') \
+      $(patsubst %.c,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.c)))
+ALL_OBJS += $(OBJS)
+
+# ----------------------------
+# - binaries in this directory
+#
+# output of binaries in this directory. none of the variables has to be used.
+# but everything you add to $(ALL_LIBRARIES) and $(ALL_BINARIES) will be
+# compiled with `make all`. be sure again to add the files with full path.
+
+LIBRARY_BASENAME:=$(call LIBNAME,$(SUBDIR))
+ifneq "$(SUBDIR)" ""
+ALL_LIBRARIES+=$(LIBDIR)$(LIBRARY_BASENAME).$(LINK_FILE_EXTENSION)
+endif
+
+# ---------------------
+# - binary dependencies
+#
+# there is no way of determining the binary dependencies automatically, so we
+# follow conventions. the current library depends on all sublibraries.
+# all other dependencies have to be added manually by specifying, that the
+# current .pc file depends on some other .pc file. binaries depending on
+# libraries should exclusivelly use the .pc files as well.
+
+ifeq "$(SKIP_BUILD_$(OBJDIR))" "1"
+$(LIBDIR)$(LIBRARY_BASENAME).a:
+else
+$(LIBDIR)$(LIBRARY_BASENAME).a:$(OBJS) \
+	$(call PRINT_INTLIB_DEPS,$(PKGDIR)$(LIBRARY_BASENAME).a,.$(LINK_FILE_EXTENSION))
+endif
+
+$(PKGDIR)$(LIBRARY_BASENAME).pc: \
+	$(call PRINT_INTLIB_DEPS,$(PKGDIR)$(LIBRARY_BASENAME).pc,.pc)
+
+# -------------------
+# - subdir management
+#
+# as the last step, always add this line to correctly recover the subdirectory
+# of the makefile including this one!
+
+SUBDIR:=$(SUBDIR_before_$(SUBDIR))
+

+ 1 - 0
classifier/libdepend.inc

@@ -0,0 +1 @@
+$(call PKG_DEPEND_INT,objrec/classifier)