public static Booster LoadFromModelString(string modelString) { BoosterHandle bh = LoadModelFromString(modelString); var booster = new Booster(bh); return(booster); }
/// <summary> /// Prediction task /// </summary> /// <param name="fileName">Model file name</param> public Booster(string fileName) { int numIterations = 0; _handle = CreateFromModelfile(fileName, out numIterations); _numClasses = GetNumClasses(); _needReloadEvalInfo = true; }
/// <summary> /// Training task /// </summary> public Booster(Dataset trainSet, string parameters = "") { _handle = Create(trainSet.Handle, parameters); _evalNames = GetEvalNames(); _trainSet = trainSet; _numDatasets = 1; _parameters = parameters; _numClasses = GetNumClasses(); _needReloadEvalInfo = true; }
public static extern int LGBM_BoosterGetCurrentIteration(BoosterHandle handle, out int out_iteration);
public static extern int LGBM_BoosterUpdateOneIterCustom(BoosterHandle handle, ref float grad, ref float hess, ref int is_finished);
public static extern int LGBM_BoosterGetNumClasses(BoosterHandle handle, out int out_len);
public static extern int LGBM_BoosterResetTrainingData(BoosterHandle handle, DatasetHandle train_data);
public static extern int LGBM_BoosterMerge(BoosterHandle handle, BoosterHandle other_handle);
public static extern int LGBM_BoosterSetLeafValue(BoosterHandle handle, int tree_idx, int leaf_idx, double val);
public static extern int LGBM_BoosterGetPredict(BoosterHandle handle, int data_idx, out int out_len, out double[] out_result);
public static extern int LGBM_BoosterGetNumPredict(BoosterHandle handle, int data_idx, out int out_len);
public static extern int LGBM_BoosterCreate(DatasetHandle train_data, [In][MarshalAs(UnmanagedType.LPStr)] string parameters, out BoosterHandle @out);
public static extern int LGBM_BoosterGetEval(BoosterHandle handle, int data_idx, out int out_len, double[] out_results);
public static extern int LGBM_BoosterGetNumFeature(BoosterHandle handle, out int out_len);
public static extern int LGBM_BoosterGetFeatureNames(BoosterHandle handle, out int out_len, IntPtr out_strs);
public static extern int LGBM_BoosterLoadModelFromString([In][MarshalAs(UnmanagedType.LPStr)] string model_str, out int out_num_iterations, out BoosterHandle @out);
public static extern int LGBM_BoosterGetLeafValue(BoosterHandle handle, int tree_idx, int leaf_idx, out double out_val);
public static extern int LGBM_BoosterPredictForFile(BoosterHandle handle, [In][MarshalAs(UnmanagedType.LPStr)] string data_filename, [MarshalAs(UnmanagedType.I4)] bool data_has_header, LGBMPredictType predict_type, int num_iteration, [In][MarshalAs(UnmanagedType.LPStr)] string parameter, [In][MarshalAs(UnmanagedType.LPStr)] string result_filename);
public static extern int LGBM_BoosterFeatureImportance(BoosterHandle handle, int num_iteration, int importance_type, ref double out_results);
public static extern int LGBM_BoosterCalcNumPredict(BoosterHandle handle, int num_row, LGBMPredictType predict_type, int num_iteration, out int out_len);
public static extern int LGBM_BoosterAddValidData(BoosterHandle handle, DatasetHandle valid_data);
public static extern int LGBM_BoosterPredictForCSC(BoosterHandle handle, IntPtr col_ptr, int col_ptr_type, ref int indices, IntPtr data, int data_type, int numCols_ptr, int nelem, int num_row, int predict_type, int num_iteration, [In][MarshalAs(UnmanagedType.LPStr)] string parameter, ref int out_len, ref double out_result);
public static extern int LGBM_BoosterResetParameter(BoosterHandle handle, [In][MarshalAs(UnmanagedType.LPStr)] string parameters);
public static extern int LGBM_BoosterCreateFromModelfile([In][MarshalAs(UnmanagedType.LPStr)] string filename, out int out_num_iterations, out BoosterHandle @out);
public static extern int LGBM_BoosterUpdateOneIter(BoosterHandle handle, out int is_finished);
public static extern int LGBM_BoosterPredictForMat(BoosterHandle handle, IntPtr data, LGBMDataType data_type, int numRows, int numCols, int is_row_major, LGBMPredictType predict_type, int num_iteration, [In][MarshalAs(UnmanagedType.LPStr)] string parameter, out int out_len, IntPtr out_result);
public static extern int LGBM_BoosterRollbackOneIter(BoosterHandle handle);
public static extern int LGBM_BoosterSaveModel(BoosterHandle handle, int num_iteration, [In][MarshalAs(UnmanagedType.LPStr)] string filename);
public static extern int LGBM_BoosterGetEvalCounts(BoosterHandle handle, out int out_len);
public static extern int LGBM_BoosterDumpModel(BoosterHandle handle, int num_iteration, int buffer_len, out int out_len, [MarshalAs(UnmanagedType.LPStr)] StringBuilder out_str);