IndexOutOfRangeException: Label RRS feed

  • Question

  • Hello everyone, I am building a project about product recomendation.

    What I am trying to do is to Load data from a database (witch I checked and is connected fine) and then use the Field Aware Factorization algorithm to make some predictions.My problem is that when I am trying  pipeline.Fit(trainingDataView) I am getting this error: System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.

    Inner Exception IndexOutOfRangeException: Label

    //Here is my class :

    public class WineRating
            public bool Label;
            public float customer_id { get; set; }
            public float product_id { get; set; }


    public class WineRatingPrediction
            public bool PredictedLabel;

            public float Score;

    //And here is the part of the main program that gives me the error.

     public static ITransformer BuildAndTrainModel(MLContext mlContext, IDataView trainingDataView)
                var pipeline = mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "customer_idEncoded", inputColumnName: "customer_id"))
                    .Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "product_idEncoded", inputColumnName: "product_id"))
                    .Append(mlContext.Transforms.Concatenate("Features", "customer_idEncoded", "product_idEncoded"))
                    .Append(mlContext.BinaryClassification.Trainers.FieldAwareFactorizationMachine(new string[] { "Features" }));

                var model = pipeline.Fit(trainingDataView); //HERE IS THE ERROR
                return model;

    Please help?

    • Edited by Tekimoto Wednesday, May 27, 2020 12:20 AM
    Tuesday, May 26, 2020 11:17 PM

All replies

  • Hello Tekimoto,

    I am not really an expert on ML.net but based on the description of your issue it looks like an exception with the data passed to pipeline.fit()

    Is it possible to set your data based on the example mentioned in the reference documentation and check if it works? 


    Wednesday, May 27, 2020 9:46 AM