コード例 #1
0
ファイル: SVMClassifier.cs プロジェクト: xman086/BotSharp
        public FeaturesWithLabel FeatureSetsGenerator(Vec sentenceVectors, String label)
        {
            var labeledFeatureSet = new FeaturesWithLabel();
            int j = 1;

            foreach (double node in sentenceVectors.VecNodes)
            {
                Feature feature = new Feature((j++).ToString(), node.ToString());
                labeledFeatureSet.Features.Add(feature);
            }
            labeledFeatureSet.Label = label;

            return(labeledFeatureSet);
        }
コード例 #2
0
ファイル: SVMClassifier.cs プロジェクト: xman086/BotSharp
        public double[][] Predict(FeaturesWithLabel featureSet, ClassifyOptions options)
        {
            Problem predict = new Problem();
            List <FeaturesWithLabel> featureSets = new List <FeaturesWithLabel>();

            featureSets.Add(featureSet);
            predict.X        = GetData(featureSets).ToArray();
            predict.Y        = new double[1];
            predict.Count    = predict.X.Count();
            predict.MaxIndex = 300;

            RangeTransform transform = options.Transform;
            Problem        scaled    = transform.Scale(predict);

            return(Prediction.PredictLabelsProbability(options.Model, scaled));
        }
コード例 #3
0
ファイル: SVMClassifier.cs プロジェクト: xman086/BotSharp
        public List <FeaturesWithLabel> FeatureSetsGenerator(List <Vec> sentenceVectors, List <String> labels)
        {
            var res = new List <FeaturesWithLabel>();
            int j;

            for (int i = 0; i < labels.Count; i++)
            {
                string curLabel          = labels[i];
                Vec    curVec            = sentenceVectors[i];
                var    labeledFeatureSet = new FeaturesWithLabel();
                j = 1;
                foreach (double node in curVec.VecNodes)
                {
                    Feature feature = new Feature((j++).ToString(), node.ToString());
                    labeledFeatureSet.Features.Add(feature);
                }
                labeledFeatureSet.Label = curLabel;
                res.Add(labeledFeatureSet);
            }

            return(res);
        }