Logistic Regression

sparkliblinear 库的类关系图

LR with spark liblinear
1、LR

Given a set of training label-instance pairs ${(x_ i ,y_ i )}^ l_{i=1} ,
x i \in \mathbb{R}^ n , y i \in{−1,1}, \forall{i} $

LR with L2 reg model considers the following optimization problem:

minwf(w)=12wTw+Cli=1log(1+exp(yiwTxi))1

minwf(w)=12wTw+Ci=1llog(1+exp(yiwTxi))1
minwf(w)=12wTw+Ci=1llog(1+exp(yiwTxi))1
minwf(w)=12wTw+Ci=1llog(1+exp(yiwTxi))1
minwf(w)=12wTw+Ci=1llog(1+exp(yiwTxi))1
minwf(w)=12wTw+Ci=1llog(1+exp(yiwTxi))1
minwf(w)=12wTw+Ci=1llog(1+exp(yiwTxi))1
minwf(w)=12wTw+Ci=1llog(1+exp(yiwTxi))1
minwf(w)=12wTw+Ci=1llog(1+exp(yiwTxi))1
minwf(w)=12wTw+Ci=1llog(1+exp(yiwTxi))1
minwf(w)=12wTw+Ci=1llog(1+exp(yiwTxi))1

2、A Trust Region Newton Method(TRON)

TRON obtains the truncated Newton step by approximately solving
mindqt(d)subject todΔt2

mindqt(d)subject todΔt2
mindqt(d)subject todΔt2
mindqt(d)subject todΔt2
mindqt(d)subject todΔt2
mindqt(d)subject todΔt2
mindqt(d)subject todΔt2
mindqt(d)subject todΔt2
mindqt(d)subject todΔt2
mindqt(d)subject todΔt2
mindqt(d)subject todΔt2

ΔtΔtΔtΔtΔtΔtΔtΔtΔtΔtΔt is the size of the trust region, qt(d)=f(wt)Td+12dT2f(xt)dqt(d)=f(wt)Td+12dT2f(xt)dqt(d)=f(wt)Td+12dT2f(xt)dqt(d)=f(wt)Td+12dT2f(xt)dqt(d)=f(wt)Td+12dT2f(xt)dqt(d)=f(wt)Td+12dT2f(xt)dqt(d)=f(wt)Td+12dT2f(xt)dqt(d)=f(wt)Td+12dT2f(xt)dqt(d)=f(wt)Td+12dT2f(xt)dqt(d)=f(wt)Td+12dT2f(xt)dqt(d)=f(wt)Td+12dT2f(xt)d
is the second-order Taylor approximation of f(wt+d)f(wt)f(wt+d)f(wt)f(wt+d)f(wt)f(wt+d)f(wt)f(wt+d)f(wt)f(wt+d)f(wt)f(wt+d)f(wt)f(wt+d)f(wt)f(wt+d)f(wt)f(wt+d)f(wt)f(wt+d)f(wt).

applying CG(Conjugate Gradient) to slove (2)

2.1 Distributed Algorithm

We partition the data matrix X and the labels Y into
disjoint p parts.
X=[X1,...,Xp]T,Y=diag(y1,...,yl)=[Y1...Yp],σ(v)[1+exp(v1),...,1+exp(vn)]T

X=[X1,...,Xp]T,Y=diag(y1,...,yl)=[Y1...Yp],σ(v)[1+exp(v1),...,1+exp(vn)]T
X=[X1,...,Xp]T,Y=diag(y1,...,yl)=[Y1...Yp],σ(v)[1+exp(v1),...,1+exp(vn)]TX=[X1,...,Xp]T,Y=diag(y1,...,yl)=[Y1...Yp],σ(v)[1+exp(v1),...,1+exp(vn)]T
X=[X1,...,Xp]T,Y=diag(y1,...,yl)=[Y1...Yp],σ(v)[1+exp(v1),...,1+exp(vn)]TX=[X1,...,Xp]T,Y=diag(y1,...,yl)=[Y1...Yp],σ(v)[1+exp(v1),...,1+exp(vn)]T
X=[X1,...,Xp]T,Y=diag(y1,...,yl)=[Y1...Yp],σ(v)[1+exp(v1),...,1+exp(vn)]TX=[X1,...,Xp]T,Y=diag(y1,...,yl)=[Y1...Yp],σ(v)[1+exp(v1),...,1+exp(vn)]T
X=[X1,...,Xp]T,Y=diag(y1,...,yl)=[Y1...Yp],σ(v)[1+exp(v1),...,1+exp(vn)]TX=[X1,...,Xp]T,Y=diag(y1,...,yl)=[Y1...Yp],σ(v)[1+exp(v1),...,1+exp(vn)]T
X=[X1,...,Xp]T,Y=diag(y1,...,yl)=[Y1...Yp],σ(v)[1+exp(v1),...,1+exp(vn)]TX=[X1,...,Xp]T,Y=diag(y1,...,yl)=[Y1...Yp],σ(v)[1+exp(v1),...,1+exp(vn)]T

We can observe that for computing (12)-(14), only the data partition XkXkXkXkXkXkXkXkXkXkXk is needed in computing. Therefore, the computation can be done in parallel, with the partitions being stored distributedly. After the map functions are computed, we need to reduce the results to the machine performing the TRON algorithm in order to obtain the summation over all partitions.

3、Implement Design

1) Loop Structure: choose the while loop to implement the software

2) Data Encapsulation:

AA uses two arrays to store indices and feature values of an instance:

ndex1 index2 index3 index4 index5 …

value1 value2 value3 value4 value5 …

3) Using mapPartitions Rather Than map

4) not to cache σ(YkXkw)σ(YkXkw)σ(YkXkw)σ(YkXkw)σ(YkXkw)σ(YkXkw)σ(YkXkw)σ(YkXkw)σ(YkXkw)σ(YkXkw)σ(YkXkw)

5) Using Broadcast Variables

相关文章:

  • 2021-06-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2021-07-20
  • 2021-08-10
  • 2022-02-10
猜你喜欢
  • 2021-05-22
  • 2021-09-22
  • 2022-12-23
  • 2021-10-07
  • 2021-08-19
  • 2021-09-06
相关资源
相似解决方案