约束算法

c-lasso的Python项目详细描述


python中的约束稀疏回归函数

安装软件包:
pip安装套索
导入包:
导入类o
  1. 不同类型的问题:
    • 最小平方:min ax-y ^2+lambda*x u 1
    • 休伯:最小h|rho(Ax-y)+lambda*| | x | | | u 1
    • 伴随最小二乘法:min ax-y ^2/sigma+n*sigma+lambda x u 1
    • 伴随huber:min h_rho((ax-y)/sigma+n)*sigma+lambda*x u 1
  2. 解决问题的不同方法:

    Four main methods have been implemented for those.

    Forward Backward splitting method:

    Standard way to solve a convex minimisation problem with an addition of smooth and non-smooth function : Projected Proximal Gradient Descent. This method only works with the two non concomitants problems. For the huber problem, we use the second formulation.

    No-proj method

    Similar to the Projected Proximal Gradient Descent, but which does not involve a projection, which can be difficult to compute for some matrix C. Only for non concomitant problems.

    Double prox method

    Use of Doulgas Rachford splitting algorithm which use the proximal operator of both functions. It also solves concomitant problems, but it is usefull even in the non concomitant case because it is usually more efficient than forward backward splitting method. For the huber problem, we use the second formulation, then we change it into a Least square problem of dimension m (m + d) instead of m d.

    ODE method

    From the KKT conditions, we can derive an simple ODE for the solution of the non concomitants problems, which shows that the solution is piecewise- affine. For the least square, as the problem can always be reported to a a non concomitant problem for another lambda, one can use the whole non-concomitant- path computed with the ODE method to then solve the concomitant-path.

  3. 两大功能

    For solving the problem for a fix lambda :

    fixlasso (matrix, lam, typ =’LS ‘, meth =’choose ‘, plot_time =True, plot_sol =True, plot_sigm =True, rho = 1.345)

    -matrix

    Matrices (A;C; y) of the problem.

    -lam

    Lambda/lambdamax in [0; 1] where lambdamax is a majoration of the lambda when the solution is null (depends on the type of problem).

    -typ

    Type of problem : ‘Huber’, ‘Concomitant’ , ‘Concomitant Huber’ or ‘LS’. Any other string will set the type of problem to Least Square.

    -meth
    Method to solve the problem. If wrong input, the algorithm choose the method according to lambda
    • Possibilities for types ‘LS’ and ‘Huber’ : ‘FB’, ‘Noproj’, ‘2prox’, ‘ODE’.
    • Possibilities for type ‘Concomitant’ : ‘2prox’, ‘ODE’.
    • Possibilities for type ‘Concomitant Huber’ : ‘2prox’.
    -plot_time

    If set to True : prints the running time.

    -plot_sol

    If set to True : plots the solution in a bars diagram.

    -plot_sigm

    If set to True and the type we solve a concomitant problem : prints sigma/sigmamax.

    -rho

    Normalized rho for non-concomitant Huber problem : rho * sqrt(m) / norm_inf(y) Unormalized sigma for concomitant Huber problem.

    -returns
    The function returns :

    An ‘numpy.ndarray’ type vector representing the solution betafor non concomitant problems, A tuple containing beta and sigma for the concomitant problems.

    解决整个路径的问题:

    Patlasso(矩阵,lambdas='choose',lamin=1e-2,typ='ls',meth='ode',plot_time=true,plot_sol=true,plot_sigm=true,rho=1.345,compare=false)

    -matrix

    Matrices (A;C; y) of the problem.

    -lambdas

    Gives the list of lambda/lambdamax in [0; 1] where we need the problem to be solved. If a boolean is given, it is the next parameter that will give the path.

    -lamin

    If lambdas is a boolean, it gives the lambda/lambdamax minimum : the algorithm will solve the problem for all lambda in [lamin * lambdamax; lambdamax] (with 100 points).

    -typ

    Type of problem : ‘Huber’, ‘Concomitant’ , ‘Concomitant Huber’ or ‘LS’. Any other string will set the type of problem to Least Square.

    -meth
    Method to solve the problem. If wrong input, the algorithm choose the method according to lambda.
    • Possibilities for types ‘LS’ and ‘Huber’ : ‘FB’, ‘Noproj’, ‘2prox’, ‘ODE’.
    • Possibilities for type ‘Concomitant’ : ‘2prox’, ‘ODE’.
    • Possibilities for type ‘Concomitant Huber’ : ‘2prox’.

    For each case except ‘ODE’, the algorithm solves the problem for each lambda of the path using warm starts.

    -plot_time

    If set to True : prints the running time.

    -plot_sol

    If set to True : plots the solution in a bars diagram.

    -plot_sigm

    If set to True and the type we solve a concomitant problem : prints sigma/sigmamax.

    -rho

    Normalized rho for non-concomitant Huber problem : rho * sqrt(m) / norm_inf(y) Unormalized sigma for concomitant Huber problem.

    -returns
    The function returns :

    a list ‘numpy.ndarray’ type vector representing the solution beta for each lambda ; the list of lambda corresponding (unormalized), also the list of sigmas for the concomitant problems.

  4. 小功能:

    For computing the theoretical lambda/lambdamax in the case of concomitant problems :

    model_selection(m,d)

    Where m is the number of sample and d the number of parameter, it returns : lam0 = sqrt(2/m) invPhi(1-t), with invPhi the quantile function for the standard normal distribution, and t is the solution to the equation t*p = invPhi(1-t)**4 + 2*invPhi(1-t)**2

    使用交叉验证和以前的主要功能计算解决方案:

    CV(matrices,k=5,typ=’LS’,test=0.4,lamin=1e-2, print_lam= True)

    Where k is the number of ‘cluster’ used, test is the proportion of sample kept for testing, and print lam tells us if the function also print the lambda/lambdamax used. The function returns the solution Beta as a ‘numpy.ndarray’.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java将图片从网站自动复制到数据库中   给定长度的java随机字符串单元测试   将java应用程序(Azure函数应用程序)迁移到运行时3。x从2开始。GRADLE的x   java会自动为maven项目的eclipse构建路径添加额外的源目录   java应用程序。属性与applicationContext。xml   如何在shell脚本中获取Java应用程序的退出状态、标准输出和标准错误流?   尽管使用了:setVerticalScrollBarPolicy(JScrollPane.VERTICAL\u SCROLLBAR\u ALWAYS),但JScrollPane滚动条未显示的java奇怪问题;   java使用本机SQL Hibernate从存储过程中检索值   java当用户在安卓应用程序中更改另一个交换机时,如何更改一个交换机的状态   java Java8 DateTimeFormatter am/pm   java使用选项“XinjectCodeExtension”插入XJC+xsd+jxb代码   适用于cocos2d Android的java Stop背景音乐   java HttpPost到asp服务器(HTML格式)   java Maven解析属性占位符