Back to Courses

Machine Learning Models with AnyLogic

2 hours
Pypeline library integration KNN classification in simulation Python–AnyLogic workflow

Course Overview

This session teaches how to integrate Machine Learning (ML) models with AnyLogic to enrich simulation scenarios. Using a healthcare example, participants will build a KNN classifier in Python to predict patient health conditions and integrate it with an AnyLogic simulation using the pypeline library.


Objectives

  • Understand how to integrate ML models with AnyLogic for simulation purposes
  • Use the pypeline Python library within AnyLogic to work with ML models
  • Apply a K-Nearest Neighbors (KNN) model to predict health conditions based on indicators
  • Store and retrieve models using pickle and handle data with pandas
  • Explore ML applications in healthcare simulation for patient outcome prediction

Prerequisites

Python

  • Intermediate knowledge including Pandas, Functions, Sklearn, data handling

AnyLogic

  • Functions, Discrete Events, Lambda functions

Machine Learning

  • Data scaling, K-Nearest Neighbors, classification model concepts

Topics Covered

1. Introduction to ML for AnyLogic

  • Overview of AnyLogic’s simulation capabilities
  • Benefits of integrating ML models in simulation (healthcare context)

2. The Pypeline Library

  • Introduction to pypeline for running Python ML models within AnyLogic
  • Architecture: connecting Python code with AnyLogic simulation models

3. K-Nearest Neighbors (KNN) Model

  • Building the KNN model in Python
  • Features: heart rate, systolic pressure, cholesterol level, diabetes status
  • Preparing the dataset with pandas

4. Model Training and Integration

  • Training the KNN model with healthcare data
  • Saving and loading trained models using pickle
  • Integrating the KNN model into AnyLogic using pypeline

5. Simulating Healthcare Scenarios

  • Running the simulation to predict health conditions
  • Interpreting simulation results and ML predictions

6. Hands-On Exercise

  • Step-by-step: predicting patient health conditions in a hospital using AnyLogic and KNN

Acquired Knowledge

By the end of this session, participants will be able to:

  • Integrate a Machine Learning model into an AnyLogic simulation
  • Implement the pypeline library to run Python-based models within AnyLogic
  • Train, save, and load ML models with pickle
  • Use pandas for data preprocessing in ML-simulation workflows
  • Apply ML to predict outcomes within a simulation context

What’s Next

  • Writing and running Python scripts directly in AnyLogic without external files

Interested in this course?

Get in Touch