STAM Summary

Summary of the STAM elective course - ABM and ML concepts

Introduction

  1. Ten Iterative steps in development and evaluation of environmental models:
  • Need for good model-development practice
  • Best practice entails
    • Clearly identifying the clients and objectives of the modelling exercise.
    • documenting the nature (quantity, quality, limitations) of the data used to construct and test the model.
    • providing a strong rationale for the choice of model family and features (encompassing review of alternative approaches);
    • justifying the techniques used to calibrate the model; serious analysis, testing and discussion of model performance.
    • making a resultant statement of model assumptions, utility, accuracy, limitations, and scope for improvement.
  • 10 steps in modelling process
    • Definition of the purposes for modelling
    • Specification of the modelling context: scope and resources
    • Conceptualization of the system, specification of data and other prior knowledge (what degree of detail)
    • Selection of model features and families
    • Choice of how model structure and parameter values are to be found
    • Choice of estimation performance criteria and technique
    • Identification of model structure and parameters
    • Conditional verification including diagnostic checking
    • Quantification of uncertainty
    • Model evaluation or testing (other models, algorithms, comparisons with alternatives)

 

  1. Modelling as a discipline:
    • Sensitivity analysis {Sensitivity analysis determines how different values of an independent variable affect a particular dependent variable under a given set of assumptions} can be used not only to test the performance of models but can also be a valuable guide to the development of models and can help identify what can safely be omitted. In some cases, sensitivity analysis can even show the impossibility of developing a model that does what we want it to. by carrying out sensitivity analysis at an early stage of the planning process it may be possible to avoid getting caught in a quagmire of detail that ultimately will not affect model performance.
    • The usual approach to model development is to characterize the system, make some assumptions about how it works, translate these assumptions into equations, and start programming. This does not always work. If the model does not fit the data, it may well be that the assumptions are wrong. If so, what does one do next? One approach is to ask what kinds of models could fit the data and see whether any of these provide plausible alternatives. This is data-driven modelling {The process of using data to derive the functional form of a model or the parameters of an algorithm}.
    • Path analysis was a useful tool for system identification and tells that if a model doesn't make any sense, it may help to look at the experimental data with a critical eye and review the assumptions on which both the model and the interpretation of the data are based.
    • Validation:
      • Aliasing Problem: Some of the most common problems in the design and analysis of experiments involve aliasing, which occurs when discrete sampling is used to measure continuous processes. Typically, the measurements are interpolated with straight lines or higher order splines.
      • Replication Problem: We have an adequate set of replicate data to work with, and consequently there are often special situations which cause unexpected discrepancies. These are not special cases-it is rare for a model to be tested with data that are fully consistent with those on which the model is based.
      • False Implicit Assumptions: Since there is little quantitative data on some parameter, it is commonly assumed that it can be ignored. This can lead to huge underestimates.

 

  1. Typical pitfalls of Simulation Modelling – Lessons Learned from Armed Forces and Business:
  • The process of applying simulation methods can be visualized as a six-step cycle:
    • Formulate Research Question
    • Identify relevant elements of target system [Distraction pitfall]
    • Choose model structure [Complexity pitfall]
    • Implement model [Implementation pitfall]
    • Run and analyze model [Interpretation pitfall]
    • Communicate results [Acceptance pitfall]
  • A single, specific experimental setting is called scenario. Running the experiment itself is referred to as the simulation.
  • Users of simulation methods might encounter the following five pitfalls:
    • Distraction – Tempting to address other relevant questions related to the model – expanding original simulation focus. Avoided by: Articulate the question at hand clearly and stay focused on it! This helps to keep the part of reality to be modeled manageable.
    • Complexity – Major cause is false understanding of realism - Model structure must represent reality with sufficient precision. Avoided by:  Stay focused on the core cause-and-effect-relationships when creating a model.
    • Implementation – Implementing model in unsuitable software, not well managed dependencies. Avoided by: The abstract simulation model should determine the IT implementation choice, not vice-versa.
    • Interpretation – users prone to losing critical distance to the results – psychological ownership of the object. Avoided by:  Simulation results should be questioned by evaluating their plausibility and by trying to find alternative explanations for the results. selected results should be randomly tested and recalculated. If the results appear counter-intuitive, they have to be broken down into sub-questions and components to be analyzed at a more detailed level.
    • Acceptance - If the results match the expectations, the simulation model and the results themselves are called trivial. If the results are surprising, they prompt third-party decision makers to question the correctness of the entire simulation. Avoided by:  Referencing to relationships and patterns, which are well-known, commonly used and, thus, accepted further adds to the simulation results' persuasive power.


 

