pm4py.algo.evaluation.earth_mover_distance.variants.pyemd module#

PM4Py – A Process Mining Library for Python Copyright (C) 2026 Process Intelligence Solutions GmbH

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see this software project’s root or visit <https://www.gnu.org/licenses/>.

Website: https://processintelligence.solutions Contact: info@processintelligence.solutions

class pm4py.algo.evaluation.earth_mover_distance.variants.pyemd.Parameters[source]#

Bases: object

STRING_DISTANCE = 'string_distance'#
USE_FAST_EMD = 'use_fast_emd'#
pm4py.algo.evaluation.earth_mover_distance.variants.pyemd.normalized_levensthein(s1, s2)[source]#
pm4py.algo.evaluation.earth_mover_distance.variants.pyemd.get_act_correspondence(activities, parameters=None)[source]#
pm4py.algo.evaluation.earth_mover_distance.variants.pyemd.encode_two_languages(lang1, lang2, parameters=None)[source]#
class pm4py.algo.evaluation.earth_mover_distance.variants.pyemd.EMDCalculator[source]#

Bases: object

A class that provides an EMD (Earth Mover’s Distance) computation similar to what pyemd offers. It uses linear programming via scipy.optimize.linprog to solve the underlying flow problem.

Usage:#

emd_value = EMDCalculator.emd(first_histogram, second_histogram, distance_matrix)

static emd(first_histogram: ndarray, second_histogram: ndarray, distance_matrix: ndarray) → float[source]#

Compute the Earth Mover’s Distance given two histograms and a distance matrix.

Parameters:
  • first_histogram (np.ndarray) – The first distribution (array of nonnegative numbers).

  • second_histogram (np.ndarray) – The second distribution (array of nonnegative numbers).

  • distance_matrix (np.ndarray) – Matrix of distances between points of the two distributions.

Returns:

The computed EMD value.

Return type:

float

class pm4py.algo.evaluation.earth_mover_distance.variants.pyemd.POTEMDCalculator[source]#

Bases: object

A faster implementation of EMD using the POT (Python Optimal Transport) library. Falls back to the SciPy implementation if POT is not available.

Usage:#

emd_value = POTEMDCalculator.emd(first_histogram, second_histogram, distance_matrix)

static is_pot_available()[source]#

Check if POT (Python Optimal Transport) is available.

static emd(first_histogram: ndarray, second_histogram: ndarray, distance_matrix: ndarray) → float[source]#

Compute the Earth Mover’s Distance using POT if available, otherwise fall back to SciPy.

Parameters:
  • first_histogram (np.ndarray) – The first distribution (array of nonnegative numbers).

  • second_histogram (np.ndarray) – The second distribution (array of nonnegative numbers).

  • distance_matrix (np.ndarray) – Matrix of distances between points of the two distributions.

Returns:

The computed EMD value.

Return type:

float

pm4py.algo.evaluation.earth_mover_distance.variants.pyemd.apply(lang1: Dict[List[str], float], lang2: Dict[List[str], float], parameters: Dict[str | Parameters, Any] | None = None) → float[source]#