Exemplo n.º 1
0
        void New_CrossValidation()
        {
            var dataPath     = GetDataPath(SentimentDataPath);
            var testDataPath = GetDataPath(SentimentTestPath);

            using (var env = new TlcEnvironment(seed: 1, conc: 1))
            {
                var data = new TextLoader(env, MakeSentimentTextLoaderArgs())
                           .Read(new MultiFileSource(dataPath));
                // Pipeline.
                var pipeline = new TextTransform(env, "SentimentText", "Features")
                               .Append(new LinearClassificationTrainer(env, new LinearClassificationTrainer.Arguments
                {
                    NumThreads           = 1,
                    ConvergenceTolerance = 1f
                }, "Features", "Label"));

                var cv = new MyCrossValidation.BinaryCrossValidator(env)
                {
                    NumFolds = 2
                };

                var cvResult = cv.CrossValidate(data, pipeline);
            }
        }
Exemplo n.º 2
0
        void New_CrossValidation()
        {
            using (var env = new LocalEnvironment(seed: 1, conc: 1))
            {
                var data = new TextLoader(env, MakeSentimentTextLoaderArgs())
                           .Read(new MultiFileSource(GetDataPath(TestDatasets.Sentiment.trainFilename)));
                // Pipeline.
                var pipeline = new TextTransform(env, "SentimentText", "Features")
                               .Append(new LinearClassificationTrainer(env, "Features", "Label", advancedSettings: (s) => { s.ConvergenceTolerance = 1f; s.NumThreads = 1; }));


                var cv = new MyCrossValidation.BinaryCrossValidator(env)
                {
                    NumFolds = 2
                };

                var cvResult = cv.CrossValidate(data, pipeline);
            }
        }