---------------------------------------------------------------------------------------------------------------------------------

 

Explanation

1. Introduction to ABM:

  • In individual-based models (IBMs), organisms are explicitly represented as discrete and unique entities, for example individual trees or birds. IBMs are used if one or more of the following aspects, that are hard to deal with in analytical models, are considered important: trait variability among individuals, local interactions, adaptive behaviour that is based on decision making, and heterogeneous and dynamic environments. Agent-based models (ABMs) follow the same rationale but have a stronger focus on decision making.
  • Agent-based models (ABMs) are stochastic models built from the bottom up meaning individual agents (often people in epidemiology) are assigned certain attributes. The agents are programmed to behave and interact with other agents and the environment in certain ways. These interactions produce emergent effects that may differ from effects of individual agents. Agent-based modeling differs from traditional, regression-based methods in that, like systems dynamics modeling, it allows for the exploration of complex systems that display non-independence of individuals and feedback loops in causal mechanisms. It is not limited to observed data and can be used to model the counterfactual or experiments that may be impossible or unethical to conduct in the real world.
  • Individual-based modeling (IBM) specifically focuses on simulating the behaviors and interactions of individual entities, often in ecological and biological contexts, with an emphasis on the detailed characteristics and diversity of individuals. Agent-based modeling (ABM), while similar in simulating autonomous entities, has a broader scope that includes a variety of agents (not just individuals) and is used to study complex systems and emergent behaviors across various fields such as economics, social sciences, and beyond.
  • Characteristics of Agents:
    • Discretely identifiable
    • Heterogeneous (different behavior for each agent)
    • Located in an environment and can perceive it
    • Goal-directed
    • Ability to adapt, learn and be flexible
    • Ability to function independently
    • Motion, communication, and interaction with environment
    • Memory
    • Policy rules that determine which behavior to perform
  • A door can be an agent: if it has the position in space, can sense the environment, we make the door with sensor to open whenever a person enters, it should stop when there is a number of people or the time has the elapsed.
  • Time-driven computation is often more expensive than event-driven computation in ABM because it requires updating all agents at every time step, leading to a higher number of computations and greater computational overhead. Event-driven computation, by contrast, only updates agents when specific events occur, resulting in more efficient use of computational resources and better scalability.
  • ABM1_upload_2024

 

---------------------------------------------------------------------------------------------------------------------------------

 

 

2. Designing an ABM:

 

  • Complex systems are those that consists of many interconnected components, where behaviour of the system as a whole cannot be predicted from the behaviour of its individual components.
  • Positive Feedback Loops: A larger population leads to more births occurring (the larger the number of people in the population, the more babies are born)
  • Negative Feedback Loops: A system with Negative feedback tries to stabilize itself according to the rules: the larger something is, the smaller something becomes (if there is a limited food supply and the population grows – the less food per person)
  • Characteristics of Complex systems:
  • Hierarchy - parts of system and their interactions can be identified in different hierarchical levels (sub-systems).
  • Non-linearity - Due to interdependence of elements, different levels of the system show non-linear behaviour
    • State Transition - Irreversible - Sand pile stable system to unstable system
    • Small Change with Large Impact - Drop a stone in river, changes flow forever
    • Fractals - Scale-less - The system shows same pattern in different scales - COVID pattern
    • Tipping Points - Critical Thresholds when crossed, will have severe impacts which are irreversible
  • Connectivity - Connection between elements form network. Not all elements have same degree of connectivity
  • Emergence - Due to connections between the elements, new properties of the system can emerge => Patterns, Structures, Behaviors
  • Pattern Oriented Modelling (POM) – Allows modelling across scales at multiple hierarchical levels
  • Designing an ABM_canvas

