/// <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;
        }