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 / git.migrate
Created October 10, 2016 19:52
Move your existing git repository # to a new remote repository
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
### OPTION 1 ###########################################################################################
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
@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

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.WebMVC.Services
{
/// <summary>
/// When working with cloud services and Docker containers, it's very important to always catch
public async Task<Catalog> GetCatalogItems(int page,int take, int? brand, int? type)
{
_apiClient = new HttpClient();
var itemsQs = $"items?pageIndex={page}&pageSize={take}";
var filterQs = "";
if (brand.HasValue || type.HasValue)
{
var brandQs = (brand.HasValue) ? brand.Value.ToString() : "null";
var typeQs = (type.HasValue) ? type.Value.ToString() : "null";
@CESARDELATORRE
CESARDELATORRE / git.migrate
Created October 10, 2016 18:51 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
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 / 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"
@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 });
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).