|
1 |
| - |
2 | 1 | vtrait(X) = X |> trait |> Val
|
3 | 2 |
|
4 | 3 | const REQUIRE = "(requires MLJBase to be loaded)"
|
@@ -292,24 +291,36 @@ _squeeze(v) = first(v)
|
292 | 291 | # UnivariateFinite
|
293 | 292 |
|
294 | 293 | 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. |
297 | 312 |
|
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. |
302 | 314 |
|
303 |
| - CategoricalElement = Union{CategoricalValue,CategoricalString} |
| 315 | + UnivariateFinite(prob_given_class; pool=nothing, ordered=false) |
304 | 316 |
|
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. |
306 | 320 |
|
307 |
| - UnivariateFinite(prob_given_class) |
| 321 | +The type requirements on the keys of the dictionary are the same as |
| 322 | +`classes` above. |
308 | 323 |
|
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. |
313 | 324 | """
|
314 | 325 | UnivariateFinite(d::AbstractDict; kwargs...) =
|
315 | 326 | UnivariateFinite(get_interface_mode(), d; kwargs...)
|
|
0 commit comments