diff --git a/windows/xgboost_sharp_wrapper/xgboost.cs b/windows/xgboost_sharp_wrapper/xgboost.cs index c1f07044b..ae5f3a205 100644 --- a/windows/xgboost_sharp_wrapper/xgboost.cs +++ b/windows/xgboost_sharp_wrapper/xgboost.cs @@ -7,19 +7,37 @@ using System.Runtime.InteropServices; namespace xgboost_sharp_wrapper { - - + + public class xgboost { - private const string dll_path="..\\x64\\Release\\"; + private const string dll_path = "..\\x64\\Release\\"; - [DllImport(dll_path+"xgboost_wrapper.dll", CallingConvention=CallingConvention.Cdecl)] + [DllImport(dll_path + "xgboost_wrapper.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr XGDMatrixCreateFromFile(string fname, int silent); -public IntPtr SharpXGDMatrixCreateFromFile(string fname, int silent) + public IntPtr SharpXGDMatrixCreateFromFile(string fname, int silent) { return XGDMatrixCreateFromFile(fname, silent); } + + /*! + * \brief set float vector to a content in info + * \param handle a instance of data matrix + * \param field field name, can be label, weight + * \param array pointer to float vector + * \param len length of array + */ + [DllImport(dll_path + "xgboost_wrapper.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void XGDMatrixSetFloatInfo(IntPtr handle, string field, IntPtr array, System.UInt32 len); + + [DllImport(dll_path + "xgboost_wrapper.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void XGBoosterSetParam(IntPtr handle, string name, string value); + public void SharpXGBoosterSetParam(IntPtr handle, string name, string value) + { + XGBoosterSetParam(handle,name,value); + } + [DllImport(dll_path + "xgboost_wrapper.dll")] public static extern IntPtr XGBoosterCreate(IntPtr[] dmats, System.UInt32 len); public IntPtr SharpXGBoosterCreate(IntPtr[] dmats, System.UInt32 len) @@ -42,47 +60,47 @@ public IntPtr SharpXGDMatrixCreateFromFile(string fname, int silent) { return XGBoosterEvalOneIter(handle, iter, dmats, evnames, len); } - /*! - * \brief make prediction based on dmat - * \param handle handle - * \param dmat data matrix - * \param output_margin whether only output raw margin value - * \param len used to store length of returning result - */ + /*! + * \brief make prediction based on dmat + * \param handle handle + * \param dmat data matrix + * \param output_margin whether only output raw margin value + * \param len used to store length of returning result + */ [DllImport(dll_path + "xgboost_wrapper.dll")] public static extern IntPtr XGBoosterPredict(IntPtr handle, IntPtr dmat, int output_margin, ref System.UInt32 len); - + public float[] SharpXGBoosterPredict(IntPtr handle, IntPtr dmat, int output_margin, System.UInt32 len) { IntPtr buf = XGBoosterPredict(handle, dmat, output_margin, ref len); - + float[] buffer = new float[len]; Marshal.Copy(buf, buffer, 0, buffer.Length); return buffer; } - /*! - * \brief load model from existing file - * \param handle handle - * \param fname file name - */ + /*! + * \brief load model from existing file + * \param handle handle + * \param fname file name + */ [DllImport(dll_path + "xgboost_wrapper.dll")] public static extern void XGBoosterLoadModel(IntPtr handle, string fname); - /*! - * \brief save model into existing file - * \param handle handle - * \param fname file name - */ + /*! + * \brief save model into existing file + * \param handle handle + * \param fname file name + */ [DllImport(dll_path + "xgboost_wrapper.dll")] public static extern void XGBoosterSaveModel(IntPtr handle, string fname); - /*! - * \brief dump model, return array of strings representing model dump - * \param handle handle - * \param fmap name to fmap can be empty string - * \param out_len length of output array - * \return char *data[], representing dump of each model - */ + /*! + * \brief dump model, return array of strings representing model dump + * \param handle handle + * \param fmap name to fmap can be empty string + * \param out_len length of output array + * \return char *data[], representing dump of each model + */ [DllImport(dll_path + "xgboost_wrapper.dll")] public static extern string XGBoosterDumpModel(IntPtr handle, string fmap, System.UInt32 out_len);