<commit_before>/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Written (W) 2012 <NAME>
 * Copyright (C) 2012 <NAME>
 */

#ifndef _LINEARMULTICLASSMACHINE_H___
#define _LINEARMULTICLASSMACHINE_H___

#include <shogun/lib/common.h>
#include <shogun/base/Parameter.h>
#include <shogun/features/DotFeatures.h>
#include <shogun/machine/LinearMachine.h>
#include <shogun/machine/MulticlassMachine.h>

namespace shogun
{

class Parameter;
class CDotFeatures;
class CLinearMachine;

/** @brief generic linear multiclass machine */
class CLinearMulticlassMachine : public CMulticlassMachine
{
	public:
		/** default constructor  */
		CLinearMulticlassMachine() : CMulticlassMachine(), m_features(NULL)
		{
			SG_ADD((CSGObject**)&m_features, "m_features", "Feature object.",
			    MS_NOT_AVAILABLE);
		}

		/** standard constructor
		 * @param strategy multiclass strategy
		 * @param features features
		 * @param machine linear machine
		 * @param labs labels
		 */
		CLinearMulticlassMachine(EMulticlassStrategy strategy, CDotFeatures* features, CLinearMachine* machine, CLabels* labs) :
			CMulticlassMachine(strategy,(CMachine*)machine,labs), m_features(NULL)
		{
			set_features(features);
			SG_ADD((CSGObject**)&m_features, "m_features", "Feature object.",
			    MS_NOT_AVAILABLE);
		}

		/** destructor */
		virtual ~CLinearMulticlassMachine()
		{
			SG_UNREF(m_features);
		}

		/** get name */
		virtual const char* get_name() const
		{
			return "LinearMulticlassMachine";
		}

		/** set features
		 *
		 * @param f features
		 */
		void set_features(CDotFeatures* f)
		{
			SG_REF(f);
			SG_UNREF(m_features);
			m_features = f;
		}

		/** get features
		 *
		 * @return kernel
		 */
		CDotFeatures* get_features() const
		{
			SG_REF(m_features);
			return m_features;
		}

	protected:

		/** init machine for train with setting features */
		virtual bool init_machine_for_train(CFeatures* data)
		{
			if (!m_machine)
				SG_ERROR("No machine given in Multiclass constructor\n");

			if (data)
				set_features((CDotFeatures*)data);

			((CLinearMachine*)m_machine)->set_features(m_features);

			return true;
		}

		/** init machines for applying with setting features */
		virtual bool init_machines_for_apply(CFeatures* data)
		{
			if (data)
				set_features((CDotFeatures*)data);

			for (int32_t i=0; i<m_machines.vlen; i++)
				((CLinearMachine*)m_machines[i])->set_features(m_features);

			return true;
		}

		/** check features availability */
		virtual bool is_ready()
		{
			if (m_features)
				return true;

			return false;
		}

		/** construct linear machine from given linear machine */
		virtual CMachine* get_machine_from_trained(CMachine* machine)
		{
			return new CLinearMachine((CLinearMachine*)machine);
		}

		/** get number of rhs feature vectors */
		virtual int32_t get_num_rhs_vectors()
		{
			return m_features->get_num_vectors();
		}

		/** set subset to the features of the machine, deletes old one
		 *
		 * @param subset subset instance to set
		 */
		virtual void set_machine_subset(CSubset* subset)
		{
			/* changing the subset structure to use subset stacks. This might
			 * have to be revised. <NAME> */
			SG_NOTIMPLEMENTED;
//			m_features->set_subset(subset);
		}

		/** deletes any subset set to the features of the machine */
		virtual void remove_machine_subset()
		{
			/* changing the subset structure to use subset stacks. This might
			 * have to be revised. <NAME> */
			SG_NOTIMPLEMENTED;
//			m_features->remove_subset();
		}

	protected:

		/** features */
		CDotFeatures* m_features;

};
}
#endif
<commit_msg>replaced SGNOTIMPLEMENTED by warning<commit_after>/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Written (W) 2012 <NAME>
 * Copyright (C) 2012 <NAME>
 */