---------------------------------------------------------------------------------------------------------------------------------

3. Model Validation ABM:

  • Model robustness is a machine-learning (ML) model's ability to withstand uncertainties and perform accurately in different contexts. A model is robust if it performs strongly on datasets that differ from the training data.
  • Difference in the logic of the model can be studied by comparison of different versions (By comparing Conditions, order of execution, final requirement)
  • Stability of Model only checked if there are any stochastic Variables
  • Validation is a process of comparing the model and its behavior to the real system and its behavior. Calibration is the iterative process of comparing the model with real system, revising the model if necessary, comparing again, until a model is accepted (validated).
    • Input Validation: Are the inputs to the model meaningful – quantitative and qualitative used to parametrize and calibrate – validated data source
    • Process Validation: How well do the processes represented in the model reflect the real world for the model purpose – entities, process, stochastic elements, interactions, spatial and temporal scale chosen and why not others
    • Descriptive output Validation: How well does the model output capture the features of the data used to build the model – we list the real world features and in which criteria the model can simulate the system
    • Predictive output Validation: Is the model able to forecast a sample data not used to build the model/ data only acquired later/ another case study – how we can trust the model on an independent data
  •  ABM3

--------------------------------------------------------------------------------------------------------------------------------

4. ODD Protocol

  • If adaptive traits explicitly act to increase some measure of the individual’s success at meeting some objective, what exactly is that objective and how is it measured?
    • In the ODD protocol, when adaptive traits act to increase an individual’s success, the objective is a specific goal such as survival, reproduction, or resource acquisition. This objective is measured using relevant metrics like lifespan, reproduction rate, resource acquisition rate, or social status indicators. These measurements help quantify how well an agent is performing in achieving its objective, allowing for the assessment of the effectiveness of adaptive traits.
  • Many individuals or agents (but also organizations and institutions) change their adaptive traits over time as a consequence of their experience? If so, how?
    • Adaptive traits in individuals, agents, organizations, and institutions change over time due to various experiences and mechanisms:
      • Individuals and Agents: Learn and adapt through reinforcement, memory, practice, genetic algorithms, and machine learning.
      • Organizations and Institutions: Adapt through knowledge management, best practices, strategic planning, and process improvements.
      • Biological Systems: Evolve through natural selection and environmental pressures.
      • These changes help entities improve their fitness, efficiency, and effectiveness in their respective environments.

  • if an agent’s adaptive traits or learning procedures are based on estimating future consequences of decisions, how do agents predict the future conditions (either environmental or internal) they will experience?

    • Agents predict future conditions using a combination of heuristic-based, model-based, and data-driven approaches. They may rely on simple heuristics, build internal models, analyze historical data, interact with other agents, use real-time sensing, or employ advanced machine learning techniques. These methods enable agents to estimate future environmental or internal conditions and adjust their behaviors to improve their chances of meeting their objectives.

  • Interactions in ABM:

    • Agent-Agent Interactions: Various forms of Communication, cooperation, competetion, adaptation. These involve sharing of information, exchanging resources, competing for limited resources, coordinating actions, adapting behaviours based on others' actions and influencing each other's decision making process

    • Agent-Environment Interactions

    • Environment-Agent Interactions

    • Environment-Environment Interactions

 

  • How do Agents interact with other Agents?

    • Agents are at the same location

      • Agents are at same cell/within a threshold distance/can see each other/belong to same neighbourhood or in same room

    • Agent broadcasts information to all other agents
      • Interaction is one-sided
      • Agent that broadcasts this information does not know the other agents and does not take actions ensuring that a specific agent will receive the information.
      • Intercom agent is an example in Fire Simulation Case.
    • Agents belong to same group
      • Groups in ABM are called collectives
      • Information shared automatically within collective
    • Agents are connected via a social network
      • Communication is in both directions
      • No physical contact needed
      • New links can be formed and links can be broken
  • What happens to an agent when there is interaction?
    • Information will be stored
    • State of agent can change
    • Behaviour of the transmitting agent, after interaction might change
    • Behaviour of all other agents will change
  • Direct Interactions: interactions in which individuals encounter and affect others
  • Indirect Interactions: the agent perceives the action of another agent and the possible impact this has on their own situation.
  • ODD Protocol

