/usr/include/shogun/multiclass/ecoc/ECOCRandomDenseEncoder.h is in libshogun-dev 3.2.0-7.3build4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | /*
* 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 Chiyuan Zhang
* Copyright (C) 2012 Chiyuan Zhang
*/
#ifndef ECOCRANDOMDENSEENCODER_H__
#define ECOCRANDOMDENSEENCODER_H__
#include <shogun/multiclass/ecoc/ECOCEncoder.h>
namespace shogun
{
/** Generate random ECOC codebook containing +1 and -1, and
* select the best one.
*/
class CECOCRandomDenseEncoder: public CECOCEncoder
{
public:
/** constructor
* @param maxiter max number of iterations
* @param codelen code length, if set to zero, will be computed automatically via get_default_code_length
* @param pposone probability of +1
*
* @see get_default_code_length
*/
CECOCRandomDenseEncoder(int32_t maxiter=10000, int32_t codelen=0, float64_t pposone=0.5);
/** destructor */
virtual ~CECOCRandomDenseEncoder() {}
/** set probability
* @param pposone probability of +1
*/
void set_probability(float64_t pposone);
/** get name */
virtual const char* get_name() const { return "ECOCRandomDenseEncoder"; }
/** init codebook.
* @param num_classes number of classes in this problem
*/
virtual SGMatrix<int32_t> create_codebook(int32_t num_classes);
/** get default code length
* @param num_classes number of classes
*
* In Dense Random Coding, 10 * log(num_classes) is suggested as code length.
* See
*
* E. Allwein, R. Schapire, and Y. Singer. Reducing multiclass to binary: A unifying approach
* for margin classifiers. Journal of Machine Learning Research, 1:113-141, 2002.
*/
int32_t get_default_code_length(int32_t num_classes) const
{
return static_cast<int32_t>(CMath::round(10 * CMath::log(num_classes)));
}
protected:
int32_t m_maxiter; ///< max number of iterations
int32_t m_codelen; ///< code length
float64_t m_pposone; ///< probability of +1
private:
/** ensure probability sum to one
* @param pposone probability of +1
*/
bool check_probability(float64_t pposone)
{
if (pposone >= 0.999 || pposone <= 0.0001)
return false;
return true;
}
/** init parameters */
void init();
};
} // namespace shogun
#endif /* end of include guard: ECOCRANDOMDENSEENCODER_H__ */
|