diff --git a/windows/xgboost_sharp_wrapper/Properties/AssemblyInfo.cs b/windows/xgboost_sharp_wrapper/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..1baa42aea --- /dev/null +++ b/windows/xgboost_sharp_wrapper/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Le informazioni generali relative a un assembly sono controllate dal seguente +// set di attributi. Per modificare le informazioni associate a un assembly +// occorre quindi modificare i valori di questi attributi. +[assembly: AssemblyTitle("xgboost_sharp_wrapper")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("xgboost_sharp_wrapper")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili +// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da +// COM, impostare su true l'attributo ComVisible per tale tipo. +[assembly: ComVisible(false)] + +// Se il progetto viene esposto a COM, il GUID che segue verrà utilizzato per creare l'ID della libreria dei tipi +[assembly: Guid("accc4026-fa8e-41d8-aaa8-1ca69c2b2db5")] + +// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori: +// +// Numero di versione principale +// Numero di versione secondario +// Numero build +// Revisione +// +// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build +// utilizzando l'asterisco (*) come descritto di seguito: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/windows/xgboost_sharp_wrapper/xgboost.cs b/windows/xgboost_sharp_wrapper/xgboost.cs new file mode 100644 index 000000000..560fb1412 --- /dev/null +++ b/windows/xgboost_sharp_wrapper/xgboost.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Runtime.InteropServices; + +namespace xgboost_sharp_wrapper +{ + + + public class xgboost + { + private const string dll_path="..\\x64\\Release\\"; + + [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) + { + return XGDMatrixCreateFromFile(fname, silent); + } + + [DllImport(dll_path + "xgboost_wrapper.dll")] + public static extern IntPtr XGBoosterCreate(IntPtr[] dmats, System.UInt32 len); + + [DllImport(dll_path + "xgboost_wrapper.dll")] + public static extern void XGBoosterUpdateOneIter(IntPtr handle, int iter, IntPtr dtrain); + + [DllImport(dll_path + "xgboost_wrapper.dll")] + public static extern string XGBoosterEvalOneIter(IntPtr handle, int iter, IntPtr[] dmats, + string[] evnames, System.UInt32 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 + */ + [DllImport(dll_path + "xgboost_wrapper.dll")] + public static extern Double[] XGBoosterPredict(IntPtr handle, IntPtr dmat, int output_margin, System.UInt32 len); + /*! + * \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 + */ + [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 + */ + [DllImport(dll_path + "xgboost_wrapper.dll")] + public static extern string XGBoosterDumpModel(IntPtr handle, string fmap, + System.UInt32 out_len); + + } +} diff --git a/windows/xgboost_sharp_wrapper/xgboost_sharp_wrapper.csproj b/windows/xgboost_sharp_wrapper/xgboost_sharp_wrapper.csproj new file mode 100644 index 000000000..01aafd029 --- /dev/null +++ b/windows/xgboost_sharp_wrapper/xgboost_sharp_wrapper.csproj @@ -0,0 +1,71 @@ + + + + + Debug + AnyCPU + {2D0E7F78-53DD-4501-8BD9-69E21A5051E3} + Library + Properties + xgboost_sharp_wrapper + xgboost_sharp_wrapper + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + ManagedMinimumRules.ruleset + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + ManagedMinimumRules.ruleset + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/windows/xgboost_sharp_wrapper/xgboost_sharp_wrapper.sln b/windows/xgboost_sharp_wrapper/xgboost_sharp_wrapper.sln new file mode 100644 index 000000000..600c68552 --- /dev/null +++ b/windows/xgboost_sharp_wrapper/xgboost_sharp_wrapper.sln @@ -0,0 +1,38 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2013 for Windows Desktop +VisualStudioVersion = 12.0.30723.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xgboost_sharp_wrapper", "xgboost_sharp_wrapper.csproj", "{2D0E7F78-53DD-4501-8BD9-69E21A5051E3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "kaggle_higgs_demo", "..\kaggle_higgs_demo\kaggle_higgs_demo.csproj", "{2EB1B15E-B7CA-494A-B4DC-BF56897A3F2F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2D0E7F78-53DD-4501-8BD9-69E21A5051E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D0E7F78-53DD-4501-8BD9-69E21A5051E3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D0E7F78-53DD-4501-8BD9-69E21A5051E3}.Debug|x64.ActiveCfg = Debug|x64 + {2D0E7F78-53DD-4501-8BD9-69E21A5051E3}.Debug|x64.Build.0 = Debug|x64 + {2D0E7F78-53DD-4501-8BD9-69E21A5051E3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D0E7F78-53DD-4501-8BD9-69E21A5051E3}.Release|Any CPU.Build.0 = Release|Any CPU + {2D0E7F78-53DD-4501-8BD9-69E21A5051E3}.Release|x64.ActiveCfg = Release|x64 + {2D0E7F78-53DD-4501-8BD9-69E21A5051E3}.Release|x64.Build.0 = Release|x64 + {2EB1B15E-B7CA-494A-B4DC-BF56897A3F2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2EB1B15E-B7CA-494A-B4DC-BF56897A3F2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2EB1B15E-B7CA-494A-B4DC-BF56897A3F2F}.Debug|x64.ActiveCfg = Debug|x64 + {2EB1B15E-B7CA-494A-B4DC-BF56897A3F2F}.Debug|x64.Build.0 = Debug|x64 + {2EB1B15E-B7CA-494A-B4DC-BF56897A3F2F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2EB1B15E-B7CA-494A-B4DC-BF56897A3F2F}.Release|Any CPU.Build.0 = Release|Any CPU + {2EB1B15E-B7CA-494A-B4DC-BF56897A3F2F}.Release|x64.ActiveCfg = Release|x64 + {2EB1B15E-B7CA-494A-B4DC-BF56897A3F2F}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal