dotnet / dotnet/machinelearning-modelbuilder

Code reusability post brain dump

Aperta
#2,269 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
Stale
Lingua principale
Dockerfile
Stelle
285
Fork
66
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

There's been a few requests / questions around sharing models across multiple projects. Today we recommend the following approach:

## Add model to C# Class Library

The general process for this is:

1. Create C# Class Library project
2. Right-Click > Add > Machine Learning Model
3. Select Machine Learning Model (ML.NET) in Add New Item dialog.
4. Provide name for your model
5. Follow Model Builder prompts to train your model.

Once the model is trained, you can add a reference to it in any project that needs it and reuse the consumption code that gets generated by Model Builder to make predictions.

---

An approach you might also consider is:

## Package model as NuGet package

NuGet packages can also be used. Models can be treated as code. They are basically stateful functions that take data in, apply transformations based on patterns learned during the training process, and output a result (often a prediction). As such, models can be packaged like any other code asset using NuGet.

Advantages:

- Versioning. Not only for auditability and rollback purposes, but upgrading to the latest version of the model is as easy as updating the version number.
- Retraining and consumption code are included as part of the package reducing the need to write boilerplate code for consumption.
- Leverage existing CI/CD processes for packaging and distributing code.
- Leverage existing security measures already in place when it comes to packages.
- Leverage existing tools and knowledge for consuming packages.
- Opportunity to create model libraries. Models that are intended to work together can be included in a single package for easier accessibility and dependency management.

Disadvantages:

- Depending on where the package is being published to, there may be package size limitations / restrictions. This is especially true for larger models.

The general process of packaging models as follows:

1. Create C# Class Library project
2. Right-Click > Add > Machine Learning Model
3. Select Machine Learning Model (ML.NET) in Add New Item dialog.
4. Provide name for your model
5. Follow Model Builder prompts to train your model.
6. Create and publish NuGet package. For simplicity, the package can be published to a local directory. However, if you already have your own private or NuGet feed, those are options as well.
7. Add feed as a package source (if it isn't already one of your sources).
8. Create a new C# Console application
9. Use VS NuGet Package Manager to install the NuGet Package for your ML Model
10. Use the code from the installed package to make predictions.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

L'issue contiene un brain dump che descrive modelli C# condivisi e il packaging NuGet, ma non indica file o test. Inizia determinando se queste indicazioni debbano rientrare nella documentazione del progetto e conferma il workflow di Model Builder descritto. Il lavoro è completato quando l'ambito previsto della documentazione e l'approccio consigliato sono stati concordati e registrati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.