Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <shogun/classifier/vw/vw_math.h>
00016
00017 namespace shogun
00018 {
00019
00020 float32_t sd_offset_add(float32_t* weights, vw_size_t mask, VwFeature* begin, VwFeature* end, vw_size_t offset)
00021 {
00022 float32_t ret = 0.;
00023 for (VwFeature* f = begin; f!= end; f++)
00024 ret += weights[(f->weight_index + offset) & mask] * f->x;
00025 return ret;
00026 }
00027
00028 float32_t sd_offset_truncadd(float32_t* weights, vw_size_t mask, VwFeature* begin, VwFeature* end, vw_size_t offset, float32_t gravity)
00029 {
00030 float32_t ret = 0.;
00031 for (VwFeature* f = begin; f!= end; f++)
00032 {
00033 float32_t w = weights[(f->weight_index+offset) & mask];
00034 float32_t wprime = real_weight(w,gravity);
00035 ret += wprime*f->x;
00036 }
00037 return ret;
00038 }
00039
00040 float32_t one_pf_quad_predict(float32_t* weights, VwFeature& f, v_array<VwFeature> &cross_features, vw_size_t mask)
00041 {
00042 vw_size_t halfhash = quadratic_constant * f.weight_index;
00043
00044 return f.x *
00045 sd_offset_add(weights, mask, cross_features.begin, cross_features.end, halfhash);
00046 }
00047
00048 float32_t one_pf_quad_predict_trunc(float32_t* weights, VwFeature& f, v_array<VwFeature> &cross_features, vw_size_t mask, float32_t gravity)
00049 {
00050 vw_size_t halfhash = quadratic_constant * f.weight_index;
00051
00052 return f.x *
00053 sd_offset_truncadd(weights, mask, cross_features.begin, cross_features.end, halfhash, gravity);
00054 }
00055
00056 }