/// <summary> /// Compute and store the scores of the input data given a model /// </summary> /// <param name="model">the model to be evaluated</param> /// <param name="labelFeatureData">input data</param> /// <param name="subModelScore">pre-computed scores for the input data</param> public void ModelEval(Model model, LabelFeatureData labelFeatureData, LabelFeatureData subModelScore) { if (subModelScore != null) { Debug.Assert(this.numSamples == subModelScore.NumDataPoint); for (int i = 0; i < this.numSamples; i++) { this.score[i] = subModelScore.GetFeature(0, i); } } else if (model != null && labelFeatureData != null) { Debug.Assert(this.numSamples == labelFeatureData.NumDataPoint); float[] scores = new float[1]; for (int i = 0; i < this.numSamples; i++) { model.Evaluate(labelFeatureData.GetFeature(i), scores); this.score[i] = scores[0]; } } else { for (int i = 0; i < this.numSamples; i++) { this.score[i] = 0.0F; } } }
/// <summary> /// Compute and store the scores of the input data given a model /// </summary> /// <param name="model">the model to be evaluated</param> /// <param name="labelFeatureData">input data</param> /// <param name="subModelScore">pre-computed scores for the input data</param> public void ModelEval(Model model, LabelFeatureData labelFeatureData, LabelFeatureData subModelScore) { if (subModelScore != null) { Debug.Assert(this.numSamples == subModelScore.NumDataPoint); for (int i = 0; i < this.numSamples; i++) { for (int k = 0; k < this.numClass; k++) { this.ModelScores[k][i] = subModelScore.GetFeature(k, i); } } } else if (model != null && labelFeatureData != null) // REVIEW by CJCB: this was 'if', I think it should be 'else if' so I changed it { Debug.Assert(this.numSamples == labelFeatureData.NumDataPoint); float[] scores = new float[this.numClass]; for (int i = 0; i < this.numSamples; i++) { model.Evaluate(labelFeatureData.GetFeature(i), scores); for (int k = 0; k < this.numClass; k++) { this.ModelScores[k][i] = scores[k]; } } } else { //TODO: qiangwu - should we always requre subModel to exist //to make the default model value computation explicit??? //It is probabaly safer that way revist the issue later float score = (float)1.0 / (float)this.numClass; for (int i = 0; i < this.numSamples; i++) { for (int k = 0; k < this.numClass; k++) { this.ModelScores[k][i] = score; } } } }