FunctionRegistry examples should be an array
This commit is contained in:
parent
c3b0009fb8
commit
3c396e0ccc
|
@ -50,7 +50,7 @@ type fnDefinition = {
|
||||||
type function = {
|
type function = {
|
||||||
name: string,
|
name: string,
|
||||||
definitions: array<fnDefinition>,
|
definitions: array<fnDefinition>,
|
||||||
examples: option<string>,
|
examples: array<string>,
|
||||||
description: option<string>,
|
description: option<string>,
|
||||||
isExperimental: bool,
|
isExperimental: bool,
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ module Function = {
|
||||||
type functionJson = {
|
type functionJson = {
|
||||||
name: string,
|
name: string,
|
||||||
definitions: array<string>,
|
definitions: array<string>,
|
||||||
examples: option<string>,
|
examples: array<string>,
|
||||||
description: option<string>,
|
description: option<string>,
|
||||||
isExperimental: bool,
|
isExperimental: bool,
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ module Function = {
|
||||||
let make = (~name, ~definitions, ~examples=?, ~description=?, ~isExperimental=false, ()): t => {
|
let make = (~name, ~definitions, ~examples=?, ~description=?, ~isExperimental=false, ()): t => {
|
||||||
name: name,
|
name: name,
|
||||||
definitions: definitions,
|
definitions: definitions,
|
||||||
examples: examples,
|
examples: examples |> E.O.default([]),
|
||||||
isExperimental: isExperimental,
|
isExperimental: isExperimental,
|
||||||
description: description,
|
description: description,
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,28 +30,29 @@ module Declaration = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let inputsTodist = (inputs: array<FunctionRegistry_Core.frValue>, makeDist) => {
|
|
||||||
let array = inputs->getOrError(0)->E.R.bind(Prepare.ToValueArray.Array.openA)
|
|
||||||
let xyCoords =
|
|
||||||
array->E.R.bind(xyCoords =>
|
|
||||||
xyCoords
|
|
||||||
->E.A2.fmap(xyCoord =>
|
|
||||||
[xyCoord]->Prepare.ToValueArray.Record.twoArgs->E.R.bind(Prepare.ToValueTuple.twoNumbers)
|
|
||||||
)
|
|
||||||
->E.A.R.firstErrorOrOpen
|
|
||||||
)
|
|
||||||
let expressionValue =
|
|
||||||
xyCoords
|
|
||||||
->E.R.bind(r => r->XYShape.T.makeFromZipped->E.R2.errMap(XYShape.Error.toString))
|
|
||||||
->E.R2.fmap(r => ReducerInterface_InternalExpressionValue.IEvDistribution(
|
|
||||||
PointSet(makeDist(r)),
|
|
||||||
))
|
|
||||||
expressionValue
|
|
||||||
}
|
|
||||||
|
|
||||||
module PointSet = {
|
module PointSet = {
|
||||||
let nameSpace = Some("PointSet")
|
let nameSpace = Some("PointSet")
|
||||||
let requiresNamespace = true
|
let requiresNamespace = true
|
||||||
|
|
||||||
|
let inputsTodist = (inputs: array<FunctionRegistry_Core.frValue>, makeDist) => {
|
||||||
|
let array = inputs->getOrError(0)->E.R.bind(Prepare.ToValueArray.Array.openA)
|
||||||
|
let xyCoords =
|
||||||
|
array->E.R.bind(xyCoords =>
|
||||||
|
xyCoords
|
||||||
|
->E.A2.fmap(xyCoord =>
|
||||||
|
[xyCoord]->Prepare.ToValueArray.Record.twoArgs->E.R.bind(Prepare.ToValueTuple.twoNumbers)
|
||||||
|
)
|
||||||
|
->E.A.R.firstErrorOrOpen
|
||||||
|
)
|
||||||
|
let expressionValue =
|
||||||
|
xyCoords
|
||||||
|
->E.R.bind(r => r->XYShape.T.makeFromZipped->E.R2.errMap(XYShape.Error.toString))
|
||||||
|
->E.R2.fmap(r => ReducerInterface_InternalExpressionValue.IEvDistribution(
|
||||||
|
PointSet(makeDist(r)),
|
||||||
|
))
|
||||||
|
expressionValue
|
||||||
|
}
|
||||||
|
|
||||||
let library = [
|
let library = [
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="PointSet.makeContinuous",
|
~name="PointSet.makeContinuous",
|
||||||
|
@ -90,13 +91,15 @@ module Functionn = {
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Function.declare",
|
~name="Function.declare",
|
||||||
~description="Adds metadata to a function of the input ranges. Works now for numeric and date inputs. This is useful when making predictions. It allows you to limit the domain that your prediction will be used and scored within.",
|
~description="Adds metadata to a function of the input ranges. Works now for numeric and date inputs. This is useful when making predictions. It allows you to limit the domain that your prediction will be used and scored within.",
|
||||||
~examples=`declareFn({
|
~examples=[
|
||||||
|
`declareFn({
|
||||||
fn: {|a,b| a },
|
fn: {|a,b| a },
|
||||||
inputs: [
|
inputs: [
|
||||||
{min: 0, max: 100},
|
{min: 0, max: 100},
|
||||||
{min: 30, max: 50}
|
{min: 30, max: 50}
|
||||||
]
|
]
|
||||||
})`,
|
})`,
|
||||||
|
],
|
||||||
~isExperimental=true,
|
~isExperimental=true,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
|
@ -175,12 +178,11 @@ module DistributionCreation = {
|
||||||
(),
|
(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
let library = [
|
let library = [
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Normal",
|
~name="Normal",
|
||||||
~examples=`normal(5,1)
|
~examples=["normal(5,1)", "normal({p5: 4, p95: 10})", "normal({mean: 5, stdev: 2})"],
|
||||||
normal({p5: 4, p95: 10})
|
|
||||||
normal({mean: 5, stdev: 2})`,
|
|
||||||
~definitions=[
|
~definitions=[
|
||||||
TwoArgDist.make("normal", twoArgs(SymbolicDist.Normal.make)),
|
TwoArgDist.make("normal", twoArgs(SymbolicDist.Normal.make)),
|
||||||
TwoArgDist.makeRecordP5P95("normal", r =>
|
TwoArgDist.makeRecordP5P95("normal", r =>
|
||||||
|
@ -192,9 +194,11 @@ normal({mean: 5, stdev: 2})`,
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Lognormal",
|
~name="Lognormal",
|
||||||
~examples=`lognormal(0.5, 0.8)
|
~examples=[
|
||||||
lognormal({p5: 4, p95: 10})
|
"lognormal(0.5, 0.8)",
|
||||||
lognormal({mean: 5, stdev: 2})`,
|
"lognormal({p5: 4, p95: 10})",
|
||||||
|
"lognormal({mean: 5, stdev: 2})"
|
||||||
|
],
|
||||||
~definitions=[
|
~definitions=[
|
||||||
TwoArgDist.make("lognormal", twoArgs(SymbolicDist.Lognormal.make)),
|
TwoArgDist.make("lognormal", twoArgs(SymbolicDist.Lognormal.make)),
|
||||||
TwoArgDist.makeRecordP5P95("lognormal", r =>
|
TwoArgDist.makeRecordP5P95("lognormal", r =>
|
||||||
|
@ -209,14 +213,13 @@ lognormal({mean: 5, stdev: 2})`,
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Uniform",
|
~name="Uniform",
|
||||||
~examples=`uniform(10, 12)`,
|
~examples=[`uniform(10, 12)`],
|
||||||
~definitions=[TwoArgDist.make("uniform", twoArgs(SymbolicDist.Uniform.make))],
|
~definitions=[TwoArgDist.make("uniform", twoArgs(SymbolicDist.Uniform.make))],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Beta",
|
~name="Beta",
|
||||||
~examples=`beta(20, 25)
|
~examples=[`beta(20, 25)`, `beta({mean: 0.39, stdev: 0.1})`],
|
||||||
beta({mean: 0.39, stdev: 0.1})`,
|
|
||||||
~definitions=[
|
~definitions=[
|
||||||
TwoArgDist.make("beta", twoArgs(SymbolicDist.Beta.make)),
|
TwoArgDist.make("beta", twoArgs(SymbolicDist.Beta.make)),
|
||||||
TwoArgDist.makeRecordMeanStdev("beta", twoArgs(SymbolicDist.Beta.fromMeanAndStdev)),
|
TwoArgDist.makeRecordMeanStdev("beta", twoArgs(SymbolicDist.Beta.fromMeanAndStdev)),
|
||||||
|
@ -225,27 +228,25 @@ beta({mean: 0.39, stdev: 0.1})`,
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Cauchy",
|
~name="Cauchy",
|
||||||
~examples=`cauchy(5, 1)`,
|
~examples=[`cauchy(5, 1)`],
|
||||||
~definitions=[TwoArgDist.make("cauchy", twoArgs(SymbolicDist.Cauchy.make))],
|
~definitions=[TwoArgDist.make("cauchy", twoArgs(SymbolicDist.Cauchy.make))],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Gamma",
|
~name="Gamma",
|
||||||
~examples=`gamma(5, 1)`,
|
~examples=[`gamma(5, 1)`],
|
||||||
~definitions=[TwoArgDist.make("gamma", twoArgs(SymbolicDist.Gamma.make))],
|
~definitions=[TwoArgDist.make("gamma", twoArgs(SymbolicDist.Gamma.make))],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Logistic",
|
~name="Logistic",
|
||||||
~examples=`gamma(5, 1)`,
|
~examples=[`logistic(5, 1)`],
|
||||||
~definitions=[TwoArgDist.make("logistic", twoArgs(SymbolicDist.Logistic.make))],
|
~definitions=[TwoArgDist.make("logistic", twoArgs(SymbolicDist.Logistic.make))],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="To (Distribution)",
|
~name="To (Distribution)",
|
||||||
~examples=`5 to 10
|
~examples=[`5 to 10`, `to(5,10)`, `-5 to 5`],
|
||||||
to(5,10)
|
|
||||||
-5 to 5`,
|
|
||||||
~definitions=[
|
~definitions=[
|
||||||
TwoArgDist.make("to", twoArgs(SymbolicDist.From90thPercentile.make)),
|
TwoArgDist.make("to", twoArgs(SymbolicDist.From90thPercentile.make)),
|
||||||
TwoArgDist.make(
|
TwoArgDist.make(
|
||||||
|
@ -257,66 +258,25 @@ to(5,10)
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Exponential",
|
~name="Exponential",
|
||||||
~examples=`exponential(2)`,
|
~examples=[`exponential(2)`],
|
||||||
~definitions=[OneArgDist.make("exponential", SymbolicDist.Exponential.make)],
|
~definitions=[OneArgDist.make("exponential", SymbolicDist.Exponential.make)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Bernoulli",
|
~name="Bernoulli",
|
||||||
~examples=`bernoulli(0.5)`,
|
~examples=[`bernoulli(0.5)`],
|
||||||
~definitions=[OneArgDist.make("bernoulli", SymbolicDist.Bernoulli.make)],
|
~definitions=[OneArgDist.make("bernoulli", SymbolicDist.Bernoulli.make)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="PointMass",
|
~name="PointMass",
|
||||||
~examples=`pointMass(0.5)`,
|
~examples=[`pointMass(0.5)`],
|
||||||
~definitions=[OneArgDist.make("pointMass", SymbolicDist.Float.makeSafe)],
|
~definitions=[OneArgDist.make("pointMass", SymbolicDist.Float.makeSafe)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
let registryStart = [
|
|
||||||
Function.make(
|
|
||||||
~name="toContinuousPointSet",
|
|
||||||
~description="Converts a set of points to a continuous distribution",
|
|
||||||
~examples=`toContinuousPointSet([
|
|
||||||
{x: 0, y: 0.1},
|
|
||||||
{x: 1, y: 0.2},
|
|
||||||
{x: 2, y: 0.15},
|
|
||||||
{x: 3, y: 0.1}
|
|
||||||
])`,
|
|
||||||
~definitions=[
|
|
||||||
FnDefinition.make(
|
|
||||||
~name="toContinuousPointSet",
|
|
||||||
~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))],
|
|
||||||
~run=(_, inputs, _) => inputsTodist(inputs, r => Continuous(Continuous.make(r))),
|
|
||||||
(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
(),
|
|
||||||
),
|
|
||||||
Function.make(
|
|
||||||
~name="toDiscretePointSet",
|
|
||||||
~description="Converts a set of points to a discrete distribution",
|
|
||||||
~examples=`toDiscretePointSet([
|
|
||||||
{x: 0, y: 0.1},
|
|
||||||
{x: 1, y: 0.2},
|
|
||||||
{x: 2, y: 0.15},
|
|
||||||
{x: 3, y: 0.1}
|
|
||||||
])`,
|
|
||||||
~definitions=[
|
|
||||||
FnDefinition.make(
|
|
||||||
~name="toDiscretePointSet",
|
|
||||||
~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))],
|
|
||||||
~run=(_, inputs, _) => inputsTodist(inputs, r => Discrete(Discrete.make(r))),
|
|
||||||
(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
(),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
module Number = {
|
module Number = {
|
||||||
let nameSpace = Some("Number")
|
let nameSpace = Some("Number")
|
||||||
let requiresNamespace = false
|
let requiresNamespace = false
|
||||||
|
|
Loading…
Reference in New Issue
Block a user