Can't pass in memory data to AutoML, in F#. Not understanding why it doesn't compile

59 Views Asked by At

I'm trying to do the code equivalent of:

mlnet classification --dataset output.csv --label-col 0 --has-header true --name test --train-time 300

and here is the code:

    let data = ctx.Data.LoadFromEnumerable(input)

    let preprocessingPipeline =
        EstimatorChain()
            .Append(ctx.Transforms.Concatenate("Features", h))

    let autoMLEstimator = ctx.Auto().Regression(labelColumnName = labelName)

    let toIEstimator (est: 'a) =
        est :> obj :?> IEstimator<ITransformer>

    let pipeline =
        (preprocessingPipeline |> toIEstimator)
            .Append(autoMLEstimator)

    let experiment = ctx.Auto().CreateExperiment()

    let x =
        experiment
            .SetPipeline(pipeline)
            .SetRegressionMetric(RegressionMetric.RSquared, labelName)
            .SetTrainingTimeInSeconds(60u)
            .SetDataset(data)

    ctx.Log.Add (fun e ->
        if e.Source.Equals("AutoMLExperiment") then
            info(e.RawMessage)
        )

    let! r = experiment.RunAsync()

my data looks like this:

outcome,side,open0,high0,low0,close0,volume0,open1,high1,low1,close1,volume1,open2,high2,low2,close2,volume2,open3,high3,low3,close3,volume3,open4,high4,low4,close4,volume4,open5,high5,low5,close5,volume5,open6,high6,low6,close6,volume6,open7,high7,low7,close7,volume7,open8,high8,low8,close8,volume8,open9,high9,low9,close9,volume9,open10,high10,low10,close10,volume10,open11,high11,low11,close11,volume11,open12,high12,low12,close12,volume12,open13,high13,low13,close13,volume13,open14,high14,low14,close14,volume14,open15,high15,low15,close15,volume15,open16,high16,low16,close16,volume16,open17,high17,low17,close17,volume17,open18,high18,low18,close18,volume18,open19,high19,low19,close19,volume19,fairPrice,lgH0,lgL0,lgH1,lgL1,obH0,obL0,obH1,obL1,hh0,lh0,hl0,ll0,hh1,lh1,hl1,ll1,bosi0,bose0,coc0,mss0,bosi1,bose1,coc1,mss1
0,1,0.00038689,0.00027194,0.00037486,0.00027194,0.14213674,-0.00025391,0.00012693,0.00007257,0.00038689,0.08160254,0.00001209,-0.00024781,-0.00036884,-0.00025391,-0.72704983,0.00068935,0.00026594,0.00058659,0.00001813,0.65746486,-0.00038706,0.00029624,0.00025409,0.00068331,-0.44333351,0.00006047,-0.00013906,-0.00048998,-0.00039311,0.13539082,0.00025401,0.00020558,0.00038712,0.00006652,-0.14805269,0.00037508,0.00004838,0.00048411,0.00025401,-0.19657870,0.00107764,0.00058072,0.00074478,0.00038114,0.61588007,0.00026656,0.00073243,0.00027262,0.00107159,0.10532012,0.00000000,0.00061177,0.00044847,0.00026656,-0.39257118,0.00009089,-0.00013329,-0.00031516,0.00000606,0.42989314,-0.00078138,-0.00074488,-0.00004848,0.00007877,0.02879348,0.00032702,0.00018768,-0.00019389,-0.00076927,-0.18632163,-0.00055707,-0.00055689,-0.00026048,0.00031490,-0.39727989,-0.00003632,0.00005446,-0.00026041,-0.00055707,0.26177475,0.00035115,0.00006052,0.00118147,-0.00003632,-0.60393262,-0.00052063,0.00000605,0.00043052,0.00035720,-0.92751914,-0.00075019,-0.00088323,-0.00175126,-0.00051457,0.67730415,-0.00030838,-0.00027207,-0.00111339,-0.00075624,1.75399160,-1.00000000,-0.00246765,-1.00000000,-0.00261879,-1.00000000,-1.00000000,-1.00000000,-1.00000000,-1.00000000,-1.00000000,-1.00000000,-1.00000000,-1.00000000,0.00000000,0.00000000,0.00000000,0.00000000,0.00000000,0.00000000,0.00000000,0.00000000

The data type is:

    [<CLIMutable>]
    type ModelInput =
        {
            Outcome   : bool
            Side      : float32
            Open0     : float32;    High0     : float32;    Low0      : float32;    Close0    : float32;    Volume0   : float32
            Open1     : float32;    High1     : float32;    Low1      : float32;    Close1    : float32;    Volume1   : float32
            Open2     : float32;    High2     : float32;    Low2      : float32;    Close2    : float32;    Volume2   : float32
            Open3     : float32;    High3     : float32;    Low3      : float32;    Close3    : float32;    Volume3   : float32
            Open4     : float32;    High4     : float32;    Low4      : float32;    Close4    : float32;    Volume4   : float32
            Open5     : float32;    High5     : float32;    Low5      : float32;    Close5    : float32;    Volume5   : float32
            Open6     : float32;    High6     : float32;    Low6      : float32;    Close6    : float32;    Volume6   : float32
            Open7     : float32;    High7     : float32;    Low7      : float32;    Close7    : float32;    Volume7   : float32
            Open8     : float32;    High8     : float32;    Low8      : float32;    Close8    : float32;    Volume8   : float32
            Open9     : float32;    High9     : float32;    Low9      : float32;    Close9    : float32;    Volume9   : float32
            Open10    : float32;    High10    : float32;    Low10     : float32;    Close10   : float32;    Volume10  : float32
            Open11    : float32;    High11    : float32;    Low11     : float32;    Close11   : float32;    Volume11  : float32
            Open12    : float32;    High12    : float32;    Low12     : float32;    Close12   : float32;    Volume12  : float32
            Open13    : float32;    High13    : float32;    Low13     : float32;    Close13   : float32;    Volume13  : float32
            Open14    : float32;    High14    : float32;    Low14     : float32;    Close14   : float32;    Volume14  : float32
            Open15    : float32;    High15    : float32;    Low15     : float32;    Close15   : float32;    Volume15  : float32
            Open16    : float32;    High16    : float32;    Low16     : float32;    Close16   : float32;    Volume16  : float32
            Open17    : float32;    High17    : float32;    Low17     : float32;    Close17   : float32;    Volume17  : float32
            Open18    : float32;    High18    : float32;    Low18     : float32;    Close18   : float32;    Volume18  : float32
            Open19    : float32;    High19    : float32;    Low19     : float32;    Close19   : float32;    Volume19  : float32
            FairPrice : float32
            LgH0      : float32;    LgL0      : float32;    LgH1      : float32;    LgL1      : float32
            ObH0      : float32;    ObL0      : float32;    ObH1      : float32;    ObL1      : float32
            Hh0       : float32;    Lh0       : float32;    Hl0       : float32;    Ll0       : float32
            Hh1       : float32;    Lh1       : float32;    Hl1       : float32;    Ll1       : float32
            Bosi0     : float32;    Bose0     : float32;    Coc0      : float32;    Mss0      : float32
            Bosi1     : float32;    Bose1     : float32;    Coc1      : float32;    Mss1      : float32
        }

and the compile error is:

The type 'ML.Data.EstimatorChain<ML.Data.ColumnConcatenatingTransformer>' does not match the type 'ModelInput'

What I want is to use an in memory data list where, for each entry one field is the label, every other field are features; every field is a float32.

And I'd like to use AutoML where it tries the different algorithms and provides a model.

0

There are 0 best solutions below