Skip to content

Commit

Permalink
restrict distributions' version before its Ext #8
Browse files Browse the repository at this point in the history
  • Loading branch information
szcf-weiya committed Jan 12, 2024
1 parent ad71a3b commit 9174527
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: 3
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
user: szcf-weiya
email: szcfweiya@gmail.com
# Edit the following line to reflect the actual name of the GitHub Secret containing your private key
ssh: ${{ secrets.DOCUMENTER_KEY }}
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"

[compat]
Distributions = "0.25"
Distributions = "0.25.0 - 0.25.102"
ECOS = "1.1"
GLM = "1.8"
GaussianProcesses = "0.12"
Expand Down
13 changes: 4 additions & 9 deletions src/mono_decomp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ Perform smoothing spline on `(x, y)`, and make predictions on `xnew`.
Returns: `yhat`, `ynewhat`,....
"""
function smooth_spline(x::AbstractVector{T}, y::AbstractVector{T}, xnew::AbstractVector{T}; keep_stuff = false, design_matrix = false, LOOCV = false) where T <: AbstractFloat
# if LOOCV
# spl = R"smooth.spline($x, $y, keep.stuff = $keep_stuff, cv = TRUE)"
# else
# spl = R"smooth.spline($x, $y, keep.stuff = $keep_stuff, cv = FALSE)"
# end
spl = R"smooth.spline($x, $y, keep.stuff = $keep_stuff, cv = $LOOCV)"
Σ = nothing
if keep_stuff
Expand All @@ -182,8 +177,8 @@ function cv_smooth_spline(x::AbstractVector{T}, y::AbstractVector{T}, λs::Abstr
for k in 1:nfold
test_idx = folds[k]
train_idx = setdiff(1:n, test_idx)
for (i, λ) in enumerate(λs)
spl = R"smooth.spline($(x[train_idx]), $(y[train_idx]), lambda = $λ)"
for (i, lam) in enumerate(λs)
spl = R"smooth.spline($(x[train_idx]), $(y[train_idx]), lambda = $lam)"
yhat = rcopy(R"predict($spl, $(x[test_idx]))$y")
# for LOOCV, yhat is a scalar, while y[test_idx] is a vector, use `.-` can help
errs[k, i] = norm(yhat .- y[test_idx])^2 / length(test_idx)
Expand All @@ -201,11 +196,11 @@ function cv_smooth_spline(x::AbstractVector{T}, y::AbstractVector{T}, λs::Abstr
elseif ind == 1
@warn "the optimal is on the left boundary of λs"
end
λopt = λs[ind]
optlam = λs[ind]
if !isnothing(figname)
savefig(cvplot(μerr, σerr, λs, nfold = nfold, ind0 = ind, lbl = "λ"), figname)
end
spl = R"smooth.spline($x, $y, lambda = $λopt, keep.stuff = TRUE)"
spl = R"smooth.spline($x, $y, lambda = $optlam, keep.stuff = TRUE)"
Σ = recover(rcopy(R"$spl$auxM$Sigma"))
knots = rcopy(R"$spl$fit$knot")[4:end-3]
bbasis = R"fda::create.bspline.basis(breaks = $knots, norder = 4)"
Expand Down

2 comments on commit 9174527

@szcf-weiya
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/98782

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 91745272853336578eec1966c721eae491588a25
git push origin v0.1.0

Please sign in to comment.