19 using namespace shogun;
51 use_bias = mch->use_bias;
69 void COnlineLibLinear::init()
87 diag[0]=0;diag[1]=0;diag[2]=0;
88 upper_bound[0]=Cn;upper_bound[1]=0;upper_bound[2]=Cp;
116 diag[0]=0;diag[1]=0;diag[2]=0;
117 upper_bound[0]=Cn;upper_bound[1]=0;upper_bound[2]=Cp;
128 SG_INFO(
"Optimization finished.\n")
131 for (int32_t i=0; i<
w_dim; i++)
135 SG_INFO(
"Objective value = %lf\n", v/2)
143 int32_t y_current = 0;
149 QD = diag[y_current + 1];
161 C = upper_bound[y_current + 1];
162 G += alpha_current*diag[y_current + 1];
165 if (alpha_current == 0)
174 else if (alpha_current == C)
189 if (fabs(PG) > 1.0e-12)
193 d = (alpha_current - alpha_old) * y_current;
195 for (int32_t i=0; i <
w_dim; ++i)
203 v += alpha_current*(alpha_current*diag[y_current + 1] - 2);
204 if (alpha_current > 0)
211 int32_t y_current = 0;
217 QD = diag[y_current + 1];
229 C = upper_bound[y_current + 1];
230 G += alpha_current*diag[y_current + 1];
233 if (alpha_current == 0)
242 else if (alpha_current == C)
257 if (fabs(PG) > 1.0e-12)
261 d = (alpha_current - alpha_old) * y_current;
271 v += alpha_current*(alpha_current*diag[y_current + 1] - 2);
272 if (alpha_current > 0)
284 SG_ERROR(
"Expected streaming dense feature <float32_t>\n")
292 SG_ERROR(
"Expected streaming sparse feature <float32_t>\n")
static float64_t dot(const bool *v1, const bool *v2, int32_t n)
compute dot product between v1 and v2 (blas optimized)
Class OnlineLinearMachine is a generic interface for linear machines like classifiers which work thro...
static const float64_t INFTY
infinity
SGVector< T > get_vector()
#define SG_NOTIMPLEMENTED
T sparse_dot(const SGSparseVector< T > &v)
SGSparseVector< T > get_vector()
virtual void train_one(SGVector< float32_t > ex, float64_t label)
virtual void stop_train()
virtual void set_features(CStreamingDotFeatures *feat)
virtual void train_example(CStreamingDotFeatures *feature, float64_t label)
template class SGSparseVector The assumtion is that the stored SGSparseVectorEntry* vector is orde...
void add(bool *param, const char *name, const char *description="")
virtual ~COnlineLibLinear()
virtual void expand_if_required(float32_t *&vec, int32_t &len)
virtual EFeatureClass get_feature_class() const =0
static T max(T a, T b)
return the maximum of two integers
Streaming features that support dot products among other operations.
T dense_dot(T alpha, T *vec, int32_t dim, T b)
Class implementing a purely online version of CLibLinear, using the L2R_L1LOSS_SVC_DUAL solver only...
CStreamingDotFeatures * features
static T min(T a, T b)
return the minimum of two integers
This class implements streaming features with sparse feature vectors. The vector is represented as an...
virtual void start_train()
SGSparseVectorEntry< T > * features