Skip to content

Commit b0ebe91

Browse files
authored
Merge pull request #44 from alan-turing-institute/dev
For a 0.2.6 release
2 parents c5dde75 + 3ed6ff9 commit b0ebe91

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MLJModelInterface"
22
uuid = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
33
authors = ["Thibaut Lienart and Anthony Blaom"]
4-
version = "0.2.5"
4+
version = "0.2.6"
55

66
[deps]
77
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

src/data_utils.jl

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
vtrait(X) = X |> trait |> Val
32

43
const REQUIRE = "(requires MLJBase to be loaded)"
@@ -292,24 +291,36 @@ _squeeze(v) = first(v)
292291
# UnivariateFinite
293292

294293
const UNIVARIATE_FINITE_DOCSTRING =
295-
"""
296-
UnivariateFinite(classes, p)
294+
"""
295+
UnivariateFinite(classes, p; pool=nothing, ordered=false)
296+
297+
Construct a discrete univariate distribution whose finite support is
298+
the elements of the vector `classes`, and whose corresponding
299+
probabilities are elements of the vector `p`, which must sum to one $REQUIRE.
300+
301+
*Important.* Here `classes` must have type
302+
`AbstractVector{<:CategoricalValue}` and all elements are assumed to
303+
share the same categorical pool. Raw classes *may* be used, but only provided
304+
`pool` is specified. The possible values are:
305+
306+
- some `v::CategoricalVector` such that `classes` is a subset of `levels(v)`
307+
308+
- some `a::CategoricalValue` such that `classes` is a subset of `levels(a)`
309+
310+
- `missing`, in which case a new categorical pool is created which has
311+
`classes` as its only levels.
297312
298-
A discrete univariate distribution whose finite support is the elements of the
299-
vector `classes`, and whose corresponding probabilities are elements of the
300-
vector `p`, which must sum to one $REQUIRE. Here `classes` must have type
301-
`AbstractVector{<:CategoricalElement}` where
313+
In the last case specify `ordered=true` to order the new pool.
302314
303-
CategoricalElement = Union{CategoricalValue,CategoricalString}
315+
UnivariateFinite(prob_given_class; pool=nothing, ordered=false)
304316
305-
and all classes are assumed to share the same categorical pool.
317+
Construct a discrete univariate distribution whose finite support is
318+
the set of keys of the provided dictionary, `prob_given_class`, and
319+
whose values specify the corresponding probabilities $REQUIRE.
306320
307-
UnivariateFinite(prob_given_class)
321+
The type requirements on the keys of the dictionary are the same as
322+
`classes` above.
308323
309-
A discrete univariate distribution whose finite support is the set of keys of
310-
the provided dictionary, `prob_given_class` $REQUIRE. The dictionary keys must
311-
be of type `CategoricalElement` (see above) and the dictionary values specify
312-
the corresponding probabilities.
313324
"""
314325
UnivariateFinite(d::AbstractDict; kwargs...) =
315326
UnivariateFinite(get_interface_mode(), d; kwargs...)

0 commit comments

Comments
 (0)