c# kaggle higgs demo drafted
This commit is contained in:
parent
2587da5fea
commit
b208338098
@ -11,15 +11,33 @@ namespace xgboost_sharp_wrapper
|
|||||||
|
|
||||||
public class xgboost
|
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 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);
|
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")]
|
[DllImport(dll_path + "xgboost_wrapper.dll")]
|
||||||
public static extern IntPtr XGBoosterCreate(IntPtr[] dmats, System.UInt32 len);
|
public static extern IntPtr XGBoosterCreate(IntPtr[] dmats, System.UInt32 len);
|
||||||
public IntPtr SharpXGBoosterCreate(IntPtr[] dmats, System.UInt32 len)
|
public IntPtr SharpXGBoosterCreate(IntPtr[] dmats, System.UInt32 len)
|
||||||
@ -42,13 +60,13 @@ public IntPtr SharpXGDMatrixCreateFromFile(string fname, int silent)
|
|||||||
{
|
{
|
||||||
return XGBoosterEvalOneIter(handle, iter, dmats, evnames, len);
|
return XGBoosterEvalOneIter(handle, iter, dmats, evnames, len);
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief make prediction based on dmat
|
* \brief make prediction based on dmat
|
||||||
* \param handle handle
|
* \param handle handle
|
||||||
* \param dmat data matrix
|
* \param dmat data matrix
|
||||||
* \param output_margin whether only output raw margin value
|
* \param output_margin whether only output raw margin value
|
||||||
* \param len used to store length of returning result
|
* \param len used to store length of returning result
|
||||||
*/
|
*/
|
||||||
[DllImport(dll_path + "xgboost_wrapper.dll")]
|
[DllImport(dll_path + "xgboost_wrapper.dll")]
|
||||||
public static extern IntPtr XGBoosterPredict(IntPtr handle, IntPtr dmat, int output_margin, ref System.UInt32 len);
|
public static extern IntPtr XGBoosterPredict(IntPtr handle, IntPtr dmat, int output_margin, ref System.UInt32 len);
|
||||||
|
|
||||||
@ -62,27 +80,27 @@ public IntPtr SharpXGDMatrixCreateFromFile(string fname, int silent)
|
|||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief load model from existing file
|
* \brief load model from existing file
|
||||||
* \param handle handle
|
* \param handle handle
|
||||||
* \param fname file name
|
* \param fname file name
|
||||||
*/
|
*/
|
||||||
[DllImport(dll_path + "xgboost_wrapper.dll")]
|
[DllImport(dll_path + "xgboost_wrapper.dll")]
|
||||||
public static extern void XGBoosterLoadModel(IntPtr handle, string fname);
|
public static extern void XGBoosterLoadModel(IntPtr handle, string fname);
|
||||||
/*!
|
/*!
|
||||||
* \brief save model into existing file
|
* \brief save model into existing file
|
||||||
* \param handle handle
|
* \param handle handle
|
||||||
* \param fname file name
|
* \param fname file name
|
||||||
*/
|
*/
|
||||||
[DllImport(dll_path + "xgboost_wrapper.dll")]
|
[DllImport(dll_path + "xgboost_wrapper.dll")]
|
||||||
public static extern void XGBoosterSaveModel(IntPtr handle, string fname);
|
public static extern void XGBoosterSaveModel(IntPtr handle, string fname);
|
||||||
/*!
|
/*!
|
||||||
* \brief dump model, return array of strings representing model dump
|
* \brief dump model, return array of strings representing model dump
|
||||||
* \param handle handle
|
* \param handle handle
|
||||||
* \param fmap name to fmap can be empty string
|
* \param fmap name to fmap can be empty string
|
||||||
* \param out_len length of output array
|
* \param out_len length of output array
|
||||||
* \return char *data[], representing dump of each model
|
* \return char *data[], representing dump of each model
|
||||||
*/
|
*/
|
||||||
[DllImport(dll_path + "xgboost_wrapper.dll")]
|
[DllImport(dll_path + "xgboost_wrapper.dll")]
|
||||||
public static extern string XGBoosterDumpModel(IntPtr handle, string fmap,
|
public static extern string XGBoosterDumpModel(IntPtr handle, string fmap,
|
||||||
System.UInt32 out_len);
|
System.UInt32 out_len);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user