Home

Awesome

Regression

A Julia package for regression analysis.

Build Status


Overview

This package is based on EmpiricalRisks, and provides a set of algorithms to perform regression analysis.

This package supports all regression problems that can be formulated as regularized empirical risk minimization, as

regerm

In particular, it supports:

The package also provides a variety of solvers


High Level Interface

The package provides a high-level interface to simplify typical use.

Example:

The following script shows how one can use this package to perform logistic regression:

d = 3      # sample dimension
n = 1000   # number of samples

# prepare data
w = randn(d+1)    # generate the weight vector
X = randn(d, n)   # generate input features
y = sign(X'w[1:d] + w[d+1] + 0.2 * randn(n))  # generate (noisy) response

# perform estimation
ret = Regression.solve(
    logisticreg(X, y; bias=1.0),   # construct a logistic regression problem
    reg=SqrL2Reg(1.0e-2),          # apply squared L2 regularization
    options=Options(verbosity=:iter, grtol=1.0e-6 * n))  # set options

# extract results
w_e = ret.sol

The high-level interface involves two parts: problem construction and problem solving.

Constructing Problems

The package provide several functions to construct regression problems:

The package also provides convenience functions to construct common problems:

Solving Problems

With a constructed problem, you can solve the problem with the solve function.

Note: The solve function is not exported (in order to avoid confliction with other optimization packages). You should write Regression.solve when calling this function.

Solvers

As mentioned, the package implements a variety of solvers, one can construct a solver using the following functions:

GD()       # Gradient descent
BFGS()     # BFGS Quasi-Newton method
LBFGS(m)   # L-BFGS method (with history size m)
ProxGD()   # Proximal gradient descent (suitable for sparse learning, etc)

# the following solver remains in experimental status
AGD()      # Accelerated gradient descent
ProxAGD()  # Accelerated proximal gradient descent

Lower Level Interface

Those who care more on performance can directly call the Regression.solve! function, as follows:

# Note: solve! will update the solution θ inplace
function solve!{T<:FloatingPoint}(
    solver::DescentSolver,  # the chosen solver
    f::Functional{T},       # the objective functional
    θ::Array{T},            # the solution (which would be updated inplace)
    options::Options,       # options to control the procedure
    callback::Function)     # callback function

# Here, the functional f can be constructed using the following functions:

# empirical risk minimization
f = RiskFun(rmodel, X, Y)   # rmodel is the risk model

# regularized empirical risk minimization
f = RegRiskFun(rmodel, reg, X, Y)   # rmodel is the risk model, reg is the regularizer

Algebraic Solution to Linear & Ridge Regression

Note that for linear regression and ridge regression, there exists analytic solution. The package also provides functions that directly compute the analytic solution to these problems, using linear algebraic methods.