28 using namespace shogun;
71 for (int32_t i=0; i < dim;i++)
75 B[i]+=diffw/ (lambda*diffw+ loss_val*dst[i]);
83 for (int32_t i=0; i < dim;i++)
87 Bc[i] = Bc[i] * c1 + B[i] * c2;
101 SG_ERROR(
"Specified features are not of type CDotFeatures\n");
112 ASSERT(num_vec==num_train_labels);
127 t = 1 / (eta0 * lambda);
129 SG_INFO(
"lambda=%f, epochs=%d, eta0=%f\n", lambda, epochs, eta0);
142 SG_INFO(
"Training on %d vectors\n", num_vec);
146 bool is_log_loss =
false;
154 for (int32_t i=0; i<num_vec; i++)
163 if (z < 1 || is_log_loss)
192 if (z < 1 || is_log_loss)
221 SG_INFO(
"Estimating sparsity num_vec=%d num_feat=%d.\n", num_vec, c_dim);
226 for (int32_t j=0; j<num_vec ; j++, n++)
231 skip = (int32_t) ((16 * n * c_dim) / r);
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.
static void vector_multiply(T *target, const T *v1, const T *v2, int32_t len)
compute vector multiplication
void compute_ratio(float64_t *W, float64_t *W_1, float64_t *B, float64_t *dst, int32_t dim, float64_t regularizer_lambda, float64_t loss)
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
void set_loss_function(CLossFunction *loss_func)
virtual bool train(CFeatures *data=NULL)
virtual float64_t first_derivative(float64_t prediction, float64_t label)=0
static void add(T *target, T alpha, const T *v1, T beta, const T *v2, int32_t len)
target=alpha*vec1 + beta*vec2
virtual int32_t get_num_vectors() const =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 void free_vector()
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 bool cancel_computations()
bool is_two_class_labeling()
The class Features is the base class of all feature objects.
static T min(T a, T b)
return the minimum of two integers
virtual void set_features(CDotFeatures *feat)
void combine_and_clip(float64_t *Bc, float64_t *B, int32_t dim, float64_t c1, float64_t c2, float64_t v1, float64_t v2)
static void fill_vector(T *vec, int32_t len, T value)
SGVector< float64_t > get_computed_dot_feature_vector(int32_t num)
CHingeLoss implements the hinge loss function.
virtual void set_labels(CLabels *lab)
ELossType
shogun loss type
#define SG_MALLOC(type, len)