Skip to content

Commit

Permalink
README updated (add MCO example)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtanyuk authored May 28, 2024
1 parent 2297281 commit 0dba54f
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,49 @@ if __name__ == "__main__":

```

Let's consider an example of using multi-objective optimisation. We use optimisation of two objectives of float type: **precision** and **recall**. The result of the process is a Pareto set chart.

```python
from examples.Machine_learning.SVC._2D.Problems import mco_breast_cancer

from iOpt.solver import Solver
from iOpt.solver_parametrs import SolverParameters
from iOpt.output_system.listeners.console_outputers import ConsoleOutputListener
import matplotlib.pyplot as plt
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split

if __name__ == "__main__":

X, y = load_breast_cancer(return_X_y=True)
X_train, X_valid, y_train, y_valid = train_test_split(X, y)
problem = mco_breast_cancer.mco_breast_cancer(X, y, X_train, y_train)

params = SolverParameters(r=3.0, eps=0.01, iters_limit=200, number_of_lambdas=50,
start_lambdas=[[0, 1]], is_scaling=False)

solver = Solver(problem=problem, parameters=params)

cfol = ConsoleOutputListener(mode='full')
solver.add_listener(cfol)

sol = solver.solve()

var = [trial.point.float_variables for trial in sol.best_trials]
val = [[-trial.function_values[i].value for i in range(2)] for trial in sol.best_trials]

print("size pareto set: ", len(var))
for fvar, fval in zip(var, val):
print(fvar, fval)

fv1 = [-trial.function_values[0].value for trial in sol.best_trials]
fv2 = [-trial.function_values[1].value for trial in sol.best_trials]
plt.plot(fv1, fv2, 'ro')
plt.show()

```


# **Project Structure**

The latest stable release of iOpt is in the [main](https://github.com/UNN-ITMM-Software/iOpt/tree/main) branch. The repository includes the following directories:
Expand All @@ -170,4 +213,4 @@ A detailed description of the iOpt framework API is available at [Read the Docs]
# **Supported by**

The study is supported by the [Research Center Strong Artificial Intelligence in Industry](https://sai.itmo.ru/)
of [ITMO University](https://en.itmo.ru/) as part of the plan of the center's program: Framework of intelligent heuristic optimization methods.
of [ITMO University](https://en.itmo.ru/) as part of the plan of the center's program: Framework of intelligent heuristic optimization methods.

0 comments on commit 0dba54f

Please sign in to comment.