Sentence similarity model : ML.net - exception while predicting how to fix it. This is the exception - System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

Navika Reddy 0 Reputation points
2023-11-13T12:22:43.9266667+00:00

I am using the ML.net model to do sentence similarity regression under the Natural language processing scenario. While using the predict() to get the predicted similarity am getting an exception System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

I have consumed the code generated as per the code snippet generated but am getting the above exception. The code I have written is as below

var userLostItem = new MatchFind.ModelInput()
                    {
                        Desc1 = actual,
                        Desc2 = foundItem.FDesc, 
                    };
         
                    var result = new MatchFind.ModelOutput();
                    try
                    {
                       
                        result = MatchFind.Predict(userLostItem);
                        
                        
                        double targetValue = 0.2; 

                        
                        double predictedValue = result.Score;
                        
                        if (predictedValue >= targetValue) 
                        {
                            matchedItems.Add(foundItem);
                        }
                    }
                    catch (Exception ex)
                    { 
                        Response.Write(ex);
                    }

.NET Machine learning
.NET Machine learning
.NET: Microsoft Technologies based on the .NET software framework.Machine learning: A type of artificial intelligence focused on enabling computers to use observed data to evolve new behaviors that have not been explicitly programmed.
150 questions
0 comments No comments
{count} votes