private protected virtual IEnumerable <KeyValuePair <RoleMappedSchema.ColumnRole, string> > GetInputColumnRolesCore(RoleMappedSchema schema) { // Get the score column information. var scoreCol = EvaluateUtils.GetScoreColumn(Host, schema.Schema, ScoreCol, nameof(ArgumentsBase.ScoreColumn), ScoreColumnKind); yield return(RoleMappedSchema.CreatePair(MetadataUtils.Const.ScoreValueKind.Score, scoreCol.Name)); // Get the label column information. string label = EvaluateUtils.GetColName(LabelCol, schema.Label, DefaultColumnNames.Label); yield return(RoleMappedSchema.ColumnRole.Label.Bind(label)); string weight = EvaluateUtils.GetColName(WeightCol, schema.Weight, null); if (!string.IsNullOrEmpty(weight)) { yield return(RoleMappedSchema.ColumnRole.Weight.Bind(weight)); } }
/// <summary> /// Evaluates scored clustering data. /// </summary> /// <param name="data">The scored data.</param> /// <param name="score">The name of the score column in <paramref name="data"/>.</param> /// <param name="label">The name of the optional label column in <paramref name="data"/>.</param> /// <param name="features">The name of the optional feature column in <paramref name="data"/>.</param> /// <returns>The evaluation results.</returns> public ClusteringMetrics Evaluate(IDataView data, string score, string label = null, string features = null) { Host.CheckValue(data, nameof(data)); Host.CheckNonEmpty(score, nameof(score)); var roles = new List <KeyValuePair <RoleMappedSchema.ColumnRole, string> >(); roles.Add(RoleMappedSchema.CreatePair(MetadataUtils.Const.ScoreValueKind.Score, score)); if (label != null) { roles.Add(RoleMappedSchema.ColumnRole.Label.Bind(label)); } if (features != null) { roles.Add(RoleMappedSchema.ColumnRole.Feature.Bind(features)); } var rolesMappedData = new RoleMappedData(data, opt: false, roles.ToArray()); var resultDict = ((IEvaluator)this).Evaluate(rolesMappedData); Host.Assert(resultDict.ContainsKey(MetricKinds.OverallMetrics)); var overall = resultDict[MetricKinds.OverallMetrics]; ClusteringMetrics result; using (var cursor = overall.GetRowCursorForAllColumns()) { var moved = cursor.MoveNext(); Host.Assert(moved); result = new ClusteringMetrics(Host, cursor, _calculateDbi); moved = cursor.MoveNext(); Host.Assert(!moved); } return(result); }