From 5c7315a899e406b4e856477219955fcdf9801c3d Mon Sep 17 00:00:00 2001 From: "Anton A. Shtanyuk" Date: Tue, 4 Jun 2024 09:30:36 +0300 Subject: [PATCH] Updated requirements.txt and README.md (#194) * Update requirements.txt (numpy version) * README updated (add MCO example) * Update README.md --- README.md | 45 ++++++++++++++++++++++++++++++++++++++++++++- requirements.txt | 2 +- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1d292bef..927406b5 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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. \ No newline at end of file +of [ITMO University](https://en.itmo.ru/) as part of the plan of the center's program: Framework of intelligent heuristic optimization methods. diff --git a/requirements.txt b/requirements.txt index c5aeb5e9..e00b31b1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy>=1.19 +numpy>=1.19,<2.0 depq cycler kiwisolver