Is there a good way to use inherited types as data for ML pipeline?
I have tried reflection and many other methods but somewhere between the LoadFromEnumerable method and the training of the pipeline, the pipeline will not be able to see properties of the concrete class.
I have tried inheriting from a base class, and from an interface, and from a base class that implements and interface.
when i remove the inheritance my training method works but when I inherit an exception is thrown "Cannot find xxyz property in pipeline"
my feature columns are directly taken from the concrete type instance using a method where the type is passed in at run time from a sample of the data.
When I print the feature columns they are all there, but when I progress to training the training the columns are not found.
Really all I need is a simple way to pass many different kinds of 'BaseFood' to my pipelines, I can get it working with a simple switch statement and by passing only classes that do not inherit but I am curious if there is a fix that would allow me to dynamically pass in types that use inheritance so that I do not need to have many lists or dictionaries for each type in the rest of my code.
just to keep it simple I will give an outline rather than all the code.
//(BaseFood): implements the features that are commonly used by all food types
//(Food1 : BaseFood): has its own specific properties.
//(Food 2: BaseFood): has its own specific properties.
TrainingMethod(BaseFood basefood)
{
var concreteType = baseFood[0].GetType();
//This method returns the string[0] of feature columns for the pipeline
var featureColumnNames = FeatureColumnFiltering.GetColumnNames(concreteType);
//The concrete column names print correctly from the returning string[]
//split data sets etc
//proceed to train pipeline and this is where error is thrown as the pipeline only recognises BaseFood properties and not Food1 or Food2 even if they have been cast, converted or reflected. so Food1 or Food2 "Property xyx Could not be found"
}
Everything I have learned is trial and error to be honest, so I am open to using specific design principle or approach that I may not have thought of, if someone could be kind enough to point it out.