Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiedb committed Sep 15, 2022
1 parent e96a77b commit 88bf5fd
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ jobs:
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
DOCUMENTER_KEY: ${{ secrets.CODECOV_TOKEN }} # If authenticating with SSH deploy key
20 changes: 20 additions & 0 deletions src/fit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ function init(config::EvoLinearRegressor;

end


"""
fit(config::EvoLinearRegressor;
x, y, w=nothing,
x_eval=nothing, y_eval=nothing, w_eval=nothing,
metric=:mse,
print_every_n=1,
tol=1e-5)
`Provided a `config`, EvoLinear.fit` takes `x` and `y` as features and target inputs, plus optionally `w` as weights and train a Linear boosted model.
# Arguments
- `config::EvoLinearRegressor`:
# Keyword arguments
- `x::AbstractMatrix`: Features matrix. Dimensions are `[nobs, num_features]`.
- `y::AbstractVector`: Vector of observed targets.
- `w=nothing`: Vector of weights. Can be be either a `Vector` or `nothing`. If `nothing`, assumes a vector of 1s.
- `metric=:mse`: Evaluation metric to be tracked through each iteration.
"""
function fit(config::EvoLinearRegressor;
x, y, w=nothing,
x_eval=nothing, y_eval=nothing, w_eval=nothing,
Expand Down
29 changes: 28 additions & 1 deletion src/predict.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
function predict_linear(m, x)
"""
predict_linear(m, x)
Returns the predictions on the linear basis from model `m` using the features matrix `x`.
# Arguments
- `m::EvoLinearModel`
- `x`
"""
function predict_linear(m::EvoLinearModel, x)
p = x * m.coef .+ m.bias
return p
end

"""
predict_proj(m, x)
Returns the predictions on the projected basis from model `m` using the features matrix `x`.
- `MSE`: pred_proj = pred_linear
- `Logistic`: pred_proj = sigmoid(pred_linear)
- `Poisson`: pred_proj = exp(pred_linear)
- `Gamma`: pred_proj = exp(pred_linear)
- `Tweedie`: pred_proj = exp(pred_linear)
# Arguments
- `m::EvoLinearModel`
- `x`
"""
function predict_proj(m::EvoLinearModel{MSE}, x)
p = predict_linear(m, x)
return p
Expand Down

0 comments on commit 88bf5fd

Please sign in to comment.