19 using namespace shogun;
51 use_bias = mch->use_bias;
69 void COnlineLibLinear::init()
93 diag[0]=0;diag[1]=0;diag[2]=0;
94 upper_bound[0]=Cn;upper_bound[1]=0;upper_bound[2]=Cp;
110 SG_INFO(
"Optimization finished.\n")
113 for (int32_t i=0; i<
w_dim; i++)
117 SG_INFO(
"Objective value = %lf\n", v/2)
130 QD = diag[y_current + 1];
142 C = upper_bound[y_current + 1];
143 G += alpha_current*diag[y_current + 1];
146 if (alpha_current == 0)
155 else if (alpha_current == C)
170 if (fabs(PG) > 1.0e-12)
174 d = (alpha_current - alpha_old) * y_current;
176 for (int32_t i=0; i <
w_dim; ++i)
184 v += alpha_current*(alpha_current*diag[y_current + 1] - 2);
185 if (alpha_current > 0)
197 QD = diag[y_current + 1];
209 C = upper_bound[y_current + 1];
210 G += alpha_current*diag[y_current + 1];
213 if (alpha_current == 0)
222 else if (alpha_current == C)
237 if (fabs(PG) > 1.0e-12)
241 d = (alpha_current - alpha_old) * y_current;
251 v += alpha_current*(alpha_current*diag[y_current + 1] - 2);
252 if (alpha_current > 0)
264 SG_ERROR(
"Expected streaming dense feature <float32_t>\n")
272 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<T>* 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 LibLinear, 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