a few comments more
This commit is contained in:
parent
d156b24fd1
commit
1a6ced0373
|
@ -183,18 +183,8 @@ module Score = {
|
||||||
->PointSetDist_Scoring.DistEstimateScalarAnswer
|
->PointSetDist_Scoring.DistEstimateScalarAnswer
|
||||||
->Ok
|
->Ok
|
||||||
)
|
)
|
||||||
| (Score_Scalar(esti'), Score_Dist(answ'), None) =>
|
| (Score_Scalar(_), Score_Dist(_), None) => NotYetImplemented->Error
|
||||||
toPointSetFn(answ')->E.R.bind(answ'' =>
|
| (Score_Scalar(_), Score_Dist(_), Some(Ok(PSScalar(_)))) => NotYetImplemented->Error
|
||||||
{estimate: esti', answer: answ'', prior: None}
|
|
||||||
->PointSetDist_Scoring.ScalarEstimateDistAnswer
|
|
||||||
->Ok
|
|
||||||
)
|
|
||||||
| (Score_Scalar(esti'), Score_Dist(answ'), Some(Ok(PSScalar(prior'')))) =>
|
|
||||||
toPointSetFn(answ')->E.R.bind(answ'' =>
|
|
||||||
{estimate: esti', answer: answ'', prior: Some(prior'')}
|
|
||||||
->PointSetDist_Scoring.ScalarEstimateDistAnswer
|
|
||||||
->Ok
|
|
||||||
)
|
|
||||||
| (Score_Scalar(_), _, Some(Ok(PSDist(_)))) => DistributionTypes.Unreachable->Error
|
| (Score_Scalar(_), _, Some(Ok(PSDist(_)))) => DistributionTypes.Unreachable->Error
|
||||||
| (Score_Scalar(esti'), Score_Scalar(answ'), None) =>
|
| (Score_Scalar(esti'), Score_Scalar(answ'), None) =>
|
||||||
{estimate: esti', answer: answ', prior: None}
|
{estimate: esti', answer: answ', prior: None}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
type pointSetDist = PointSetTypes.pointSetDist
|
type pointSetDist = PointSetTypes.pointSetDist
|
||||||
|
|
||||||
type scalar = float
|
type scalar = float
|
||||||
|
type score = float
|
||||||
type abstractScoreArgs<'a, 'b> = {estimate: 'a, answer: 'b, prior: option<'a>}
|
type abstractScoreArgs<'a, 'b> = {estimate: 'a, answer: 'b, prior: option<'a>}
|
||||||
type scoreArgs =
|
type scoreArgs =
|
||||||
| DistEstimateDistAnswer(abstractScoreArgs<pointSetDist, pointSetDist>)
|
| DistEstimateDistAnswer(abstractScoreArgs<pointSetDist, pointSetDist>)
|
||||||
| DistEstimateScalarAnswer(abstractScoreArgs<pointSetDist, scalar>)
|
| DistEstimateScalarAnswer(abstractScoreArgs<pointSetDist, scalar>)
|
||||||
| ScalarEstimateDistAnswer(abstractScoreArgs<scalar, pointSetDist>)
|
|
||||||
| ScalarEstimateScalarAnswer(abstractScoreArgs<scalar, scalar>)
|
| ScalarEstimateScalarAnswer(abstractScoreArgs<scalar, scalar>)
|
||||||
|
|
||||||
let logFn = Js.Math.log // base e
|
let logFn = Js.Math.log // base e
|
||||||
|
@ -35,7 +35,7 @@ module WithDistAnswer = {
|
||||||
~combineFn,
|
~combineFn,
|
||||||
~integrateFn,
|
~integrateFn,
|
||||||
~toMixedFn,
|
~toMixedFn,
|
||||||
): result<float, Operation.Error.t> => {
|
): result<score, Operation.Error.t> => {
|
||||||
let combineAndIntegrate = (estimate, answer) =>
|
let combineAndIntegrate = (estimate, answer) =>
|
||||||
combineFn(integrand, estimate, answer)->E.R2.fmap(integrateFn)
|
combineFn(integrand, estimate, answer)->E.R2.fmap(integrateFn)
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ module WithDistAnswer = {
|
||||||
~combineFn,
|
~combineFn,
|
||||||
~integrateFn,
|
~integrateFn,
|
||||||
~toMixedFn,
|
~toMixedFn,
|
||||||
): result<float, Operation.Error.t> => {
|
): result<score, Operation.Error.t> => {
|
||||||
let kl1 = sum(~estimate, ~answer, ~combineFn, ~integrateFn, ~toMixedFn)
|
let kl1 = sum(~estimate, ~answer, ~combineFn, ~integrateFn, ~toMixedFn)
|
||||||
let kl2 = sum(~estimate=prior, ~answer, ~combineFn, ~integrateFn, ~toMixedFn)
|
let kl2 = sum(~estimate=prior, ~answer, ~combineFn, ~integrateFn, ~toMixedFn)
|
||||||
E.R.merge(kl1, kl2)->E.R2.fmap(((kl1', kl2')) => kl1' -. kl2')
|
E.R.merge(kl1, kl2)->E.R2.fmap(((kl1', kl2')) => kl1' -. kl2')
|
||||||
|
@ -92,9 +92,9 @@ module WithDistAnswer = {
|
||||||
|
|
||||||
module WithScalarAnswer = {
|
module WithScalarAnswer = {
|
||||||
let sum = (mp: PointSetTypes.MixedPoint.t): float => mp.continuous +. mp.discrete
|
let sum = (mp: PointSetTypes.MixedPoint.t): float => mp.continuous +. mp.discrete
|
||||||
let score = (~estimate: pointSetDist, ~answer: scalar): result<float, Operation.Error.t> => {
|
let score = (~estimate: pointSetDist, ~answer: scalar): result<score, Operation.Error.t> => {
|
||||||
let _score = (~estimatePdf: float => float, ~answer: float): result<
|
let _score = (~estimatePdf: float => float, ~answer: float): result<
|
||||||
float,
|
score,
|
||||||
Operation.Error.t,
|
Operation.Error.t,
|
||||||
> => {
|
> => {
|
||||||
let density = answer->estimatePdf
|
let density = answer->estimatePdf
|
||||||
|
@ -117,7 +117,7 @@ module WithScalarAnswer = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let scoreWithPrior = (~estimate: pointSetDist, ~answer: scalar, ~prior: pointSetDist): result<
|
let scoreWithPrior = (~estimate: pointSetDist, ~answer: scalar, ~prior: pointSetDist): result<
|
||||||
float,
|
score,
|
||||||
Operation.Error.t,
|
Operation.Error.t,
|
||||||
> => {
|
> => {
|
||||||
let _scoreWithPrior = (
|
let _scoreWithPrior = (
|
||||||
|
@ -178,7 +178,7 @@ let twoGenericDistsToTwoPointSetDists = (~toPointSetFn, estimate, answer): resul
|
||||||
> => E.R.merge(toPointSetFn(estimate, ()), toPointSetFn(answer, ()))
|
> => E.R.merge(toPointSetFn(estimate, ()), toPointSetFn(answer, ()))
|
||||||
|
|
||||||
let logScore = (args: scoreArgs, ~combineFn, ~integrateFn, ~toMixedFn): result<
|
let logScore = (args: scoreArgs, ~combineFn, ~integrateFn, ~toMixedFn): result<
|
||||||
float,
|
score,
|
||||||
Operation.Error.t,
|
Operation.Error.t,
|
||||||
> =>
|
> =>
|
||||||
switch args {
|
switch args {
|
||||||
|
@ -190,7 +190,6 @@ let logScore = (args: scoreArgs, ~combineFn, ~integrateFn, ~toMixedFn): result<
|
||||||
WithScalarAnswer.score(~estimate, ~answer)
|
WithScalarAnswer.score(~estimate, ~answer)
|
||||||
| DistEstimateScalarAnswer({estimate, answer, prior: Some(prior)}) =>
|
| DistEstimateScalarAnswer({estimate, answer, prior: Some(prior)}) =>
|
||||||
WithScalarAnswer.scoreWithPrior(~estimate, ~answer, ~prior)
|
WithScalarAnswer.scoreWithPrior(~estimate, ~answer, ~prior)
|
||||||
| ScalarEstimateDistAnswer(_) => Operation.NotYetImplemented->Error
|
|
||||||
| ScalarEstimateScalarAnswer({estimate, answer, prior: None}) =>
|
| ScalarEstimateScalarAnswer({estimate, answer, prior: None}) =>
|
||||||
TwoScalars.score(~estimate, ~answer)
|
TwoScalars.score(~estimate, ~answer)
|
||||||
| ScalarEstimateScalarAnswer({estimate, answer, prior: Some(prior)}) =>
|
| ScalarEstimateScalarAnswer({estimate, answer, prior: Some(prior)}) =>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user