---------------------------------------------------------------------------------------------------------------------------------

5. Integrating ABM and ML

Integration of ABM with ML

Examples

1. Abstract Simulation

Definition:

  • Abstract simulations use theoretical constructs and simplified models to explore general principles and hypotheses without a direct reference to real-world data.

Characteristics:

  • Theoretical Basis: Based on abstract theories and models.
  • Simplification: Simplifies complex systems to focus on fundamental aspects.
  • Exploratory: Used for exploring ideas, concepts, and theoretical scenarios.

 

2. Experimental Simulation

Definition:

  • Experimental simulations are used to test hypotheses and explore the behavior of systems under controlled conditions. They often mimic experiments conducted in a lab.

Characteristics:

  • Controlled Conditions: Conducted in a controlled environment to isolate variables.
  • Hypothesis Testing: Used to test specific hypotheses or theories.
  • Repeatability: Can be repeated under the same conditions to verify results.

3. Historical Simulation

Definition:

  • Historical simulations aim to recreate and study past events or processes using historical data and known facts.

Characteristics:

  • Historical Data: Relies on data and records from past events.
  • Reconstruction: Reconstructs historical events to understand their dynamics and consequences.
  • Validation: Validates models against known historical outcomes.

 

4. Empirical Simulation

Definition:

  • Empirical simulations are based on observed data and real-world measurements. They use empirical evidence to build and validate models.

Characteristics:

  • Data-Driven: Relies heavily on empirical data and observations.
  • Validation and Calibration: Models are validated and calibrated using real-world data.
  • Predictive: Often used to make predictions about future events or behaviors.

=======================================================

Comparison of Behavior and Pattern emergence:

  • Behavior vs. Pattern: Emergent behavior focuses on the actions and interactions of individual components (e.g., birds flying and coordinating), while pattern emergence focuses on the observable structures or arrangements that result from these interactions (e.g., flock formations).
  • Nature of Emergence: Behavior emergence emphasizes how complex actions arise from simple rules at the micro level, whereas pattern emergence highlights how these actions lead to visible and often repetitive structures at the macro level.

Summary

Emergent behavior and pattern emergence are fundamental concepts in modeling complex systems:

  • Emergent Behavior: Complex actions and interactions arising from simple rules at the individual level.
  • Pattern Emergence: Observable and repetitive spatial, temporal, or spatiotemporal structures resulting from the interactions of components.

=====================================================================

|If the dataset has too many features??

This dataset has too many features (i.e., the number of features is more than the number of observations). So we face the Curse of Dimensionality. If we have more features than observations, we have the risk of overfitting in supervised learning, so the performance will drop. Moreover, the observations become harder to cluster. When we have too many features, the observations appear at equal distances from each other. So defining meaningful clusters will be hard

The curse of dimensionality refers to the difficulties that arise when analyzing or modeling data with many dimensions. These problems can be summarized in the following points: Data Sparsity: Data points become increasingly spread out, making it hard to find patterns or relationships.

=====================================================================

PCA vs K-means clustering

PCA and k-means clustering are both unsupervised machine learning techniques used for data analysis, but they have different goals and methods. PCA is used to reduce the dimensionality of the data, while k-means clustering groups data points together based on similarity. The technique you select depends on the specific dataset and goals of your analysis.

PCA creates new variables, i.e. principal components, that are linear combinations of the original variables. PCA takes a dataset with multiple variables as input, and it produces a dataset into a lower subspace, that is, a reduced dataset with fewer variables. It is often used in exploratory data analysis for building predictive models, but it is also used in data preprocessing for dimensionality reduction.

