This document summarizes Luis Beltran's presentation on machine learning with ML.NET and serverless functions. The presentation covered ML.NET for building machine learning models, Azure Functions for serverless applications, and a demo integrating the two by calling an ML.NET model from a function.
SQL Database Design For Developers at php[tek] 2024
Global AI Back Together - ML.NET, Serverless Functions & Integration
1. Global AI Back Together
Luis Beltrán
Microsoft MVP
Hosting Partner
Serverless
Machine
Learning
2. Luis Beltrán
Microsoft MVP in AI and Developer Technologies
Researcher at Tomas Bata University in Zlín, Czech Republic
Lecturer at Tecnológico Nacional de México en Celaya
@darkicebea
m
luis@luisbeltran.mx
luisbeltran.mx
8. Historic data
New data
Machine Learning
Algorithm
ML model
Data
Prediction
Training
Prediction
Machine Learning
Machine learning is a branch of AI that focuses on building apps that learn from
data and improve their accuracy over the time without being explicitly
programmed to do so.
10. ML.NET is a framework for custom ML
Machine Learning
lifecycle
Historic
Data
Test /
Evaluate
Build &Train
ML model
.ZIP file
(Trained)
Prepare Data, Build and Train an ML model
ML.NET API
(.NET Console app, etc.)
ML.NET Model Builder
(UI Desktop Tool)
ML Tasks, Data Transforms, Learners/Algorithms
ML.NET API
(.NET app)
API to run the model
nuget nuget
Business Application
(Web/Service/Desktop/Mobile)
ML model
file
.NET app
Predict: Run/consume the ML model
?
Live
User’s
Data
ML.NET
API to consume
the model
Run /
Predict
.NET
.NET
.csv files
Database
etc.
14. MLContext
MLContext is the starting point for all ML.NET operations and provides ways to create
components for:
◦ Data preparation
◦ Feature engineering
◦ Training
◦ Prediction
◦ Model evaluation
◦ Logging
◦ Execution control
◦ Seeding
15. Data Schema IDataView
It’s the set of columns, their names, types, & other annotations
Before loading data, you must define how the schema of data will look (column
names & column types)
Use class definitions to define IDV schemas
Dataset
Schema class definition
IDataView
Label SepalLength SepalWidth PetalLength PetalWidth
Iris-setosa 5.1 3.5 1.4 0.2
Iris-
versicolor
7.0 3.2 4.7 1.4
Iris-setosa 4.9 3.0 1.5 0.1
…
24. Your code runs when a
(previously-specified)
event occurs
Blob Storage
Cosmos DB
Event Hub
HTTP
Queues
Service Bus
Timer
Webhook
Photo taken and sent r
Upload it to
blob storage
PP
r
Produce scalated images
File
Table
Excel
OneDrive
Email
Mobile app
Notification
Más…
29. Global AI Back Together
Thank You
Hosting Partner
Register to Win Gift hamper
Editor's Notes
ML: Uses mathematical algorithms that can teach itself to evolve while data changes.
Supervised Labeled data.
Non-supervised Pattern discovery using non-labeled datasets.
An open source and cross-platform machine learning framework for .NET
Use your C# or F# skills and knowledge to enable ML in your .NET apps
How to improive a model
More different data
Larger datasets
Specialized datasets
Mixed datasets
Different pipelines
Different learners
Different transforms
Different hyperparameters
ML.NET API (code)
ML.NET Model Builder (VS)
ML.NET CLI
Data in ML.NET is represented in an IDataView
IEstimator defines the operations that will be executed.
ITransformer executes the operations
On-premises
What media should I use to keep backup? What is the right size of servers for my business needs? How do I deploy new code to my server? Whay happens in case of server hardware failure? Who monitors my app? What about server security? Which OS do I need?
Fortunately virtualization came to the rescue. One great thing about the cloud evolution is that each phase leads to less waste. Infrastructure as a Service leverages hardware in a way that you can stop worrying about the hardware and focus on the operating system and your virtual machines. You can get better utilization of your resources and it’s faster and easier to provision new instances. IaaS addresses many of the questions we dealt with on-premises, and more importantly paves the way to the cloud.
Platform-as-a-Service is the next evolution: host a runtime, so we stop worrying about hardware and operating system and even dependencies and just focus on our project. We’re no longer in the business of constantly patching an OS or even making sure dependencies are installed to run a web server or host a process. PaaS simplifies the process even more and provides a mature platform for code that must run at scale because you can still size (scale up) and specify instances (scale out) to manage your workloads.
Serverless takes us to the ultimate cloud native experience: we simply focus on code. It doesn’t mean there is no server, because we still need to run on infrastructure, but the infrastructure is further abstracted so there is less server in our scope of responsibility and more code. We focus on what is unique for our business and spend more time on innovation, less time on answering the myriad questions that exist with the previous phases. Serverless is cloud native. But what does that really mean?
Write your code in C#, nodeJS, Python, F#, PHP, PowerShell, Bash or Batch
You can extend your functionality by using NuGet or Node PM
You can even include DLLs to be called from your code or EXEs and execute them
Other scenarios
Devices feed data such as temperature, into Stream Analytics, then AF or Logic Apps cleans, processes and transforms this raw data into structured data that is stored into a database.
Create a Timer Trigger function in order to schedule a function that runs at a specified frequency, for example every 15 minutes or exactly at 9 am in Europe every Monday to connect to a database and clean it, for instance to remove non-valid data