<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 _LOSS_H__
#define _LOSS_H__

#include <shogun/base/SGObject.h>
#include <shogun/features/Features.h>
#include <shogun/features/StructuredLabels.h>
#include <shogun/lib/SGVector.h>
#include <shogun/lib/StructuredData.h>

namespace shogun {

class CStructuredLoss;

/**
 * @brief Abstract class StructuredLoss that represents the application
 * independent loss \f$l(x,y,w)\f$  used in structured output (SO) problems. 
 * This type of loss function must be used since the applicacion dependent 
 * \f$Delta\f$ loss defined in a StructuredModel class may be non convex or 
 * discontinuous w.r.t. \f$w\f$. This class is thought to be used as the 
 * interface for the family of \f$l\f$ functions that contains e.g. hinge loss.
 */
class CStructuredLoss : public CSGObject
{
	public:
		/** default constructor */
		CStructuredLoss();

		/** destructor */
		~CStructuredLoss();

		/** abstract method to compute the loss
		 *
		 * @param z where to evaluate the function
		 * @return the loss
		 */
		virtual float64_t compute(float64_t z) = 0;

		/** abstract method the first gradient of the loss
		 *
		 * @param z where to evaluate the gradient of the function
		 * @return the gradient (first derivative) of the loss
		 */

		virtual float64_t compute_gradient(float64_t) = 0;

		/** abstract method the second gradient of the loss
		 *
		 * @param z where to evaluate the subgradient of the function
		 * @return the subgradient (second derivative or Hessian) of the 
		 *		loss
		 */
		virtual float64_t compute_subgradient(float64_t z) = 0;

		/** is smooth? 
		 *
		 * @return is_smooth whether the loss function is smooth
		 */
		inline bool is_smooth() { return m_is_smooth; }

		/** is convex?
		 *
		 * @return is_convex whether the loss function is convex
		 */
		inline bool is_convex() { return m_is_convex; }

		/** is positive?
		 *
		 * @return is_positive whether the loss function is positive
		 */
		inline bool is_positive() { return m_is_positive; }

		/** @return name of SGSerializable */
		inline virtual const char* get_name() const 
			{ return "StructuredLoss"; }
			
	protected:
		/** whether the loss function is smooth */
		bool m_is_smooth;

		/** whether the loss function is convex */
		bool m_is_convex;

		/** whether the loss function is positive, 
		 *  i.e. \f$ l: (\mathcal{X, Y}, \Re^{n}) \to \Re^{+}? \f$ 
		 */
		bool m_is_positive;

}; /* class CStructuredLoss */

} /* namespace shogun */

#endif /* _LOSS_H__ */<commit_msg>~ naming in macros StructuredLoss<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 _STRUCTURED_LOSS_H__
#define _STRUCTURED_LOSS_H__

#include <shogun/base/SGObject.h>
#include <shogun/features/Features.h>
#include <shogun/features/StructuredLabels.h>
#include <shogun/lib/SGVector.h>
#include <shogun/lib/StructuredData.h>

namespace shogun {

class CStructuredLoss;

/**
 * @brief Abstract class StructuredLoss that represents the application
 * independent loss \f$l(x,y,w)\f$  used in structured output (SO) problems. 
 * This type of loss function must be used since the applicacion dependent 
 * \f$Delta\f$ loss defined in a StructuredModel class may be non convex or 
 * discontinuous w.r.t. \f$w\f$. This class is thought to be used as the 
 * interface for the family of \f$l\f$ functions that contains e.g. hinge loss.
 */
class CStructuredLoss : public CSGObject
{
	public:
		/** default constructor */
		CStructuredLoss();

		/** destructor */
		~CStructuredLoss();

		/** abstract method to compute the loss
		 *
		 * @param z where to evaluate the function
		 * @return the loss
		 */
		virtual float64_t compute(float64_t z) = 0;

		/** abstract method the first gradient of the loss
		 *
		 * @param z where to evaluate the gradient of the function
		 * @return the gradient (first derivative) of the loss
		 */

		virtual float64_t compute_gradient(float64_t) = 0;

		/** abstract method the second gradient of the loss
		 *
		 * @param z where to evaluate the subgradient of the function
		 * @return the subgradient (second derivative or Hessian) of the 
		 *		loss
		 */
		virtual float64_t compute_subgradient(float64_t z) = 0;

		/** is smooth? 
		 *
		 * @return is_smooth whether the loss function is smooth
		 */
		inline bool is_smooth() { return m_is_smooth; }

		/** is convex?
		 *
		 * @return is_convex whether the loss function is convex
		 */
		inline bool is_convex() { return m_is_convex; }

		/** is positive?
		 *
		 * @return is_positive whether the loss function is positive
		 */
		inline bool is_positive() { return m_is_positive; }

		/** @return name of SGSerializable */
		inline virtual const char* get_name() const 
			{ return "StructuredLoss"; }
			
	protected:
		/** whether the loss function is smooth */
		bool m_is_smooth;

		/** whether the loss function is convex */
		bool m_is_convex;

		/** whether the loss function is positive, 
		 *  i.e. \f$ l: (\mathcal{X, Y}, \Re^{n}) \to \Re^{+}? \f$ 
		 */
		bool m_is_positive;

}; /* class CStructuredLoss */

} /* namespace shogun */

#endif /* _STRUCTURED_LOSS_H__ */
{'fraction_non_alphanumeric': 0.10245106683124669, 'fraction_numerical': 0.008464115676247575, 'mean_word_length': 3.3330786860198627, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '6026413', 'n_tokens_mistral': 1990, 'n_tokens_neox': 1703, 'n_words': 652}