Skip to content

Simplify Pipeline Initalization with Append() that returns the pipeline #7

Closed

Description

@glebuk

Issue:
Currently we have to use the pipeline instance to append additional items to the pipeline. It looks something like this:

var pipeline = new LearningPipeline();
pipeline.Add(new TextLoader<SentimentData>(dataPath, separator: ","));
pipeline.Add(new TextFeaturizer("Features", "SentimentText"));

We can add the ability to add a pipeline item in a fluent fashion. The benefit would be reduction of typing and cleaner API.
This would require pipeline to add the following method:

public LearningPipeline Append(ILearningPipelineItem item);

The user code will look like this:

var pipeline = new LearningPipeline()
   .Append(new TextLoader<SentimentData>(dataPath, separator: ","))
   .Append(new TextFeaturizer("Features", "SentimentText"));

(optional) with extension methods, this can be simplified even further to:

var pipeline = new LearningPipeline()
   .AddTextLoader<SentimentData>(dataPath, separator: ",")
   .AddTextFeaturizer("Features", "SentimentText");

Activity

  1. eerhardt commented on May 4, 2018

    @eerhardt
    Member

    The user code will look like this:
    var pipeline = new LearningPipeline()
    .Add(new TextLoader(dataPath, separator: ","))
    .Add(new TextFeaturizer("Features", "SentimentText"));

    Did you mean to have .Append instead of .Add?

  2. markusweimer commented on May 4, 2018

    @markusweimer

    +1 on this change. However, I wonder whether we should return a new copy of the pipeline after each .Append or .Add call. Otherwise, the following code would be very confusing:

    var p1 = new LearningPipeline().Add(A).Add(B);
    var p2 = p1.Add(C).Add(D);
    var p3 = p1.Add(D);

    We should make sure that p1 refers to [A,B], p2 to [A,B,C,D] and p3 to [A,B,D].

  3. added this to the 0518 milestone on May 9, 2018
  4. added a commit that references this issue on May 24, 2018
  5. modified the milestones: 0518, 0618 on May 29, 2018
  6. glebuk commented on May 29, 2018

    @glebuk
    ContributorAuthor

    It would be also good to make the LearningPipeline a List instead of Collection. This way it would be easy to manipulate the pipeline by adding and replacing items in the arbitrary location.
    Example of the scenario is sweep of different learners.

  7. shauheen commented on Jun 26, 2018

    @shauheen
    Contributor

    closing this issue as the PR has already merged and the API will also be updated in the next release.

  8. ghost locked as resolved and limited conversation to collaborators on Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions