I tried using MySQL for ML.NET. I installed MySQL driver for VisualStudio, and it gets displayed in the normal server explorer data sources but not in the ML.NET Setup?
Is there any way to use MySQL with ML.NET?
CodePudding user response:
There is no built-in way to use MySQL with ML.NET. From the ML.NET Model Builder documentation:
The current preview of Model Builder can work with csv files, tsv files, and SQL Server databases. As we work toward stable release, we'll be adding support for more file formats and databases, including non-relational data stores.
Thus, you However, the DatabaseSource class appears to be fairly generic, and it should work if you write some custom code:
First, install MySqlConnector with dotnet add package MySqlConnector.
Then try the following code:
var source = new DatabaseSource(MySqlConnectorFactory.Instance,
"server=myserver;user=myuser;password=pass",
"select `Text`, Label from table");
var ctx = new MLContext();
var loader = ctx.Data.CreateDatabaseLoader(
new("Text", DbType.String, 0),
new("Label", DbType.Boolean, 1));
var view = loader.Load(source);
