Skip to content

Consider making DataView and IEstimator Preview methods return DataTable #2912

Description

@eerhardt

Visual Studio has the ability to visualize a data set if the object is a System.Data.DataTable.

We currently have some debugger extension methods:

public static class DebuggerExtensions
{
/// <summary>
/// Extract a 'head' of the data view in a view that is convenient to debug.
/// </summary>
/// <param name="data">The data view to preview</param>
/// <param name="maxRows">Maximum number of rows to pull</param>
public static DataDebuggerPreview Preview(this IDataView data, int maxRows = DataDebuggerPreview.Defaults.MaxRows)
=> new DataDebuggerPreview(data, maxRows);
/// <summary>
/// Preview an effect of the <paramref name="transformer"/> on a given <paramref name="data"/>.
/// </summary>
/// <param name="transformer">The transformer which effect we are previewing</param>
/// <param name="data">The data view to use for preview</param>
/// <param name="maxRows">Maximum number of rows to pull</param>
public static DataDebuggerPreview Preview(this ITransformer transformer, IDataView data, int maxRows = DataDebuggerPreview.Defaults.MaxRows)
=> new DataDebuggerPreview(transformer.Transform(data), maxRows);
/// <summary>
/// Preview an effect of the <paramref name="estimator"/> on a given <paramref name="data"/>.
/// </summary>
/// <param name="estimator">The estimnator which effect we are previewing</param>
/// <param name="data">The data view to use for preview</param>
/// <param name="maxRows">Maximum number of rows to show in preview</param>
/// <param name="maxTrainingRows">Maximum number of rows to fit the estimator</param>
public static DataDebuggerPreview Preview(this IEstimator<ITransformer> estimator, IDataView data, int maxRows = DataDebuggerPreview.Defaults.MaxRows,
int maxTrainingRows = DataDebuggerPreview.Defaults.MaxRows)
{
Contracts.CheckValue(estimator, nameof(estimator));
Contracts.CheckValue(data, nameof(data));
Contracts.CheckParam(maxRows >= 0, nameof(maxRows));
Contracts.CheckParam(maxTrainingRows >= 0, nameof(maxTrainingRows));
var env = new LocalEnvironment();
var trainData = SkipTakeFilter.Create(env, new SkipTakeFilter.TakeOptions { Count = maxTrainingRows }, data);
return new DataDebuggerPreview(estimator.Fit(trainData).Transform(data), maxRows);
}
/// <summary>
/// Preview an effect of the <paramref name="loader"/> on a given <paramref name="source"/>.
/// </summary>
/// <param name="loader">The data loader to preview</param>
/// <param name="source">The source to pull the data from</param>
/// <param name="maxRows">Maximum number of rows to pull</param>
public static DataDebuggerPreview Preview<TSource>(this IDataLoader<TSource> loader, TSource source, int maxRows = DataDebuggerPreview.Defaults.MaxRows)
=> new DataDebuggerPreview(loader.Load(source), maxRows);
}

We should consider making these return DataTable, so VS can visualize them. Or potentially we could add ancillary methods that return DataTable, and keep the current methods returning DataDebuggerPreview, if we think the current experience has value over the visualization in VS.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIIssues pertaining the friendly APIP2Priority of the issue for triage purpose: Needs to be fixed at some point.enhancementNew feature or requestneeds-author-action

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions