private protected override IEnumerable <string> GetPerInstanceColumnsToSave(RoleMappedSchema schema)
        {
            Host.CheckValue(schema, nameof(schema));
            Host.CheckParam(schema.Label.HasValue, nameof(schema), "Schema must contain a label column");

            // The regression evaluator outputs the label and score columns.
            yield return(schema.Label.Value.Name);

            var scoreCol = EvaluateUtils.GetScoreColumn(Host, schema.Schema, ScoreCol, nameof(Arguments.ScoreColumn),
                                                        MetadataUtils.Const.ScoreColumnKind.Regression);

            yield return(scoreCol.Name);

            // Return the output columns.
            yield return(RegressionPerInstanceEvaluator.L1);

            yield return(RegressionPerInstanceEvaluator.L2);

            // REVIEW: Identify by metadata.
            int col;

            if (schema.Schema.TryGetColumnIndex("FeatureContributions", out col))
            {
                yield return("FeatureContributions");
            }
        }
        private IEnumerable <KeyValuePair <RoleMappedSchema.ColumnRole, string> > GetColumnRoles(
            RoleMappedSchema testSchema, Schema scoredSchema)
        {
            switch (PredictionKind)
            {
            case PredictionKind.BinaryClassification:
                yield return(RoleMappedSchema.CreatePair(RoleMappedSchema.ColumnRole.Label, testSchema.Label.Value.Name));

                var scoreCol = EvaluateUtils.GetScoreColumn(Host, scoredSchema, null, nameof(BinaryClassifierMamlEvaluator.ArgumentsBase.ScoreColumn),
                                                            MetadataUtils.Const.ScoreColumnKind.BinaryClassification);
                yield return(RoleMappedSchema.CreatePair(MetadataUtils.Const.ScoreValueKind.Score, scoreCol.Name));

                // Get the optional probability column.
                var probCol = EvaluateUtils.GetOptAuxScoreColumn(Host, scoredSchema, null, nameof(BinaryClassifierMamlEvaluator.Arguments.ProbabilityColumn),
                                                                 scoreCol.Index, MetadataUtils.Const.ScoreValueKind.Probability, NumberType.Float.Equals);
                if (probCol.HasValue)
                {
                    yield return(RoleMappedSchema.CreatePair(MetadataUtils.Const.ScoreValueKind.Probability, probCol.Value.Name));
                }
                yield break;

            case PredictionKind.Regression:
                yield return(RoleMappedSchema.CreatePair(RoleMappedSchema.ColumnRole.Label, testSchema.Label.Value.Name));

                scoreCol = EvaluateUtils.GetScoreColumn(Host, scoredSchema, null, nameof(RegressionMamlEvaluator.Arguments.ScoreColumn),
                                                        MetadataUtils.Const.ScoreColumnKind.Regression);
                yield return(RoleMappedSchema.CreatePair(MetadataUtils.Const.ScoreValueKind.Score, scoreCol.Name));

                yield break;

            case PredictionKind.MultiClassClassification:
                yield return(RoleMappedSchema.CreatePair(RoleMappedSchema.ColumnRole.Label, testSchema.Label.Value.Name));

                scoreCol = EvaluateUtils.GetScoreColumn(Host, scoredSchema, null, nameof(MultiClassMamlEvaluator.Arguments.ScoreColumn),
                                                        MetadataUtils.Const.ScoreColumnKind.MultiClassClassification);
                yield return(RoleMappedSchema.CreatePair(MetadataUtils.Const.ScoreValueKind.Score, scoreCol.Name));

                yield break;

            default:
                throw Host.Except("Unrecognized prediction kind '{0}'", PredictionKind);
            }
        }
예제 #3
0
        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));
            }
        }
예제 #4
0
        private protected override IEnumerable <string> GetPerInstanceColumnsToSave(RoleMappedSchema schema)
        {
            Host.CheckValue(schema, nameof(schema));
            Host.CheckParam(schema.Label.HasValue, nameof(schema), "Data must contain a label column");
            Host.CheckParam(schema.Group.HasValue, nameof(schema), "Data must contain a group column");

            // The ranking evaluator outputs the label, group key and score columns.
            yield return(schema.Group.Value.Name);

            yield return(schema.Label.Value.Name);

            var scoreCol = EvaluateUtils.GetScoreColumn(Host, schema.Schema, ScoreCol, nameof(Arguments.ScoreColumn),
                                                        AnnotationUtils.Const.ScoreColumnKind.Ranking);

            yield return(scoreCol.Name);

            // Return the output columns.
            yield return(RankingPerInstanceTransform.Ndcg);

            yield return(RankingPerInstanceTransform.Dcg);

            yield return(RankingPerInstanceTransform.MaxDcg);
        }