problem with Microsoft ML

SaeedP

Well-known member
Joined
Oct 21, 2020
Messages
100
Programming Experience
3-5
Hello,

This class is a logo builder project app. I have installed Microsoft ml but I still see a red line under Predict. I've tried many AI modes but still couldn't find what package should I install:

C#:
using Microsoft.ML;

namespace BlazorWasm_ML.net_Monica_Claude.Services
{
    public class LogoGenerator
    {
        private readonly MLContext mlContext;
        private readonly ITransformer model;

        //Constructor
        public LogoGenerator()
        {
            mlContext = new MLContext();

            // Load CSV training data
            var data = mlContext.Data.LoadFromTextFile<LogoModel>("logo_data.csv", hasHeader: true);



            // Define and train model
            model = mlContext.MulticlassClassification.Trainers.LbfgsMaximumEntropy(
                "LogoText", "ImagePath")
                .Fit(data);


        }

        //Method
        public LogoPrediction Predict(byte[] imageData)
        {
            var prediction = model.Predict(mlContext.Data.LoadFromEnumerable(new[] { imageData }));
            return new LogoPrediction
            {
                LogoText = prediction.First().PredictedLabel,
                Probability = prediction.First().Score
            };

        }
    }
}


thanks,
 
The red line simply means that there's a compilation error. You need to actually look at the error message to know what the problem is. Have you looked, because you haven't relayed that error message us? I would have thought that, if you hadn't referenced the appropriate assembly, the ITransformer type would cause a compilation error too.

I just took a look at the documentation for that ITransformer interface and I see no Predict method, so why do you think there should be one? Maybe you should provide a FULL and CLEAR explanation of the problem.

 
I can see that the generic PredicationEngine class has a Predict method, so may that's what you should be using.

 
Back
Top Bottom