Skip to content

Commit

Permalink
bug BN learning
Browse files Browse the repository at this point in the history
  • Loading branch information
VicentePerezSoloviev committed Sep 29, 2023
1 parent 305b370 commit 451f992
Show file tree
Hide file tree
Showing 91 changed files with 110 additions and 99 deletions.
18 changes: 10 additions & 8 deletions EDAspy.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Metadata-Version: 2.1
Name: EDAspy
Version: 1.1.1
Version: 1.1.2
Summary: EDAspy is a Python package that implements Estimation of Distribution Algorithms. EDAspy allows toeither use already existing implementations or customize the EDAs baseline easily building it bymodules so new research can be easily developed. It also has several benchmarks for comparisons.
Home-page: https://github.com/VicentePerezSoloviev/EDAspy
Author: Vicente P. Soloviev
Author-email: [email protected]
License: MIT
Download-URL: https://github.com/VicentePerezSoloviev/EDAspy/archive/1.1.1.tar.gz
Download-URL: https://github.com/VicentePerezSoloviev/EDAspy/archive/1.1.2.tar.gz
Description: # <img src='https://raw.githubusercontent.com/VicentePerezSoloviev/EDAspy/master/Logo%20EDAspy.png' align="right" height="150"/>

[![PyPI](https://img.shields.io/pypi/v/edaspy)](https://pypi.python.org/pypi/EDAspy/)
[![PyPI license](https://img.shields.io/pypi/l/EDAspy.svg)](https://pypi.python.org/pypi/EDAspy/)
[![Downloads](https://static.pepy.tech/personalized-badge/edaspy?period=total&units=none&left_color=grey&right_color=blue&left_text=downloads)](https://pepy.tech/project/edaspy)
[![Downloads](https://static.pepy.tech/badge/edaspy)](https://pepy.tech/project/edaspy)
[![Documentation Status](https://readthedocs.org/projects/edaspy/badge/?version=latest)](https://edaspy.readthedocs.io/en/latest/?badge=latest)

# EDAspy
Expand Down Expand Up @@ -48,7 +48,10 @@ Description: # <img src='https://raw.githubusercontent.com/VicentePerezSoloviev/
* UMDAc: Univariate Marginal Distribution Algorithm continuous [3]. In this EDA all the variables assume a Gaussian distribution and there are not dependencies considered between the variables. Some usages include hyperparameter optimization, for example.


* UnivariateKEDA: Univariate Kernel Estimation of Distribution Algorithm [4]. Each variables distribution is estimated using Kernel Density Estimation.
* UnivariateKEDA: Univariate Kernel Estimation of Distribution Algorithm [4]. Each variables distribution is estimated using Kernel Density Estimation.


* UMDAcat: Univariate Marginal Distribution Algorithm categorical [2]. UMDA variant for categorical data, where more than two possible values per dimension are used (otherwise, use binary version).


* EGNA: Estimation of Gaussian Distribution Algorithm [5][6]. This is a complex implementation in which dependencies between the variables are considered during the optimization. In each iteration, a Gaussian Bayesian network is learned and sampled. The variables in the model are assumed to be Gaussian and also de dependencies between them. This implementation is focused in continuous optimization.
Expand All @@ -63,7 +66,7 @@ Description: # <img src='https://raw.githubusercontent.com/VicentePerezSoloviev/
* MultivariateKEDA: Special case of SPEDA approach in which all nodes are restricted to be estimated using KDE (Gaussian nodes are forbidden) [7]. It is also an archive-based approach.


* Categorical EDA. In this implementation we consider some independent categorical variables. Some usages include portfolio optimization, for exampled.
* EBNA: Estimation of Bayesian Network Algorithm [1]. This version of EDAs is used for categorical data. The probabilistic model used is a Categorical Bayesian network, where conditional dependencies between variables can be analyzed.


Some tools are also available in EDAspy such as the Bayesian network structure plotting, for visualizing the graph learnt in some of the implementations, if needed.
Expand Down Expand Up @@ -99,7 +102,7 @@ Description: # <img src='https://raw.githubusercontent.com/VicentePerezSoloviev/
```bash
git clone https://github.com/VicentePerezSoloviev/EDAspy.git
cd EDAspy
git checkout v1.0.0 # You can checkout a specific version if you want
git checkout v1.1.2 # You can checkout a specific version if you want
python setup.py install
```
## Testing
Expand Down Expand Up @@ -133,12 +136,11 @@ Description: # <img src='https://raw.githubusercontent.com/VicentePerezSoloviev/

[7] Soloviev, Vicente P.& Bielza, Concha & Larrañaga, Pedro (2023). Semiparametric Estimation of Distribution Algorithms for continuous optimization. IEEE Transactions on Evolutionary Computation.


Keywords: EDA,estimation,bayesian,evolutionary,algorithm,optimization,time_series,feature,selection,semiparametric,Gaussian
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.0
Requires-Python: >=3.8
Description-Content-Type: text/markdown
43 changes: 27 additions & 16 deletions EDAspy.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,53 @@ EDAspy/optimization/custom/__init__.py
EDAspy/optimization/custom/eda_custom.py
EDAspy/optimization/custom/initialization_models/__init__.py
EDAspy/optimization/custom/initialization_models/_generation_init.py
EDAspy/optimization/custom/initialization_models/categorical_geninit.py
EDAspy/optimization/custom/initialization_models/latin_hypercube_sampling_geninit.py
EDAspy/optimization/custom/initialization_models/multi_gauss_geninit.py
EDAspy/optimization/custom/initialization_models/uni_bin_geninit.py
EDAspy/optimization/custom/initialization_models/uni_gauss_geninit.py
EDAspy/optimization/custom/initialization_models/uniform_geninit.py
EDAspy/optimization/custom/probabilistic_models/__init__.py
EDAspy/optimization/custom/probabilistic_models/_probabilistic_model.py
EDAspy/optimization/custom/probabilistic_models/discrete_bayesian_network.py
EDAspy/optimization/custom/probabilistic_models/gaussian_bayesian_network.py
EDAspy/optimization/custom/probabilistic_models/kde_bayesian_network.py
EDAspy/optimization/custom/probabilistic_models/multivariate_gaussian.py
EDAspy/optimization/custom/probabilistic_models/semiparametric_bayesian_network.py
EDAspy/optimization/custom/probabilistic_models/univariate_binary.py
EDAspy/optimization/custom/probabilistic_models/univariate_categorical.py
EDAspy/optimization/custom/probabilistic_models/univariate_gaussian.py
EDAspy/optimization/custom/probabilistic_models/univariate_kde.py
EDAspy/optimization/multivariate/__init__.py
EDAspy/optimization/multivariate/ebna.py
EDAspy/optimization/multivariate/egna.py
EDAspy/optimization/multivariate/emna.py
EDAspy/optimization/multivariate/keda.py
EDAspy/optimization/multivariate/speda.py
EDAspy/optimization/univariate/__init__.py
EDAspy/optimization/univariate/keda.py
EDAspy/optimization/univariate/umda_binary.py
EDAspy/optimization/univariate/umda_categorical.py
EDAspy/optimization/univariate/umda_continuous.py
EDAspy/timeseries/TS_transformations.py
EDAspy/timeseries/TransformationsFeatureSelection.py
EDAspy/timeseries/__init__.py
tests/__init__.py
tests/test_egna.py
tests/test_emna.py
tests/test_gbn.py
tests/test_geninit.py
tests/test_kdebn.py
tests/test_keda.py
tests/test_multivariate_keda.py
tests/test_pm.py
tests/test_spbn.py
tests/test_speda.py
tests/test_umdac.py
tests/test_umdad.py
tests/test_univariate_keda.py
tests/edas_multivariate/__init__.py
tests/edas_multivariate/test_ebna.py
tests/edas_multivariate/test_egna.py
tests/edas_multivariate/test_emna.py
tests/edas_multivariate/test_multivariate_keda.py
tests/edas_multivariate/test_speda.py
tests/edas_univariate/__init__.py
tests/edas_univariate/test_umdac.py
tests/edas_univariate/test_umdacat.py
tests/edas_univariate/test_umdad.py
tests/edas_univariate/test_univariate_keda.py
tests/inits/__init__.py
tests/inits/test_geninit.py
tests/pms/__init__.py
tests/pms/test_discrete_bn.py
tests/pms/test_gbn.py
tests/pms/test_kdebn.py
tests/pms/test_spbn.py
tests/pms/test_uni_bin_pm.py
tests/pms/test_uni_cat_pm.py
tests/pms/test_uni_gauss_pm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import pandas as pd
from pgmpy.models import BayesianNetwork
from pgmpy.estimators import BicScore, ExhaustiveSearch, MaximumLikelihoodEstimator
from pgmpy.estimators import HillClimbSearch, MaximumLikelihoodEstimator

from ._probabilistic_model import ProbabilisticModel

Expand Down Expand Up @@ -47,9 +47,8 @@ def learn(self, dataset: np.array, *args, **kwargs):
self.pm.add_nodes_from(self.variables)

# learn structure
bic = BicScore(data)
es = ExhaustiveSearch(data, scoring_method=bic)
best_structure = es.estimate()
es = HillClimbSearch(data)
best_structure = es.estimate(scoring_method='bicscore', max_iter=1000, show_progress=False)

for edge in best_structure.edges():
self.pm.add_edge(edge[0], edge[1])
Expand Down
Binary file modified docs/_build/doctrees/EDAspy.benchmarks.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/EDAspy.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/EDAspy.optimization.custom.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/_build/doctrees/EDAspy.optimization.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/EDAspy.optimization.multivariate.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/EDAspy.optimization.univariate.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/categorical_optimization.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/changelog.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/eda_custom.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/egna_opt.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/emna_opt.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/examples.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/feature_selection_umdad.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/hyperparameter_umdac.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/index.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/installation.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/introduction.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/modules.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/multivariate_keda_opt.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/speda_opt.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/_build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 548cc20651cbb788240a69431335e19f
config: b17ce3ec747fb292f205046b405d7595
tags: 645f666f9bcd5a90fca523b33c5a78b7
2 changes: 1 addition & 1 deletion docs/_build/html/EDAspy.benchmarks.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.benchmarks package &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.benchmarks package &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/EDAspy.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy package &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy package &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/EDAspy.optimization.custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization.custom package &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization.custom package &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization.custom.initialization_models package &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization.custom.initialization_models package &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization.custom.probabilistic_models package &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization.custom.probabilistic_models package &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/EDAspy.optimization.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization package &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization package &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/EDAspy.optimization.multivariate.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization.multivariate package &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization.multivariate package &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/EDAspy.optimization.univariate.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization.univariate package &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization.univariate package &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/_modules/EDAspy/benchmarks/binary.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.benchmarks.binary &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.benchmarks.binary &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.benchmarks.continuous &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.benchmarks.continuous &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization.custom.eda_custom &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization.custom.eda_custom &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization.custom.initialization_models.categorical_geninit &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization.custom.initialization_models.categorical_geninit &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="../../../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization.custom.initialization_models.latin_hypercube_sampling_geninit &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization.custom.initialization_models.latin_hypercube_sampling_geninit &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="../../../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization.custom.initialization_models.multi_gauss_geninit &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization.custom.initialization_models.multi_gauss_geninit &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="../../../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization.custom.initialization_models.uni_bin_geninit &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization.custom.initialization_models.uni_bin_geninit &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="../../../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization.custom.initialization_models.uni_gauss_geninit &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization.custom.initialization_models.uni_gauss_geninit &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="../../../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EDAspy.optimization.custom.initialization_models.uniform_geninit &mdash; EDAspy 1.1.2 documentation</title>
<title>EDAspy.optimization.custom.initialization_models.uniform_geninit &mdash; EDAspy 1.1.3 documentation</title>
<link rel="stylesheet" href="../../../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
Loading

0 comments on commit 451f992

Please sign in to comment.