本文整理匯總了C#中RDotNet.REngine.InitializeConsoleOutput方法的典型用法代碼示例。如果您正苦於以下問題:C# REngine.InitializeConsoleOutput方法的具體用法?C# REngine.InitializeConsoleOutput怎麽用?C# REngine.InitializeConsoleOutput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類RDotNet.REngine
的用法示例。
在下文中一共展示了REngine.InitializeConsoleOutput方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SupervisedLearner
/// <summary>
/// Creates an untrained learner, that uses the given number of frames to learn.
/// <param name="numberFrames">Number of frames after which this learner switches
/// to 'learned' state and predicts instead of further fitting the model.</param>
/// </summary>
public SupervisedLearner(int numberFrames)
{
// Initialize R engine for the untrained (or to-be-trained) learner
if (_engine == null)
{
#region Find R DLL
#if UNIX
// Hope, the RDotNet.NativeLibrary project finds it...
#else
// Try to find the path from the Windows registry and add it to a special environment variable,
// as well as the subfolders containing the dlls to the PATH variable.
string rhome = System.Environment.GetEnvironmentVariable("R_HOME");
if (string.IsNullOrEmpty(rhome)){
rhome = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\R-core\R", "InstallPath", "C:");
System.Environment.SetEnvironmentVariable("R_HOME", rhome);
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" +
rhome + @"\bin\i386;" +
rhome + @"\bin\x64;");
}
// Obsolete: set directory explicitly
//REngine.SetDllDirectory(rhome + @"\bin\i386");
#endif
#endregion
_engine = REngine.CreateInstance("R");
_engine.InitializeConsoleOutput();
}
// Only keep one single instance of the R engine (R.Net restriction: one engine per process).
// Therefore, make use of different virtual engines via an incrementing number, that is
// prepended to each used variable.
// Also, keep track of all SupervisedLearner instances: if the last one is disposed, no
// virtual engine is needed anymore: therefore dispose the R engine.
this._engineNum = _engines;
_engines++;
_disposedLearners.Add(false);
if (_disposedLearners.Count != _engines)
{
throw new Exception("Something has gone wrong: the list that keeps track of the virtual engines " +
"is different to the number of virtual engines.");
}
this.numberLearningSamples = numberFrames;
this.learned = false;
}