hello all,
a few days ago, we started looking into bringing machine learning to vl. discussions and tests are happening in this element channel.
one of the options we have at hand is to use Microsoft’s ML.NET lib. Hayden and I did some tests and unfortunately, we could not succeed. this topic aims to highlight the issues we encountered and try to figure out what could be done in vl to be able to wrap such a lib.
i tried to patch this example in which they teach you how to predict if a user review is aggressive or not (more info in the previous link). here are the issues I faced, please note i lack C# terms to clearly explicit the things they do in code I could not manage to patch :
finding the right overloads and default values
- in their example, they’re using the
LoadFromTextFile<T>
function like so :
IDataView dataView = mlContext.Data.LoadFromTextFile<SentimentIssue>(DataPath, hasHeader: true);
i actually had a hard time finding which overload of this function to use (the lib has many), and most importantly could not find the “generic” one. I would have a expected a generic LoadFromTextFile
node waiting for its output to be annotated to LoadFromTextFile<MyClass>
, but it could not find it in the node browser. is this something VL does not handle?
also, using the “Options” version makes the node red, with VL complaining the reference is ambiguous, not sure why.
- they create a trainer this way
var trainer = mlContext.BinaryClassification.Trainers.SdcaLogisticRegression(labelColumnName: "Label", featureColumnName: "Features");
when using the SdcaLogisticRegression node that has the input they’re using in code, the node throws an error saying name cannot be null or empty
. this is confusing since they’re only setting two params here, which are by the way the defaults the node already has.
… but using the node that just takes an Options input, no error is thrown :
attributes
also, they heavily rely on attributes (you have to annotate your class with those to tell to which column of your dataset a specific property of your class corresponds to). without proper attributes support in VL, it seems the lib not unusable right now.
loading a trained model
- tried a second approach trying to load a model trained in visual studio in C#, which they do like that :
var predEngine = mlContext.Model.CreatePredictionEngine<SentimentIssue, SentimentPrediction>(trainedModel);
in this case, I can find a generic CreatePredictionEngine<T1, T2>
, but VL complains TDst must have a default constructor, but SentimentPrediction has not
. @tonfilm pointed out it was related to type constraints, which not something I’m familiar with.
sorry for being so verbose, I just wanted to report things i stumbled upon to see how those issues could be addressed, or if I missed something obvious :)
thanks in advance for your comments and tips
seb