Skip to content

Commit

Permalink
Merge pull request #4 from VicentePerezSoloviev/devel
Browse files Browse the repository at this point in the history
change package name
  • Loading branch information
VicentePerezSoloviev authored Jun 10, 2020
2 parents 10d1669 + fbda824 commit 89c3d45
Show file tree
Hide file tree
Showing 51 changed files with 2,310 additions and 192 deletions.
18 changes: 0 additions & 18 deletions EDApy.egg-info/SOURCES.txt

This file was deleted.

2 changes: 0 additions & 2 deletions EDApy.egg-info/top_level.txt

This file was deleted.

60 changes: 49 additions & 11 deletions EDApy.egg-info/PKG-INFO → EDAspy.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Metadata-Version: 2.1
Name: EDApy
Version: 0.0.1
Name: EDAspy
Version: 0.1.0
Summary: This is a package where some estimation of distribution algorithms are implemented.
Home-page: https://github.com/VicentePerezSoloviev/EDApy
Home-page: https://github.com/VicentePerezSoloviev/EDAspy
Author: Vicente P. Soloviev
Author-email: vicente.perez.soloviev@gmail.com
License: UNKNOWN
Description: # EDApy
License: LGPL-2.1
Download-URL: https://github.com/VicentePerezSoloviev/EDAspy/archive/0.1.0.tar.gz
Description: # EDAspy

## Description

Expand All @@ -22,7 +23,7 @@ Description: # EDApy
#### Binary univariate EDA
It can be used as a simple example of EDA, or to use it for feature selection. The cost function to optimize is the metric of the model. An example is shown.
```python
from EDApy.optimization.univariate import EDA_discrete as EDAd
from EDAspy.optimization.univariate import EDA_discrete as EDAd
import pandas as pd

def check_solution_in_model(dictionary):
Expand Down Expand Up @@ -51,7 +52,7 @@ Description: # EDApy

This EDA is used when some continuous parameters must be optimized.
```python
from EDApy.optimization.univariate import EDA_continuous as EDAc
from EDAspy.optimization.univariate import EDA_continuous as EDAc
import pandas as pd
import numpy as np

Expand Down Expand Up @@ -89,7 +90,7 @@ Description: # EDApy
The optimizer will find the optimum values of the non-evidence-variables based on the value of the evidences. This is widely used in problems where dependencies among variables must be considered.

```python
from EDApy.optimization.multivariate import EDA_multivariate as EDAm
from EDAspy.optimization.multivariate import EDA_multivariate as EDAm
import pandas as pd

blacklist = pd.DataFrame(columns=['from', 'to'])
Expand All @@ -115,12 +116,47 @@ Description: # EDApy

In this case, the output is the self class that can be saved as a pickle in order to explore the attributes. One of the attributes is the optimum structure of the optimum generation, from which the structure can be plotted and observe the dependencies among the variables. The function to plot the structure is the following:
```python
from EDApy.optimization.multivariate import print_structure
from EDAspy.optimization.multivariate import print_structure
print_structure(structure=structure, var2optimize=['param2', 'param3', 'param4'], evidences=['param1', 'param5'])
```

![Structure praph plot](/structure.PNG "Structure of the optimum generation found by the EDA")

#### Another Continuous multivariate EDA approach

In this EDA approach, new individuals are sampled from a multivariate normal distribution. Evidences are not allowed in the optimizer. If desired, the previous approach should be used.
The EDA is initialized, as in the univariate continuous EDA, with univariate mus and sigma for the variables. In the execution, a multivariate gaussian is built to sample from it. As it is multivariate, correlation among variables is considered.

```python
import pandas as pd
from EDAspy.optimization.multivariate import EDA_multivariate_gaussian as EDAmg


def cost_function(dictionary):
suma = dictionary['param1'] + dictionary['param2']
if suma < 0:
return 999999999
return suma

mus = pd.DataFrame(columns=['param1', 'param2'])
mus.loc[0] = [10, 8]

sigma = pd.DataFrame(columns=['param1', 'param2'])
sigma.loc[0] = 5

EDAmulti = EDAmg(SIZE_GEN=40, MAX_ITER=1000, DEAD_ITER=50, ALPHA=0.6, aim='minimize',
cost_function=cost_function, mus=mus, sigma=sigma)