#ifndef _LINEARMULTICLASSMACHINE_H___
#define _LINEARMULTICLASSMACHINE_H___

#include <shogun/lib/common.h>
#include <shogun/base/Parameter.h>
#include <shogun/features/DotFeatures.h>
#include <shogun/machine/LinearMachine.h>
#include <shogun/machine/MulticlassMachine.h>

namespace shogun
{

class Parameter;
class CDotFeatures;
class CLinearMachine;

/** @brief generic linear multiclass machine */
class CLinearMulticlassMachine : public CMulticlassMachine
{
	public:
		/** default constructor  */
		CLinearMulticlassMachine() : CMulticlassMachine(), m_features(NULL)
		{
			SG_ADD((CSGObject**)&m_features, "m_features", "Feature object.",
			    MS_NOT_AVAILABLE);
		}

		/** standard constructor
		 * @param strategy multiclass strategy
		 * @param features features
		 * @param machine linear machine
		 * @param labs labels
		 */
		CLinearMulticlassMachine(EMulticlassStrategy strategy, CDotFeatures* features, CLinearMachine* machine, CLabels* labs) :
			CMulticlassMachine(strategy,(CMachine*)machine,labs), m_features(NULL)
		{
			set_features(features);
			SG_ADD((CSGObject**)&m_features, "m_features", "Feature object.",
			    MS_NOT_AVAILABLE);
		}

		/** destructor */
		virtual ~CLinearMulticlassMachine()
		{
			SG_UNREF(m_features);
		}

		/** get name */
		virtual const char* get_name() const
		{
			return "LinearMulticlassMachine";
		}

		/** set features
		 *
		 * @param f features
		 */
		void set_features(CDotFeatures* f)
		{
			SG_REF(f);
			SG_UNREF(m_features);
			m_features = f;
		}

		/** get features
		 *
		 * @return kernel
		 */
		CDotFeatures* get_features() const
		{
			SG_REF(m_features);
			return m_features;
		}

	protected:

		/** init machine for train with setting features */
		virtual bool init_machine_for_train(CFeatures* data)
		{
			if (!m_machine)
				SG_ERROR("No machine given in Multiclass constructor\n");

			if (data)
				set_features((CDotFeatures*)data);

			((CLinearMachine*)m_machine)->set_features(m_features);

			return true;
		}

		/** init machines for applying with setting features */
		virtual bool init_machines_for_apply(CFeatures* data)
		{
			if (data)
				set_features((CDotFeatures*)data);

			for (int32_t i=0; i<m_machines.vlen; i++)
				((CLinearMachine*)m_machines[i])->set_features(m_features);

			return true;
		}

		/** check features availability */
		virtual bool is_ready()
		{
			if (m_features)
				return true;

			return false;
		}

		/** construct linear machine from given linear machine */
		virtual CMachine* get_machine_from_trained(CMachine* machine)
		{
			return new CLinearMachine((CLinearMachine*)machine);
		}

		/** get number of rhs feature vectors */
		virtual int32_t get_num_rhs_vectors()
		{
			return m_features->get_num_vectors();
		}

		/** set subset to the features of the machine, deletes old one
		 *
		 * @param subset subset instance to set
		 */
		virtual void set_machine_subset(CSubset* subset)
		{
			/* changing the subset structure to use subset stacks. This might
			 * have to be revised. <NAME> */
			SG_WARNING("FIXME");
			m_features->push_subset(subset);
		}

		/** deletes any subset set to the features of the machine */
		virtual void remove_machine_subset()
		{
			/* changing the subset structure to use subset stacks. This might
			 * have to be revised. <NAME> */
			SG_WARNING("FIXME");
			m_features->pop_subset();
		}

	protected:

		/** features */
		CDotFeatures* m_features;

};
}
#endif

{'fraction_non_alphanumeric': 0.10966126268617372, 'fraction_numerical': 0.003690523263477, 'mean_word_length': 3.80253164556962, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5821562', 'n_tokens_mistral': 2817, 'n_tokens_neox': 2389, 'n_words': 637}