public Booster(Parameters parameters, Dataset trainset, Dataset validset = null) { var param = parameters.ToString(); var handle = IntPtr.Zero; PInvokeException.Check(PInvoke.BoosterCreate(trainset.Handle, param, ref handle), nameof(PInvoke.BoosterCreate)); Handle = handle; if (validset != null) { PInvokeException.Check(PInvoke.BoosterAddValidData(handle, validset.Handle), nameof(PInvoke.BoosterAddValidData)); _hasValid = true; } BestIteration = -1; int numEval = this.EvalCounts; // At most one metric in ML.NET: to do remove this. if (numEval > 1) { throw new Exception($"Expected at most one metric, got {numEval}"); } else if (numEval == 1) { _hasMetric = true; } }
public Booster(Parameters parameters, Dataset trainset, Dataset validset = null) { if (trainset.CommonParameters != parameters.Common) throw new Exception("CommonParameters differ from those used to create training set"); if (trainset.DatasetParameters != parameters.Dataset) throw new Exception("DatasetParameters differ from those used to create training set"); if (validset != null) { if (validset.CommonParameters != parameters.Common) throw new Exception("CommonParameters differ from those used to create validation set"); if (validset.DatasetParameters != parameters.Dataset) throw new Exception("DatasetParameters differ from those used to create validation set"); } var param = parameters.ToString(); var handle = IntPtr.Zero; PInvokeException.Check(PInvoke.BoosterCreate(trainset.Handle, param, ref handle),nameof(PInvoke.BoosterCreate)); Handle = handle; if (validset != null) { PInvokeException.Check(PInvoke.BoosterAddValidData(handle, validset.Handle),nameof(PInvoke.BoosterAddValidData)); _hasValid = true; } BestIteration = -1; int numEval = this.EvalCounts; // At most one metric in ML.NET: to do remove this. if (numEval > 1) throw new Exception($"Expected at most one metric, got {numEval}"); else if (numEval == 1) _hasMetric = true; }