Esempio n. 1
0
        /// <summary>
        /// Parses a random forest from a weka output file
        /// </summary>
        public static RandomForest FromWekaFile(string file)
        {
            var    output = new RandomForest(new HashSet <string>(s_classLabels));
            var    reader = new StreamReader(file);
            int    id     = 0;
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                // keep reading until we find one of these. This one is followed
                // by another line with equal signs and then empty lines until we find the first text
                if (line.StartsWith("RandomTree"))
                {
                    ++id;
                    string firstLine;
                    reader.ReadLine();
                    while ((firstLine = reader.ReadLine()).Trim().Length == 0)
                    {
                        continue;
                    }
                    // now, we can start reading the tree
                    output.Trees.Add(RandomTree.FromStream(reader, firstLine, DefaultPrecision, id));
                }
            }
            reader.Close();
            return(output);
        }
Esempio n. 2
0
 private void LoadClassifier(ContentPlacementClassifierConfiguration config)
 {
     Contract.Requires(Directory.Exists(config.QueueToMachineMapDirectory), $"QueToMachineMapDirectory directory [{config.QueueToMachineMapDirectory}] does not exists");
     Contract.Requires(Directory.Exists(config.QueueDistanceMapDirectory), $"QueueDistanceMapDirectory directory [{config.QueueDistanceMapDirectory}] does not exists");
     Contract.Requires(File.Exists(config.RandomForestFile), $"RandomForestFile [{config.RandomForestFile}] does not exists");
     // load the forest
     m_forest = RandomForest.FromWekaFile(config.RandomForestFile);
     // now load the alternatives per queue
     LoadAlternativesPerQueue(config);
     // done
 }