28 init(NULL, 0, use_quadr, keep_lin_terms);
35 init(feats, d, use_quadr, keep_lin_terms);
43 init(feats, d, use_quadr, keep_lin_terms);
52 init(feats, d, use_quadr, keep_lin_terms);
60 use_quadratic = use_quadr;
61 keep_linear_terms = keep_lin_terms;
65 SG_ADD(&use_quadratic,
"use_quadratic",
"Whether to use quadratic features",
67 SG_ADD(&keep_linear_terms,
"keep_linear_terms",
"Whether to keep the linear terms or not",
70 SG_ADD((
CSGObject** ) &sparse_feats,
"sparse_feats",
"Sparse features to work on",
103 int32_t vec_idx)
const
106 dim, use_quadratic, keep_linear_terms);
111 bool use_quadratic,
bool keep_linear_terms)
118 bool use_quadratic,
bool keep_linear_terms)
132 hash_cache[i] = hash;
134 if ( (!use_quadratic) || keep_linear_terms )
150 idx = (hash_cache[i] ^ hash_cache[j]) % dim;
156 int32_t num_nnz_features = 0;
165 int32_t sparse_index = 0;
213 hash_cache[i] = hash;
215 if ( (!use_quadratic) || keep_linear_terms)
231 idx = (hash_cache[i] ^ hash_cache[j]) % dim;
237 sparse_feats ->free_feature_vector(vec_idx1);
243 float64_t* vec2, int32_t vec2_len,
bool abs_val)
258 hash_cache[i] = hash;
260 if ( (!use_quadratic) || keep_linear_terms)
276 idx = (hash_cache[i] ^ hash_cache[j]) % dim;
281 sparse_feats ->free_feature_vector(vec_idx1);
312 return "HashedSparseFeatures";
330 return sparse_feats ->get_num_vectors();