1 """
2 This module contains functions for logit l1 calculation
3 """
4
5 import victor_utils
6 import math
7
9 """
10 logit l1 sparse function
11 @type w: vector
12 @param w: model vector
13 @type mu: double
14 @param mu: mu
15 @type indexes: vector
16 @param indexes: indexes vector of the example's feature vector
17 @type vectors: vector
18 @param vectors: vector values of the example's feature vector
19 @type step: double
20 @param step: steps of the incremental stage
21 @type y: number
22 @param y: label of the example
23 """
24 wx = victor_utils.dot_dss(w,indexes,vectors)
25 sig = victor_utils.sigma(-wx*y)
26
27
28 victor_utils.scale_and_add_dss(w,indexes, vectors, step*y*sig)
29 victor_utils.l1_shrink_mask(w, mu*step)
30
32 """
33 Calculates and returns loss function
34 @type w: vector
35 @param w: model vector
36 @type indexes: vector
37 @param indexes: indexes vector of the example's feature vector
38 @type vectors: vector
39 @param vectors: vector values of the example's feature vector
40 @type y: number
41 @param y: label of the example
42 @rtype: double
43 @return: returns loss function value
44 """
45 wx = victor_utils.dot_dss(w,indexes,vectors)
46 return math.log(1 + math.exp(-y*wx))
47