Skip to content

Instantly share code, notes, and snippets.

View CESARDELATORRE's full-sized avatar

Cesar De la Torre CESARDELATORRE

  • Microsoft Corp
  • Redmond, WA, U.S.
View GitHub Profile
@CESARDELATORRE
CESARDELATORRE / Breaking changes from ML.NET v0.9 to v0.10 impacting ML.NET Samples.md
Last active January 14, 2023 14:25
Breaking changes from ML.NET v0.9 to v0.10 impacting ML.NET Samples

The following are the breaking changes that were impacting the ML.NET samples (at https://github.com/dotnet/machinelearning-samples) when moving to v0.10:

  1. IDataView moved to a different NuGet package: a. Error: error CS0246: The type or namespace name 'IDataView' could not be found (are you missing a using directive or an assembly reference?) b. Fix: Add using Microsoft.Data.DataView; i. The new NuGet package is added automatically when using 0.10 version

  2. AsEnumerable() moved to mlContext.CreateEnumerable() a. Error: Severity Code Description Project File Line Suppression State

There are many more breaking changes in 0.9, but these are the ones that mostly the ML.NET samples faced when moving to v0.9:
1. MakePredictionFunction() --> CreatePredictionEngine() --> Based on my original feedback and this [issue](https://github.com/dotnet/machinelearning/issues/1761), since it creates an object, not a function..
2. The type or namespace name 'Microsoft.ML.Runtime' does not exist in the namespace 'Microsoft.ML' (Error: are you missing an assembly reference?)
a. Data attributes are now in: using Microsoft.ML.Data;
b. TextLoader and other types moved to using Microsoft.ML.Data;
c. Related, removed:
using Microsoft.ML.Runtime.Learners;
@CESARDELATORRE
CESARDELATORRE / mlnet-static-api-not-using-dataset-file.cs
Last active October 3, 2018 17:16
ML.NET static API loading traing DataSet NOT from a file
var dataReader = TextLoader.CreateReader(env,
c => (
CustomerId: c.LoadText(0),
ProductId: c.LoadText(1),
Quantity: c.LoadFloat(2),
Label: c.LoadBool(3)),
separator: ',', hasHeader: true);
FieldAwareFactorizationMachinePredictor pred = null;
var ctx = new BinaryClassificationContext(env);
@CESARDELATORRE
CESARDELATORRE / FFM.cs
Last active July 7, 2018 18:40
Adding FFM (FieldAwareFactorizationMachineBinaryClassifier) to ML.NET pipeline
pipeline.Add(new FieldAwareFactorizationMachineBinaryClassifier(){ LearningRate = 0.5f, Iter=2 });
@CESARDELATORRE
CESARDELATORRE / export-onnx-model-from-mlnet-model.cs
Last active July 8, 2018 21:08
export-onnx-model-from-mlnet-model
var onnxPath = GetOutputPath(subDir, "SaveModelToOnnxTest.onnx");
var onnxAsJsonPath = GetOutputPath(subDir, "SaveModelToOnnxTest.json");
OnnxConverter converter = new OnnxConverter()
{
InputsToDrop = new[] { "Label" },
OutputsToDrop = new[] { "Label", "Features" },
Onnx = onnxPath,
Json = onnxAsJsonPath,
Domain = "com.mydomain"
catalog.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80
- ConnectionString=YOUR_VALUE
- ... Other Environment Variables
ports:
- "5101:80" # Important: In a production environment you should remove the external port (5101) kept here for microservice debugging purposes.
# The API Gateway redirects and access through the internal port (80).
@CESARDELATORRE
CESARDELATORRE / AddJwtBearer-ConfigureServices.cs
Created May 15, 2018 19:01
AddJwtBearer-ConfigureServices.cs
// prevent from mapping "sub" claim to nameidentifier.
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
var identityUrl = Configuration.GetValue<string>("IdentityUrl");
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
@CESARDELATORRE
CESARDELATORRE / Sample-Authorize-Controller-Class.cs
Created May 15, 2018 18:58
Sample-Authorize-Controller-Class.cs
namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers
{
[Route("api/v1/[controller]")]
[Authorize]
public class BasketController : Controller
{ //...
{
"DownstreamPathTemplate": "/api/{version}/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "basket.api",
"Port": 80
}
],
"UpstreamPathTemplate": "/api/{version}/b/{everything}",
@CESARDELATORRE
CESARDELATORRE / Partial-eShopOnContainers-docker-compose.override.yml
Created May 15, 2018 18:54
Partial-eShopOnContainers-docker-compose.override.yml
mobileshoppingapigw:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- IdentityUrl=http://identity.api
ports:
- "5200:80"
volumes:
- ./src/ApiGateways/Mobile.Bff.Shopping/apigw:/app/configuration
mobilemarketingapigw: