Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FsCatBoost

An F# thin wrapper around CatBoost API.

Example taken from CatBoostNetTests.

result {
    let dsPath = Path.Combine(CatBoostNet.directory, @"mushrooms\mushrooms.csv")
    let modelPath = Path.Combine(CatBoostNet.directory, @"mushrooms\mushroom_model.cbm")
            
    let df = Frame.ReadCsv(dsPath, hasHeaders = false)
    let target =
        df.Rows.Select(_.Value["Column1"]).Values
        |> Seq.map string
        |> Seq.toArray

    df.DropColumn("Column1")
    let data = df.ToArray2D<string>()
    let floatFeatures = Array2D.zeroCreate (data.GetLength(0)) 0 
            
    use! model =
        modelCalcerCreate ()
        |> loadFullModelFromFile modelPath
            
    let! res = calcModelPrediction floatFeatures data model
            
    let targetLabelList = [| "e"; "p" |]
            
    [| 0 .. res.GetLength(0) - 1 |]
    |> Array.iter (fun i ->
        let argmax = if res[i, 0] > 0 then 1 else 0
        let predLabel = targetLabelList[argmax]
                
        predLabel.Should().Be(target[i], $"Mushroom test crashed on sample {i + 1}") |> ignore)
}
|> Result.mapError (fun e ->
    output.WriteLine(e)
    Assert.Fail())

About

F# thin wrapper around CatBoost API.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages