Beispiel #1
0
            public Dictionary<object, object> predict(Dictionary<string, dynamic> inputData,
                                                      bool byName = true,
                                                      Combiner combiner = Combiner.Plurality,
                                                      int missing_strategy = 0,
                                                      bool addDistribution=true)
            {
                mv = new MultiVote();

                if (_models.Count > 1) {
                    inputData = _models[0].prepareInputData(inputData);
                }

                for (i = 0; i < this._models.Count; i++)
                {
                    _modelsPredictions[i] = this._models[i].predict(inputData, byName, missing_strategy);
                    mv.append(_modelsPredictions[i].toDictionary(addDistribution));
                }
                return mv.combine((int)combiner, addDistribution: addDistribution);
            }
            public Dictionary <object, object> predict(Dictionary <string, dynamic> inputData,
                                                       bool byName          = true,
                                                       Combiner combiner    = Combiner.Plurality,
                                                       int missing_strategy = 0,
                                                       bool addDistribution = true)
            {
                mv = new MultiVote();
                bool addConfidence = areBoostedTrees;

                if (_models.Count > 1)
                {
                    inputData = _models[0].prepareInputData(inputData);
                    byName    = false;
                }

                mv.areBoostedTrees = areBoostedTrees;
                Dictionary <object, object> vote;

                for (i = 0; i < this._models.Count; i++)
                {
                    if (areBoostedTrees)
                    {
                        _modelsBoostedPredictions[i] = this._models[i].predictBoosted(inputData, byName, missing_strategy);

                        vote           = _modelsBoostedPredictions[i].toDictionary();
                        vote["weight"] = this._models[i].Boosting["weight"];
                        if (this._models[i].Boosting.ContainsKey("objective_class"))
                        {
                            vote["class"] = this._models[i].Boosting["objective_class"];
                        }
                        mv.append(vote);
                    }
                    else
                    {
                        _modelsPredictions[i] = this._models[i].predict(inputData, byName, missing_strategy);
                        mv.append(_modelsPredictions[i].toDictionary(addDistribution));
                    }
                }
                return(mv.combine((int)combiner, addDistribution: addDistribution, addConfidence: addConfidence));
            }