The following are the breaking changes that were impacting the ML.NET samples (at https://github.com/dotnet/machinelearning-samples) when moving to v0.10:
-
IDataView moved to a different NuGet package: a. Error: error CS0246: The type or namespace name 'IDataView' could not be found (are you missing a using directive or an assembly reference?) b. Fix: Add using Microsoft.Data.DataView; i. The new NuGet package is added automatically when using 0.10 version
-
AsEnumerable() moved to mlContext.CreateEnumerable() a. Error: Severity Code Description Project File Line Suppression State Error CS1501 No overload for method 'AsEnumerable' takes 2 arguments BikeSharingDemand D:\GitRepos\machinelearning-samples-0.10migration\samples\csharp\common\ConsoleHelper.cs 181 Active
-
Use pipeline Cache for most of the pipelines so there are no issues in VS F5
-
AsEnumerable functionality in IdataView is replaced with CreateEnumerable in MLContext class
a. Error : CS1929 'IDataView' does not contain a definition for 'CreateEnumerable' data.AsEnumerable(env, reuseRowObject: false)
a. Fix: env.CreateEnumerable(data, reuseRowObject: false) Where data -> IdataView and env ->MLContext
-
'BinaryClassificationContext' is replaced with BinaryClassificationCatalog a. Error CS0246 The type or namespace name 'BinaryClassificationContext' could not be found (are you missing a using directive or an assembly reference?) b. Fix: use BinaryClassificationCatalog class
-
Order of input and ouput columns is changed in API calls. a. Run time Exception: unable to find "PCSFeatures" in CustomerSegmentation.Train project b. Fix: the order of columns is changed from ML 0.9 to ML 0.10 in the below API call Example In ML 0.9: var dataProcessPipeline = new PrincipalComponentAnalysisEstimator(mlContext, "Features", "PCAFeatures", rank: 2)
Example In ML 0.10
var dataProcessPipeline = new PrincipalComponentAnalysisEstimator(env:mlContext, outputColumnName:"PCAFeatures", inputColumnName: "Features", rank: 2)
-
Order of input and output columns is changed in API calls
a. Error: Error: System.ArgumentOutOfRangeException: 'Could not find input column 'Label' - Parameter name: inputSchema'
a. Fix: change the order of input and output columns according to syntax in API. OR a. Error CS1739 The best overload for 'Normalize' does not have a parameter named 'inputName'
Example:
var dataProcessPipeline = mlContext.Transforms.CopyColumns("FareAmount", "Label")
.Append(mlContext.Transforms.Normalize(inputName: "PassengerCount", mode: NormalizerMode.MeanVariance))
b. Fix: Change the order according to syntax. Here mandatory column is output column. Input column is optional.
Example:
var dataProcessPipeline = mlContext.Transforms.CopyColumns("FareAmount", "Label") .Append(mlContext.Transforms.Normalize(outputColumnName : "PassengerCount", mode: NormalizerMode.MeanVariance))
-
MatrixFactorization package is replaced with Recommender. a. Error : NU1102 Unable to find package Microsoft.ML.MatrixFactorization with version (>= 0.10.0) b. Fix: edit the project file and replace "Microsoft.ML.MatrixFactorization" with "Microsoft.ML.Recommender"
-
Contiguous and Min variables are removed in KeyType Dataattribute
a. Error: CS0246 The type or namespace name 'Contiguous' could not be found (are you missing a using directive or an assembly reference?)
Example: public class ProductEntry { [KeyType(Contiguous = true, Count = 262111, Min = 0)] public uint ProductID { get; set; }[KeyType(Contiguous = true, Count = 262111, Min = 0)] public uint CoPurchaseProductID { get; set; } }
b. Fix: Remove Contiguous and Min variables. KeyType contains only Count variable. Example: [KeyType(Count = 262111)]
-
Seperator is replacedwith seperatorChar a. Error : CS0117 'TextLoader.Arguments' does not contain a definition for 'Separator'
b. Fix: Replace seperator with seperatorChar -
KeyRange is replaced with KeyCount a. Error : CS1503 Argument 3: cannot convert from 'Microsoft.ML.Data.TextLoader.Range[]' to 'int'
Error : CS0246 The type or namespace name 'KeyRange' could not be found (are you missing a using directive or an assembly reference?)Example:
new TextLoader.Column("ProductID", DataKind.U4, new [] { new TextLoader.Range(0) }, new KeyRange(0, 262110)),
b. Fix: use KeyCount isntead of KeyRange
Example:
new TextLoader.Column("ProductID", DataKind.U4, new [] { new TextLoader.Range(0) }, new KeyCount(262111))
- AdvancedSettings is removed while initializing MatrixFactorization trainer and replaced with Options
a. Error : CS1739 The best overload for 'MatrixFactorization' does not have a parameter named 'advancedSettings'
Example:
var est = ctx.Recommendation().Trainers.MatrixFactorization("ProductID", "CoPurchaseProductID", labelColumn: "Label", advancedSettings: s => { s.LossFunction = MatrixFactorizationTrainer.LossFunctionType.SquareLossOneClass; s.Alpha = 0.01; s.Lambda = 0.025; // For better results use the following parameters //s.K = 100; //s.C = 0.00001; });
b. Fix: Create a new options variable and assign the values as below. Pass the 'options' variable as parameter to trainer
MatrixFactorizationTrainer.Options options = new MatrixFactorizationTrainer.Options(); options.MatrixColumnIndexColumnName = nameof(ProductEntry.ProductID); options.MatrixRowIndexColumnName = nameof(ProductEntry.CoPurchaseProductID); options.LabelColumnName= DefaultColumnNames.Label; options.LossFunction = MatrixFactorizationTrainer.LossFunctionType.SquareLossOneClass; options.Alpha = 0.01; options.Lambda = 0.025;
var est = mlContext.Recommendation().Trainers.MatrixFactorization(options);
-
CreateTextReader of TextLoader Class is removed. Read the data using ReadFromTextFile method. a. Error : CS1061 'DataOperationsCatalog' does not contain a definition for 'CreateTextReader' and no accessible extension method 'CreateTextReader' accepting a first argument of type 'DataOperationsCatalog' could be found b. Fix: Use ReadFromTextFile method
-
'MulticlassClassificationContext' is moved to MulticlassClassificationCatalog a. Error : CS0246 The type or namespace name 'MulticlassClassificationContext' could not be found (are you missing a using directive or an assembly reference?)
b. Fix: Change 'MulticlassClassificationContext' to MulticlassClassificationCatalog