28 using namespace shogun;
77 SG_ERROR(
"Specified features are not of type CDotFeatures\n");
88 ASSERT(num_vec==num_train_labels);
104 t = 1 / (eta0 * lambda);
106 SG_INFO(
"lambda=%f, epochs=%d, eta0=%f\n", lambda, epochs, eta0);
112 SG_INFO(
"Training on %d vectors\n", num_vec);
116 bool is_log_loss =
false;
123 for (int32_t i=0; i<num_vec; i++)
129 if (z < 1 || is_log_loss)
136 if (use_regularized_bias)
137 bias *= 1 - eta * lambda * bscale;
138 bias += etd * y * bscale;
146 r = pow(1 - eta * lambda, skip);
172 SG_INFO(
"Estimating sparsity and bscale num_vec=%d num_feat=%d.\n", num_vec, c_dim);
179 for (int32_t j=0; j<num_vec && m<=1000; j++, n++)
193 skip = (int32_t) ((16 * n * c_dim) / r);
194 SG_INFO(
"using %d examples. skip=%d bscale=%.6f\n", n, skip, bscale);
211 use_regularized_bias=
false;
223 m_parameters->
add(&use_bias,
"use_bias",
"Indicates if bias is used.");
224 m_parameters->
add(&use_regularized_bias,
"use_regularized_bias",
"Indicates if bias is regularized.");
bool has_property(EFeatureProperty p)
virtual int32_t get_nnz_features_for_vector(int32_t num)=0
Class CLossFunction is the base class of all loss functions.
The class Labels models labels, i.e. class assignments of objects.
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)=0
virtual float64_t first_derivative(float64_t prediction, float64_t label)=0
virtual int32_t get_num_vectors() const =0
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)=0
Features that support dot products among other operations.
virtual int32_t get_dim_feature_space() const =0
void add(bool *param, const char *name, const char *description="")
virtual bool train_machine(CFeatures *data=NULL)
virtual ELossType get_loss_type()=0
static void clear_cancel()
float64_t get_label(int32_t idx)
static T max(T a, T b)
return the maximum of two integers
Class LinearMachine is a generic interface for all kinds of linear machines like classifiers.
static float64_t dot(const bool *v1, const bool *v2, int32_t n)
compute dot product between v1 and v2 (blas optimized)
static bool cancel_computations()
bool is_two_class_labeling()
The class Features is the base class of all feature objects.
virtual void set_features(CDotFeatures *feat)
void set_loss_function(CLossFunction *loss_func)
static void scale_vector(T alpha, T *vec, int32_t len)
scale vector inplace
CHingeLoss implements the hinge loss function.
virtual void set_labels(CLabels *lab)
ELossType
shogun loss type
#define SG_MALLOC(type, len)