Introducing Microsoft machine learning library for .NET (ML.NET)

Possibly save 1 hour of your time: This is a quick introduction to Microsoft machine learning library ML.NET.

Microsoft

Github

The library is only supported since .NET Core 2.0.

To start, you can create a .NET Core 2.0 console app. Then you can use nuget to find package Microsoft.ML and install it to your project.

Here are some features of the library:

ml_net

 

Package is not compatible with Package supports netstandard2.0

Possibly save 1 hour of your time: When you try to install a nuget package with a dependency on .NET Standard 2.0, it gives you this error.

.NET Standard 2.0 is supported by .NET Core 2.

You can right click your project >> select properties. Check to see what .NET Core you are using.

dot net core 2

If you don’t have .NET Core 2.0, the easiest way is to download latest is to go into Visual Studio > Tools > Extensions and Updates > Under Updates > Product Updates > you should be able to see Visual Studio Update.

You can also download SDK and Runtime here https://www.microsoft.com/net/download/visual-studio-sdks

For more information on .NET Standard 2.0, please see https://blogs.msdn.microsoft.com/dotnet/2017/08/14/announcing-net-standard-2-0/

 

 

LINQ query should not include your class projection to improve performance

Possibly save 1 hour of your time: I have found that performance of your LINQ query could be impact especially for large datasets when you project your results directly to a class object. It is better to project to .NET object after the sql query results came back first.

var results = (from a in context.TableA
                    join b in context.TableB on a.ID equals b.ID
                    select new YourClassName
                    {
                        Year = a.Year,
                        Name = b.Name
                    });
var list = results.ToList();

The code above is much slower than the code below for large datasets.

var results = (from a in context.TableA
                    join b in context.TableB on a.ID equals b.ID
                    select new
                    {
                        Year = a.Year,
                        Name = b.Name
                    });
var list = results.ToList();

var returnList = list.Select(x => new YourClassName
                {
                    Year = x.Year,
                    Name = x.Name
                }).ToList();