Skip to content

Conversation

@artidoro
Copy link
Owner

@artidoro artidoro commented Mar 23, 2019

I am a bit concerned about the fact that we have to .Fit(...) for non trainable transforms. I think it can make ML.NET look really bad! I worked on a solution for the problem...

I tried three approaches:

  1. Create a new interface that combines IEstimator and ITransformer:ITrivialEstiamtor : IEstimator , ITransformer
  2. Make the trivial estimator class implement ITransformer:TrivialEstimator : IEstimator, ITransformer
  3. Simply add a method .Transform(IDataView input) in  the TrivialEstimator class.

For each one of these the difficult part is making sure that the estimator/transformer chains work properly. So I implemented a TrivialEstiamtorChain that mimics EstimatorChain but on the class TrivialEstimator instead of the interface IEstimator.

For 1. and 2. I did not manage to make it work... When you .Append() two trivialestimators it will just have a difficult time to distinguish whether you want to create a new EstimatorChain or a TransformerChain. 

For 3. I managed to make it work, I think! The .Append() works and will switch to an EstimatorChain as soon as a trainable estimator is added to the pipeline.

Is it fine not having a class/interface that combines ITransformer and IEstimator?

/// there is no easy way to infer it from the transformer.
/// </summary>
public abstract class TrivialEstimator<TTransformer> : IEstimator<TTransformer>
public abstract class TrivialEstimator<TTransformer> : ITrivialEstimator<TTransformer>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TrivialEstimator [](start = 26, length = 16)

TrivialEstimatorBase

private protected readonly IHost Host;
[BestFriend]
private protected readonly TTransformer Transformer;
internal readonly TTransformer Transformer;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nternal readonly TTransformer Transformer; [](start = 9, length = 42)

private protected

}

public TTransformer Fit(IDataView input)
public virtual TTransformer Fit(IDataView input)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

virtual [](start = 15, length = 7)

remove

return Transformer;
}

public virtual IDataView Transform(IDataView input)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

virtual [](start = 15, length = 7)

remove virtual

private protected readonly IHost Host;
[BestFriend]
private protected readonly TTransformer Transformer;
internal readonly TTransformer Transformer;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transformer [](start = 39, length = 11)

not needed

Host.CheckValue(input, nameof(input));
// Validate input schema.
Transformer.GetOutputSchema(input.Schema);
return Transformer;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transformer [](start = 19, length = 11)

return this.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants