Skip to content

Commit

Permalink
v0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBlanke committed Jun 9, 2019
1 parent 2aa8eb0 commit fca749a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,49 @@ prediction = Optimizer.predict(X_test)
score = Optimizer.score(X_test, y_test)
```

Example with a feedforward neural network in keras (experimental):
```python
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split

from hyperactive import ParticleSwarm_Optimizer

breast_cancer_data = load_breast_cancer()
X = breast_cancer_data.data
y = breast_cancer_data.target

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)

# this defines the structure of the model and the search space in each layer
search_config = {
"keras.compile.0": {"loss": ["binary_crossentropy"], "optimizer": ["adam"]},
"keras.fit.0": {"epochs": [5], "batch_size": [100]},
"keras.layers.Dense.1": {
"units": range(5, 15),
"activation": ["relu"],
"kernel_initializer": ["uniform"],
},
"keras.layers.Dense.2": {
"units": range(5, 15),
"activation": ["relu"],
"kernel_initializer": ["uniform"],
},
"keras.layers.Dense.3": {"units": [1], "activation": ["sigmoid"]},
}
Optimizer = ParticleSwarm_Optimizer(search_config, 3, cv=1)

# search best hyperparameter for given data
Optimizer.fit(X_train, y_train)

# predict from test data
prediction = Optimizer.predict(X_test)

# calculate accuracy score
score = Optimizer.score(X_test, y_test)
```




## Hyperactive API

Expand Down
2 changes: 1 addition & 1 deletion hyperactive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .simulated_annealing import SimulatedAnnealing_Optimizer
from .particle_swarm_optimization import ParticleSwarm_Optimizer

__version__ = "0.1.3"
__version__ = "0.1.4"
__license__ = "MIT"

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="hyperactive",
version="0.1.3",
version="0.1.4",
author="Simon Blanke",
author_email="[email protected]",
license="MIT",
Expand Down

0 comments on commit fca749a

Please sign in to comment.