Skip to content

Commit

Permalink
Merge pull request #270 from FluxML/multitarget-docstring-fix
Browse files Browse the repository at this point in the history
Fix `l2` loss in `MultitargetNeuralNetworkRegressor` doctring
  • Loading branch information
ablaom authored Aug 6, 2024
2 parents 70dff6e + d77d20d commit 1e41256
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
16 changes: 11 additions & 5 deletions docs/src/extended_examples/MNIST/notebook.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
# This tutorial is available as a Jupyter notebook or julia script
# [here](https://github.com/FluxML/MLJFlux.jl/tree/dev/docs/src/extended_examples/MNIST).

using Pkg #!md
const DIR = @__DIR__ #!md
Pkg.activate(DIR) #!md
Pkg.instantiate() #!md
# The following code block assumes the current directory contains `Manifest.toml` and
# `Project.toml` files tested for this demonstration, available
# [here](https://github.com/FluxML/MLJFlux.jl/tree/dev/docs/src/extended_examples/MNIST).
# Otherwise, you can try running `using Pkg; Pkg.activate(temp=true)` instead, and
# manually add the relevant packages to the temporary environment created.

using Pkg
const DIR = @__DIR__
Pkg.activate(DIR)
Pkg.instantiate()

# **Julia version** is assumed to be 1.10.*
# **Julia version** is assumed to be 1.10**

using MLJ
using Flux
Expand Down
12 changes: 9 additions & 3 deletions docs/src/extended_examples/spam_detection/notebook.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
# **Warning.** This demo includes some non-idiomatic use of MLJ to allow use of the
# Flux.jl `Embedding` layer. It is not recommended for MLJ beginners.

using Pkg #!md
Pkg.activate(@__DIR__); #!md
Pkg.instantiate(); #!md
# The following code block assumes the current directory contains `Manifest.toml` and
# `Project.toml` files tested for this demonstration, available
# [here](https://github.com/FluxML/MLJFlux.jl/tree/dev/docs/src/extended_examples/spam_detection).
# Otherwise, you can try running `using Pkg; Pkg.activate(temp=true)` instead, and
# manually add the relevant packages to the temporary environment created.

using Pkg
Pkg.activate(@__DIR__);
Pkg.instantiate();

# ### Basic Imports
using MLJ
Expand Down
6 changes: 2 additions & 4 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1190,16 +1190,14 @@ With the learning rate fixed, we can now compute a CV estimate of the performanc
all data bound to `mach`) and compare this with performance on the test set:
```julia
# custom MLJ loss:
multi_loss(yhat, y) = l2(MLJ.matrix(yhat), MLJ.matrix(y))
# CV estimate, based on `(X, y)`:
evaluate!(mach, resampling=CV(nfolds=5), measure=multi_loss)
evaluate!(mach, resampling=CV(nfolds=5), measure=multitarget_l2)
# loss for `(Xtest, test)`:
fit!(mach) # trains on all data `(X, y)`
yhat = predict(mach, Xtest)
multi_loss(yhat, ytest)
multitarget_l2(yhat, ytest)
```
See also
Expand Down

0 comments on commit 1e41256

Please sign in to comment.