Skip to content

Commit

Permalink
clarify rows versus columns in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ablaom committed Jun 12, 2024
1 parent 37453bc commit dacdf97
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
7 changes: 3 additions & 4 deletions docs/src/interface/Custom Builders.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end
```

Note here that `n_in` and `n_out` depend on the size of the data (see
[Table 1](@ref Models).
[Table 1](@ref Models)).

For a concrete image classification example, see [Using MLJ to classifiy the MNIST image
dataset](@ref).
Expand All @@ -41,9 +41,8 @@ This method must return a `Flux.Chain` instance, `chain`, subject to the
following conditions:

- `chain(x)` must make sense:
- for any `x <: Array{<:AbstractFloat, 2}` of size `(n_in,
batch_size)` where `batch_size` is any integer (for use with one
of the first three model types); or
- for any `x <: Array{<:AbstractFloat, 2}` of size `(n_in, batch_size)` where
`batch_size` is any integer (for all models except `ImageClassifier`); or
- for any `x <: Array{<:Float32, 4}` of size `(W, H, n_channels,
batch_size)`, where `(W, H) = n_in`, `n_channels` is 1 or 3, and
`batch_size` is any integer (for use with `ImageClassifier`)
Expand Down
39 changes: 20 additions & 19 deletions docs/src/interface/Summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ the [scientific type](https://juliaai.github.io/ScientificTypes.jl/dev/)
indicated in the table below. The parameters `n_in`, `n_out` and `n_channels` refer to
information passed to the builder, as described under [Defining Custom Builders](@ref).

| Model Type | Prediction type | `scitype(X) <: _` | `scitype(y) <: _` |
|---------------------------------------------|-----------------|-----------------------------------------------------|-------------------------------------------------|
| [`NeuralNetworkRegressor`](@ref) | `Deterministic` | `Table(Continuous)` with `n_in` columns | `AbstractVector{<:Continuous)` (`n_out = 1`) |
| [`MultitargetNeuralNetworkRegressor`](@ref) | `Deterministic` | `Table(Continuous)` with `n_in` columns | `<: Table(Continuous)` with `n_out` columns |
| [`NeuralNetworkClassifier`](@ref) | `Probabilistic` | `<:Table(Continuous)` with `n_in` columns | `AbstractVector{<:Finite}` with `n_out` classes |
| [`NeuralNetworkBinaryClassifier`](@ref) | `Probabilistic` | `<:Table(Continuous)` with `n_in` columns | `AbstractVector{<:Finite{2}}` (`n_out = 2`) |
| [`ImageClassifier`](@ref) | `Probabilistic` | `AbstractVector(<:Image{W,H})` with `n_in = (W, H)` | `AbstractVector{<:Finite}` with `n_out` classes |
| Model Type | Prediction type | `scitype(X) <: _` | `scitype(y) <: _` |
|---------------------------------------------|-----------------|-------------------------------------------------------------------------|-------------------------------------------------|
| [`NeuralNetworkRegressor`](@ref) | `Deterministic` | `AbstractMatrix{Continuous}` or `Table(Continuous)` with `n_in` columns | `AbstractVector{<:Continuous)` (`n_out = 1`) |
| [`MultitargetNeuralNetworkRegressor`](@ref) | `Deterministic` | `AbstractMatrix{Continuous}` or `Table(Continuous)` with `n_in` columns | `<: Table(Continuous)` with `n_out` columns |
| [`NeuralNetworkClassifier`](@ref) | `Probabilistic` | `AbstractMatrix{Continuous}` or `Table(Continuous)` with `n_in` columns | `AbstractVector{<:Finite}` with `n_out` classes |
| [`NeuralNetworkBinaryClassifier`](@ref) | `Probabilistic` | `AbstractMatrix{Continuous}` or `Table(Continuous)` with `n_in` columns | `AbstractVector{<:Finite{2}}` (but `n_out = 1`) |
| [`ImageClassifier`](@ref) | `Probabilistic` | `AbstractVector(<:Image{W,H})` with `n_in = (W, H)` | `AbstractVector{<:Finite}` with `n_out` classes |


```@raw html
Expand All @@ -31,23 +31,24 @@ particular, an MLJ model does not store learned parameters.
```

```@raw html
<details open><summary><b>Dealing with non-tabular input</b></summary>
<details open><summary><b>Are oberservations rows or columns?</b></summary>
```
Any `AbstractMatrix{<:AbstractFloat}` object `Xmat` can be forced to
have scitype `Table(Continuous)` by replacing it with ` X =
MLJ.table(Xmat)`. Furthermore, this wrapping, and subsequent
unwrapping under the hood, will compile to a no-op. At present this
includes support for sparse matrix data, but the implementation has
not been optimized for sparse data at this time and so should be used
with caution.

Instructions for coercing common image formats into some
`AbstractVector{<:Image}` are
[here](https://juliaai.github.io/ScientificTypes.jl/dev/#Type-coercion-for-image-data).

In MLJ the convention for two-dimensional data (tables and matrices) is
**rows=obervations**. For matrices Flux has the opposite convention. If your data is a
matrix with whose column index the observation index, then your optimal solution is to
present the `adjoint` or `transpose` of your matrix to MLJFlux models. Otherwise, you can
use the matrix as is, or transform one time with `permutedims`, and again present the
`adjoint` or `transpose` as the optimal solution for MLJFlux training.

```@raw html
</details>
```

Instructions for coercing common image formats into some `AbstractVector{<:Image}` are
[here](https://juliaai.github.io/ScientificTypes.jl/dev/#Type-coercion-for-image-data).


```@raw html
<details closed><summary><b>Fitting and warm restarts</b></summary>
```
Expand Down

0 comments on commit dacdf97

Please sign in to comment.