This file is indexed.

/usr/include/shogun/classifier/PluginEstimate.h is in libshogun-dev 1.1.0-4ubuntu2.

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
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*
 * 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) 1999-2009 Soeren Sonnenburg
 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
 */

#ifndef _PLUGINESTIMATE_H___
#define _PLUGINESTIMATE_H___

#include <shogun/machine/Machine.h>
#include <shogun/features/StringFeatures.h>
#include <shogun/features/Labels.h>
#include <shogun/distributions/LinearHMM.h>

namespace shogun
{
/** @brief class PluginEstimate
 *
 * The class PluginEstimate takes as input two probabilistic models (of type
 * CLinearHMM, even though general models are possible ) and classifies
 * examples according to the rule
 *
 * \f[
 * f({\bf x})= \log(\mbox{Pr}({\bf x}|\theta_+)) - \log(\mbox{Pr}({\bf x}|\theta_-))
 * \f]
 *
 * \sa CLinearHMM
 * \sa CDistribution
 * */
class CPluginEstimate: public CMachine
{
	public:
		/** default constructor
		 * @param pos_pseudo pseudo for positive model
		 * @param neg_pseudo pseudo for negative model
		 */
		CPluginEstimate(float64_t pos_pseudo=1e-10, float64_t neg_pseudo=1e-10);
		virtual ~CPluginEstimate();

		/** classify objects using the currently set features
		 *
		 * @return classified labels
		 */
		CLabels* apply();

		/** classify objects
		 *
		 * @param data (test)data to be classified
		 * @return classified labels
		 */
		virtual CLabels* apply(CFeatures* data);

		/** set features
		 *
		 * @param feat features to set
		 */
		virtual inline void set_features(CStringFeatures<uint16_t>* feat)
		{
			SG_UNREF(features);
			SG_REF(feat);
			features=feat;
		}

		/** get features
		 *
		 * @return features
		 */
		virtual CStringFeatures<uint16_t>* get_features() { SG_REF(features); return features; }

		/// classify the test feature vector indexed by vec_idx
		float64_t apply(int32_t vec_idx);

		/** obsolete posterior log odds
		 *
		 * @param vector vector
		 * @param len len
		 * @return something floaty
		 */
		inline float64_t posterior_log_odds_obsolete(
			uint16_t* vector, int32_t len)
		{
			return pos_model->get_log_likelihood_example(vector, len) - neg_model->get_log_likelihood_example(vector, len);
		}

		/** get log odds parameter-wise
		 *
		 * @param obs observation
		 * @param position position
		 * @return log odd at position
		 */
		inline float64_t get_parameterwise_log_odds(
			uint16_t obs, int32_t position)
		{
			return pos_model->get_positional_log_parameter(obs, position) - neg_model->get_positional_log_parameter(obs, position);
		}

		/** get obsolete positive log derivative
		 *
		 * @param obs observation
		 * @param pos position
		 * @return positive log derivative
		 */
		inline float64_t log_derivative_pos_obsolete(uint16_t obs, int32_t pos)
		{
			return pos_model->get_log_derivative_obsolete(obs, pos);
		}

		/** get obsolete negative log derivative
		 *
		 * @param obs observation
		 * @param pos position
		 * @return negative log derivative
		 */
		inline float64_t log_derivative_neg_obsolete(uint16_t obs, int32_t pos)
		{
			return neg_model->get_log_derivative_obsolete(obs, pos);
		}

		/** get model parameters
		 *
		 * @param pos_params parameters of positive model
		 * @param neg_params parameters of negative model
		 * @param seq_length sequence length
		 * @param num_symbols numbe of symbols
		 * @return if operation was successful
		 */
		inline bool get_model_params(
			float64_t*& pos_params, float64_t*& neg_params,
			int32_t &seq_length, int32_t &num_symbols)
		{
			if ((!pos_model) || (!neg_model))
			{
				SG_ERROR( "no model available\n");
				return false;
			}

			SGVector<float64_t> log_pos_trans = pos_model->get_log_transition_probs();
			pos_params = log_pos_trans.vector;
			SGVector<float64_t> log_neg_trans = neg_model->get_log_transition_probs();
			neg_params = log_neg_trans.vector;

			seq_length = pos_model->get_sequence_length();
			num_symbols = pos_model->get_num_symbols();
			ASSERT(pos_model->get_num_model_parameters()==neg_model->get_num_model_parameters());
			ASSERT(pos_model->get_num_symbols()==neg_model->get_num_symbols());
			return true;
		}

		/** set model parameters
		 * @param pos_params parameters of positive model
		 * @param neg_params parameters of negative model
		 * @param seq_length sequence length
		 * @param num_symbols numbe of symbols
		 */
		inline void set_model_params(
			float64_t* pos_params, float64_t* neg_params,
			int32_t seq_length, int32_t num_symbols)
		{
			int32_t num_params;

			SG_UNREF(pos_model);
			pos_model=new CLinearHMM(seq_length, num_symbols);
			SG_REF(pos_model);


			SG_UNREF(neg_model);
			neg_model=new CLinearHMM(seq_length, num_symbols);
			SG_REF(neg_model);

			num_params=pos_model->get_num_model_parameters();
			ASSERT(seq_length*num_symbols==num_params);
			ASSERT(num_params==neg_model->get_num_model_parameters());

			pos_model->set_log_transition_probs(SGVector<float64_t>(pos_params, num_params));
			neg_model->set_log_transition_probs(SGVector<float64_t>(neg_params, num_params));
		}

		/** get number of parameters
		 *
		 * @return number of parameters
		 */
		inline int32_t get_num_params()
		{
			return pos_model->get_num_model_parameters()+neg_model->get_num_model_parameters();
		}
		
		/** check models
		 *
		 * @return if one of the two models is invalid
		 */
		inline bool check_models()
		{
			return ( (pos_model!=NULL) && (neg_model!=NULL) );
		}

		/** @return object name */
		inline virtual const char* get_name() const { return "PluginEstimate"; }

	protected:
		/** train plugin estimate classifier
		 *
		 * @param data training data (parameter can be avoided if distance or
		 * kernel-based classifiers are used and distance/kernels are
		 * initialized with train data)
		 *
		 * @return whether training was successful
		 */
		virtual bool train_machine(CFeatures* data=NULL);

	protected:
		/** pseudo count for positive class */
		float64_t m_pos_pseudo;
		/** pseudo count for negative class */
		float64_t m_neg_pseudo;

		/** positive model */
		CLinearHMM* pos_model;
		/** negative model */
		CLinearHMM* neg_model;

		/** features */
		CStringFeatures<uint16_t>* features;
};
}
#endif