Skip to content

Commit

Permalink
Updated requirements.txt and README.md (#194)
Browse files Browse the repository at this point in the history
* Update requirements.txt (numpy version)

* README updated (add MCO example)

* Update README.md
  • Loading branch information
ashtanyuk committed Jun 4, 2024
1 parent e66c7c4 commit 5c7315a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
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 multicriteria optimization. We use optimization for two float objectives: 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.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy>=1.19
numpy>=1.19,<2.0
depq
cycler
kiwisolver
Expand Down

0 comments on commit 5c7315a

Please sign in to comment.