PartitionedLS.jl
TBD
Package Features
- TBD
Function Documentation
PartitionedLS.fit
— Functionfit(::Type{Alt}, X::Array{Float64,2}, y::Array{Float64,1}, P::Array{Int,2}; T = 1000, η = 1.0, ϵ = 1e-6, getsolver = getECOSSolver)
Fits a PartitionedLS model by alternating the optimization of the α and β variables.
Arguments
X
: $N × M$ matrix describing the examplesy
: $N$ vector with the output values for each exampleP
: $M × K$ matrix specifying how to partition the $M$ attributes into $K$ subsets. $P_{m,k}$ should be 1 if attribute number $m$ belongs to
partition $k$.
η
: regularization factor, higher values implies more regularized solutionsT
: number of alternating loops to be performed, defaults to 20.get_solver
: a function returning the solver to be used. Defaults to () -> ECOSSolver()ϵ
: minimum relative improvement in the objective function before stopping the optimization. Default is 1e-6
Result
A tuple of the form: (opt, a, b, t, P)
opt
: optimal value of the objective function (loss + regularization)a
: values of the α variables at the optimal pointb
: values of the β variables at the optimal pointt
: the intercept at the optimal pointP
: the partition matrix (copied from the input)
fit(::Type{AltNNLS}, X::Array{Float64,2}, y::Array{Float64,1}, P::Array{Int,2}; η = 0.0, ϵ = 1e-6, T = 1000, nnlsalg = :pivot)
Fits a PartitionedLS model by alternating the optimization of the α and β variables. This version uses an optimization strategy based on non-negative-least-squaes solvers. This formulation is faster and more numerically stable with respect to fit(Alt, ...)
`.
Arguments
X
: $N × M$ matrix describing the examplesy
: $N$ vector with the output values for each exampleP
: $M × K$ matrix specifying how to partition the $M$ attributes into $K$ subsets. $P_{m,k}$ should be 1 if attribute number $m$ belongs to
partition $k$.
η
: regularization factor, higher values implies more regularized solutionsT
: number of alternating loops to be performed, defaults to 1000.ϵ
: minimum relative improvement in the objective function before stopping the optimization. Default is 1e-6nnlsalg
: specific flavour of nnls algorithm to be used, possible values are:pivot
,:nnls
,:fnnls
Result
A tuple of the form: (opt, a, b, t, P)
opt
: optimal value of the objective function (loss + regularization)a
: values of the α variables at the optimal pointb
: values of the β variables at the optimal pointt
: the intercept at the optimal pointP
: the partition matrix (copied from the input)
fit(::Type{Opt}, X::Array{Float64,2}, y::Array{Float64,1}, P::Array{Int,2}; η=1.0, getsolver=getECOSSolver, returnAllSolutions=false)
Fits a PartialLS Regression model to the given data and resturns the learnt model (see the Result section). It uses a coplete enumeration strategy which is exponential in K, but guarantees to find the optimal solution.
Arguments
X
: $N × M$ matrix describing the examplesy
: $N$ vector with the output values for each exampleP
: $M × K$ matrix specifying how to partition the $M$ attributes into $K$ subsets. $P_{m,k}$ should be 1 if attribute number $m$ belongs to
partition $k$.
η
: regularization factor, higher values implies more regularized solutionsget_solver
: a function returning the solver to be used. Defaults to () -> ECOSSolver()returnAllSolutions
: if true an additional output is appended to the resulting tuple containing all solutions found during the algorithm.
Result
A tuple of the form: (opt, a, b, t, P)
opt
: optimal value of the objective function (loss + regularization)a
: values of the α variables at the optimal pointb
: values of the β variables at the optimal pointt
: the intercept at the optimal pointP
: the partition matrix (copied from the input)- solutions: all solutions found during the execution (returned only if resultAllSolutions=true)
The output model predicts points using the formula: f(X) = $X * (P .* a) * b + t$.
fit(::Type{Opt}, X::Array{Float64,2}, y::Array{Float64,1}, P::Array{Int,2}; η=1.0, getsolver=getECOSSolver, returnAllSolutions=false, nnlsalg=:pivot)
Fits a PartialLS Regression model to the given data and resturns the learnt model (see the Result section). It uses a coplete enumeration strategy which is exponential in K, but guarantees to find the optimal solution.
Arguments
X
: $N × M$ matrix describing the examplesy
: $N$ vector with the output values for each exampleP
: $M × K$ matrix specifying how to partition the $M$ attributes into $K$ subsets. $P_{m,k}$ should be 1 if attribute number $m$ belongs to
partition $k$.
η
: regularization factor, higher values implies more regularized solutionsget_solver
: a function returning the solver to be used. Defaults to () -> ECOSSolver()returnAllSolutions
: if true an additional output is appended to the resulting tuple containing all solutions found during the algorithm.nnlsalg
: the kind of nnls algorithm to be used during solving. Possible values are :pivot, :nnls, :fnnls
Result
A tuple of the form: (opt, a, b, t, P)
opt
: optimal value of the objective function (loss + regularization)a
: values of the α variables at the optimal pointb
: values of the β variables at the optimal pointt
: the intercept at the optimal pointP
: the partition matrix (copied from the input)- solutions: all solutions found during the execution (returned only if resultAllSolutions=true)
The output model predicts points using the formula: f(X) = $X * (P .* a) * b + t$.
fit(::Type{BnB}, X::Array{Float64,2}, y::Array{Float64,1}, P::Array{Int,2}, η=1.0, nnlsalg=:pivot)
Implements the Branch and Bound algorithm to fit a Partitioned Least Squres model.
Arguments
X
: $N × M$ matrix describing the examplesy
: $N$ vector with the output values for each exampleP
: $M × K$ matrix specifying how to partition the $M$ attributes into $K$ subsets. $P_{m,k}$ should be 1 if attribute number $m$ belongs to
partition $k$.
η
: regularization factor, higher values implies more regularized solutions- nnlsalg: the kind of nnls algorithm to be used during solving. Possible values are :pivot, :nnls, :fnnls
Result
A tuple of the form: (opt, a, b, t, P, nopen)
opt
: optimal value of the objective function (loss + regularization)a
: values of the α variables at the optimal pointb
: values of the β variables at the optimal pointt
: the intercept at the optimal pointP
: the partition matrix (copied from the input)nopen
: the number of nodes opened by the BnB algorithm
The output model predicts points using the formula: f(X) = $X * (P .* a) * b + t$.
PartitionedLS.predict
— Functionpredict(α::Vector{Float64}, β::Vector{Float64}, t::Float64, P::Matrix{Int}, X::Matrix{Float64})::Vector{Float64}
Result
the prediction for the partitioned least squares problem with solution α, β, t over the dataset X and partition matrix P
predict(model::Tuple, X::Array{Float64,2})
Make predictions for the datataset X
using the PartialLS model model
.
Arguments
model
is a Tuple in the form returned by fit functions, it shall contains the following elements:opt
: the optimal value of the objective attained by the fit functionα
: the values of the α variablesβ
: the values of the β variablest
: the value of the t variableP
: the partition matrix
X
: the data containing the examples for which the predictions are sought
Return
the predictions of the given model on examples in X.