-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Allow DiscreteNonParametric
to have non-Real
support
#916
RFC: Allow DiscreteNonParametric
to have non-Real
support
#916
Conversation
Codecov Report
@@ Coverage Diff @@
## master #916 +/- ##
=========================================
+ Coverage 73.94% 76.3% +2.35%
=========================================
Files 107 107
Lines 5269 5114 -155
=========================================
+ Hits 3896 3902 +6
+ Misses 1373 1212 -161
Continue to review full report at Codecov.
|
Bump. Any thoughts on this? |
Not that I have any say, but this looks like a good idea to me. However, am I right in thinking that logcdf(d::DiscreteUnivariateDistribution, x::Real) = logcdf(d, floor(Int,x)) |
I wanted this pull request to be backwards-compatible, which is why I didn't make any changes to the behavior of I imagine that removing those calls to |
True, but only to people doing some seriously crazy stuff! |
Closing in favor of #941 |
Description
Let
vs
denote the list of support values used when creating an instance ofDiscreteNonParametric
. Currently, we require that:vs::Ts
whereTs<:AbstractVector{T}
andT<:Real
.This pull request relaxes the requirement so that it is now:
vs::Ts
whereTs<:AbstractVector{T}
This allows you to create instances of
DiscreteNonParametric
that have non-Real
support.All of the existing
DiscreteNonParametric
tests are preserved, to show that this change is backwards compatible and will have no effect on DiscreteNonParametric whenT<:Real
.I also add some tests for
DiscreteNonParametric
whenT
isString
.Motivation
Suppose you have trained a multiclass classifier, and you would now like run the classifier on a single sample. For each of the classes, the classifier will output the probability of that class. For example, the output might be
setosa=0.1, versicolor=0.7, verginica=0.2
.Since the output of a multiclass classifier (when run on a single sample) is a discrete non-parametric distribution on the set of classes, it would be natural to store it in a
DiscreteNonParametric
. However, currentlyDiscreteNonParametric
requires that the support be a list of real values. This pull request relaxes the requirement and allows you to create aDiscreteNonParametric
where the support values can be of any type (such asString
).