Example #1
0
        public void Train(List <Person> people, int numberOfTrees, int skillSetSize)
        {
            double[][] inputs = _dataPointService.GenerateDataPointsFromPeople(people, skillSetSize);

            int[] expectedResults = _dataPointService.GenerateExpectedResultFromPeople(people);

            // Create the forest learning algorithm
            var teacher = new RandomForestLearning()
            {
                NumberOfTrees = numberOfTrees, // use 10 trees in the forest
            };

            // Finally, learn a random forest from data
            _randomForest = teacher.Learn(inputs, expectedResults);

            // We can estimate class labels using
            trainingPredictions = _randomForest.Decide(inputs);

            // And the classification error (0.0006) can be computed as
            double error = new ZeroOneLoss(expectedResults).Loss(_randomForest.Decide(inputs));

            File.WriteAllLines(
                @"C:\Users\Niall\Documents\Visual Studio 2015\Projects\LinkedInSearchUi\LinkedIn Dataset\XML\random_forest_predictions.txt" // <<== Put the file name here
                , trainingPredictions.Select(d => d.ToString()).ToArray());
        }
        public void Train(List <Person> trainingPeople, int skillSetSize)
        {
            double[][] inputs = _dataPointService.GenerateDataPointsFromPeople(trainingPeople, skillSetSize);
            KMeans     kMeans = new KMeans(2);

            _clustersCollection = kMeans.Learn(inputs);

            trainingPredictions = _clustersCollection.Decide(inputs);
        }
        public void Train(List <Person> trainingPeople, int skillSetSize)
        {
            double[][] inputs = _dataPointService.GenerateDataPointsFromPeople(trainingPeople, skillSetSize);

            int[] expectedResults = _dataPointService.GenerateExpectedResultFromPeople(trainingPeople);

            // Now, we can create the sequential minimal optimization teacher
            var learn = new SequentialMinimalOptimization()
            {
                UseComplexityHeuristic = true,
                UseKernelEstimation    = false
            };

            // And then we can obtain a trained SVM by calling its Learn method
            _supportVectorMachine = learn.Learn(inputs, expectedResults);

            // Finally, we can obtain the decisions predicted by the machine:
            trainingPredictions = _supportVectorMachine.Decide(inputs);

            File.WriteAllLines(
                @"C:\Users\Niall\Documents\Visual Studio 2015\Projects\LinkedInSearchUi\LinkedIn Dataset\XML\predictions.txt" // <<== Put the file name here
                , trainingPredictions.Select(d => d.ToString()).ToArray());
        }