K-means is a clustering algorithm that assigns data points to clusters based on their distance from the cluster centers. It takes a dataset with one or more variables as input, and it produces a set of clusters with similar data points. It is often used to cluster data for a variety of use cases, such as image segmentation, customer segmentation, and anomaly detection.

=====================================================================

The outcome variable is also called the response or dependent variable, and the risk factors and confounders are called the predictors, or explanatory or independent variables. In regression analysis, the dependent variable is denoted "Y" and the independent variables are denoted by "X".

=====================================================================

How to

Machine Learning Concepts:

  • Components in artificial neural networks

    ANNs comprise several components like the ones below.

  • Inputs: They’re usually represented as features of a dataset which are passed on to a neural network to make predictions.
  • Weights: These are the real values associated with the features. They are significant as they tell the importance of each feature which is passed as an input to the artificial neural network.
  • Bias: Bias in a neural network is required to shift the activation function across the plane either towards the left or the right. We will cover it in more detail later.
  • Summation function: It is defined as the function which sums up the product of the weight and the features with bias.
  • Activation function: It is required to add non-linearity to the neural network model. We introduce non-linearity, means that an output cannot be reproduced from a linear combination of the inputs. Therefore without a non-linear activation function in a neural-network, even though it may have hundreds of hidden layers it would still behave like a single-layer perceptron.

===================================================================

Box Plots

Box plots (also known as box and whisker plots) provide a visualization that provide three key benefits compared to other visualization of data:

  1. Box plots show the size of the center quartiles and the values of Q1, Q2, and Q3.

  2. Box plots show the inter quartile range (commonly called the IQR), a measure of the spread of the data. The IQR is the value of Q3 - Q1.

    The IQR tells us the range of the middle 50% of the data. In other words, it tells us the width of the “box” on the box plot.

  3. Box plots show outliers in the dataset. Outliers are data points that differ significantly from most of the other points in the dataset. In other words, they “lie outside” most of the data. They are plotted as single dots on a box plot. You can calculate outliers mathematically using these rules:

    • Low Outliers: All values less than Q1 - (1.5 × IQR).
    • High Outliers: All values greater than Q3 + (1.5 × IQR).
       

    Outliers can be typos, lies, or real data! Outliers can have a strong effect on certain statistics (like the average) so it’s important that as a data scientist, you recognize outliers and decide if you want to include them in your analysis. Outliers should only be excluded from analysis for a good reason!

=-==================================================================

ESDA

INTRO TO ML

k-MEANS

ANN_SOM

===================================================================

Solving a K-means problem:

Given 2 random centres, for an iteration of 2 times,
Compute distance of all points from the 2 centres and fill in the table and give label as the class with the minimum distance
update cluster centre: all points within 1 cluster, compute average x and y
Now this value becomes the 2 centres, compute distance and label and compute new centre.

-------------------------------------------------------------------------------------------------------------------

A model that exhibits small variance and high bias will underfit the target, while a model with high variance and little bias will overfit the target. A model with high variance may represent the data set accurately but could lead to overfitting to noisy or otherwise unrepresentative training data.

====================================================================

Feature Selection

Definition:

  • Feature selection involves selecting a subset of the most relevant features from the original set of features.
  • The objective is to identify and retain the most important features while discarding irrelevant or redundant ones.
  • Key Points:

  • Subset Selection: Features are directly chosen from the original set.
  • Methods: Include filter methods (e.g., correlation, statistical tests), wrapper methods (e.g., recursive feature elimination), and embedded methods (e.g., regularization).

Feature Extraction

Definition:

  • Feature extraction involves transforming the original features into a new set of features.
  • The transformation is typically done using techniques like Principal Component Analysis (PCA), Independent Component Analysis (ICA), or autoencoders.
  • Key Points:

  • Transformation: Creates new features that are combinations of the original features.
  • Dimensionality Reduction: Reduces the number of features by transforming them into a lower-dimensional space.