/// <summary> /// Evaluates scored clustering data. /// </summary> /// <param name="data">The scored data.</param> /// <param name="scoreColumnName">The name of the score column in <paramref name="data"/>.</param> /// <param name="labelColumnName">The name of the optional label column in <paramref name="data"/>. /// If present, the <see cref="ClusteringMetrics.NormalizedMutualInformation"/> metric will be computed.</param> /// <param name="featureColumnName">The name of the optional features column in <paramref name="data"/>. /// If present, the <see cref="ClusteringMetrics.DaviesBouldinIndex"/> metric will be computed.</param> /// <returns>The evaluation result.</returns> public ClusteringMetrics Evaluate(IDataView data, string labelColumnName = null, string scoreColumnName = DefaultColumnNames.Score, string featureColumnName = null) { Environment.CheckValue(data, nameof(data)); Environment.CheckNonEmpty(scoreColumnName, nameof(scoreColumnName)); if (featureColumnName != null) { Environment.CheckNonEmpty(featureColumnName, nameof(featureColumnName), "The features column name should be non-empty if you want to calculate the Dbi metric."); } if (labelColumnName != null) { Environment.CheckNonEmpty(labelColumnName, nameof(labelColumnName), "The label column name should be non-empty if you want to calculate the Nmi metric."); } var eval = new ClusteringEvaluator(Environment, new ClusteringEvaluator.Arguments() { CalculateDbi = !string.IsNullOrEmpty(featureColumnName) }); return(eval.Evaluate(data, scoreColumnName, labelColumnName, featureColumnName)); }
public ClusteringMamlEvaluator(IHostEnvironment env, Arguments args) : base(args, env, MetadataUtils.Const.ScoreColumnKind.Clustering, "ClusteringMamlEvaluator") { Host.CheckValue(args, nameof(args)); Host.CheckUserArg(1 <= args.NumTopClustersToOutput, nameof(args.NumTopClustersToOutput)); _numTopClusters = args.NumTopClustersToOutput; _featureCol = args.FeatureColumn; _calculateDbi = args.CalculateDbi; var evalArgs = new ClusteringEvaluator.Arguments { CalculateDbi = _calculateDbi }; _evaluator = new ClusteringEvaluator(Host, evalArgs); }