-
-
Save quinn-dougherty/4be2257d132331bf1cfb864db3b06337 to your computer and use it in GitHub Desktop.
| // Needs to be able to import `PointSetTypes.pointSetDist` as `t` | |
| type scoreArgs = DistDist(t, t) | DistFloat(t, float), DistDistDist(t, t, t), DistFloatDist(t, float, t) | |
| // Can be expanded for the other 4 cases of the definition of scoring a scalar prediction against a dist answer. | |
| module KlDivergence = { | |
| ... | |
| } | |
| module LogScoreAgainstScalarAnswer = { | |
| let score = (prediction, answer) => ... | |
| let scoreWithPrior = (prediction, answer, prior) => ... | |
| } | |
| module T = { | |
| let score = (args: scoreArgs) => | |
| switch args { | |
| DistDist(prediction, answer) => KlDivergence.score(prediction, answer) | |
| DistFloat(prediction, answer) => LogScoreAgainstScalarAnswer.score(prediction, answer) | |
| DistDistDist(prediction, answer, prior) => KlDivergence.score(prediction, answer) - KlDivergence.score(prior, answer) | |
| DistFloatDist(prediction, answer, prior) => LogScoreAgainstScalarAnswer.scoreWithPrior(prediction, answer, prior) | |
| } | |
| } |
This is better, but I think it could be made better still.
Maybe something like,
type zeroToOne = float // enforce is between 0 and 1.
type abstractScore('a,'b) = {estimate:'a, prior:option<'a>, result:'b}
type distEstimateDistResult = abstractScore(pointSetDist, pointSetDist)
type distEstimatePointResult = abstractScore(pointSetDist, float)
type pointEstimatePointResult = abstractScore(zeroToOne, zeroToOne)
type scoreArgs = DistEstimateDistResult(distEstimateDistResult) | DistEstimatePointResult(distEstimatePointResult) | DointEstimatePointResult(pointEstimatePointResult)
type distOrFloat = #Dist(pointSetDist) | #Float(float)
let makeScoreArgs=(~estimate:distOrFloat, ~prior:option<distOrFloat>, ~result<distOrFloat>) =>
switch(estimate, prior, result){
}...
Actually, maybe use the word "answer" instead of result, to separate it from the Rescript result
well done.
thanks!
me in slack:
the main change in philosophy is importing the type
PoitnSetTypes.pointSetDistand it's constructors into the scoring file, instead of making the scoring file unaware
also:
- I'll be moving integration logic into scoring file now, too.
the main change in philosophy is importing the type PoitnSetTypes.pointSetDist and it's constructors into the scoring file, instead of making the scoring file unaware
I don't see much of that here, but I'm happy for the scoring file to be dependent on PoitnSetTypes.pointSetDist, if that's what you mean.
I'll be moving integration logic into scoring file now, too.
Moving lots to the scoring file seems good to me
. the typeT.scoreis the only export of this file (tho enforcing that with.resifile may be overkill)scoreArgsand constructors must also be exported, along withT.score