bestcost, params, history = EDAmulti.run(output=True)
print(bestcost)
print(params)
print(history)
```

The cost function to optimize is the minimization of two parameter sum. Both parameters are continuous, and to be initialized two pandas dataframes are needed: one with mus and another with sigmas (diagonal of the covariance matrix)

The EDA returns the best cost, the combination and the history of costs if wanted to be plotted.

## Getting started

#### Prerequisites
Expand All @@ -129,12 +165,14 @@ Description: # EDApy

#### Installing
```
pip install git+https://github.com/vicenteperezsoloviev/EDApy.git#egg=EDApy
pip install git+https://github.com/vicenteperezsoloviev/EDAspy.git#egg=EDApy
```

Keywords: EDA,estimation,bayesian,evolutionary,algorithm,optimization
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: License :: OSI Approved :: LGPL-2.1
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
18 changes: 18 additions & 0 deletions EDAspy.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
README.md
setup.py
EDAspy/__init__.py
EDAspy.egg-info/PKG-INFO
EDAspy.egg-info/SOURCES.txt
EDAspy.egg-info/dependency_links.txt
EDAspy.egg-info/top_level.txt
EDAspy/optimization/__init__.py
EDAspy/optimization/multivariate/EDA_multivariate.py
EDAspy/optimization/multivariate/EDA_multivariate_gaussian.py
EDAspy/optimization/multivariate/__BayesianNetwork.py
EDAspy/optimization/multivariate/__clustering.py
EDAspy/optimization/multivariate/__init__.py
EDAspy/optimization/multivariate/__matrix.py
EDAspy/optimization/univariate/__init__.py
EDAspy/optimization/univariate/continuous.py
EDAspy/optimization/univariate/discrete.py
tests/__init__.py
File renamed without changes.
2 changes: 2 additions & 0 deletions EDAspy.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
EDAspy
tests
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def check_package(installed_pack, package):
else:
return False


if sys.version_info[0] < 3:
raise Exception("Python version should be greater than 3")

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# EDApy
# EDAspy

## Description

Expand All @@ -14,7 +14,7 @@ Three EDAs have been implemented:
#### Binary univariate EDA
It can be used as a simple example of EDA, or to use it for feature selection. The cost function to optimize is the metric of the model. An example is shown.
```python
from EDApy.optimization.univariate import EDA_discrete as EDAd
from EDAspy.optimization.univariate import EDA_discrete as EDAd
import pandas as pd

def check_solution_in_model(dictionary):
Expand Down Expand Up @@ -43,7 +43,7 @@ Vector probabilities are usually initialized to 0.5 to start from an equilibrium

This EDA is used when some continuous parameters must be optimized.
```python
from EDApy.optimization.univariate import EDA_continuous as EDAc
from EDAspy.optimization.univariate import EDA_continuous as EDAc
import pandas as pd
import numpy as np

Expand Down Expand Up @@ -81,7 +81,7 @@ In this case, dependencies among the variables are considered and managed with a
The optimizer will find the optimum values of the non-evidence-variables based on the value of the evidences. This is widely used in problems where dependencies among variables must be considered.

```python
from EDApy.optimization.multivariate import EDA_multivariate as EDAm
from EDAspy.optimization.multivariate import EDA_multivariate as EDAm
import pandas as pd

blacklist = pd.DataFrame(columns=['from', 'to'])
Expand All @@ -107,7 +107,7 @@ Due to the evidences, to help the structure learning algorithm to find the arcs,

In this case, the output is the self class that can be saved as a pickle in order to explore the attributes. One of the attributes is the optimum structure of the optimum generation, from which the structure can be plotted and observe the dependencies among the variables. The function to plot the structure is the following:
```python
from EDApy.optimization.multivariate import print_structure
from EDAspy.optimization.multivariate import print_structure
print_structure(structure=structure, var2optimize=['param2', 'param3', 'param4'], evidences=['param1', 'param5'])
```

Expand All @@ -120,7 +120,7 @@ The EDA is initialized, as in the univariate continuous EDA, with univariate mus

```python
import pandas as pd
from EDApy.optimization.multivariate import EDA_multivariate_gaussian as EDAmg
from EDAspy.optimization.multivariate import EDA_multivariate_gaussian as EDAmg


def cost_function(dictionary):
Expand Down Expand Up @@ -151,10 +151,10 @@ The EDA returns the best cost, the combination and the history of costs if wante
## Getting started

#### Prerequisites
R must be installed to use the multivariate EDA, with installed libraries c("bnlearn", "dbnR", "data.table")
R must be installed to use the multivariate EDA with Bayesian networks, with the following installed libraries: c("bnlearn", "dbnR", "data.table")
To manage R from python, rpy2 package must also be installed.

#### Installing
```
pip install git+https://github.com/vicenteperezsoloviev/EDApy.git#egg=EDApy
pip install git+https://github.com/vicenteperezsoloviev/EDAspy.git#egg=EDAspy
```
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 89c3d45

Please sign in to comment.