-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Append new examples. Correct documentation
- Loading branch information
Showing
26 changed files
with
1,025 additions
and
26 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+123 KB
examples/Machine_learning/SVC/_2D/output/svc2d_transformator_state_stat1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.7 KB
examples/Machine_learning/SVC/_2D/output/svc2d_transformator_state_stat2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
examples/Machine_learning/XGBoostRegression/_3D/Example_XGBR_3D_Gasturbine.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from examples.Machine_learning.XGBoostRegression._3D.Problems import XGB_3D | ||
from iOpt.output_system.listeners.console_outputers import ConsoleOutputListener | ||
from iOpt.output_system.listeners.static_painters import StaticDiscreteListener | ||
from iOpt.solver import Solver | ||
from iOpt.solver_parametrs import SolverParameters | ||
from sklearn.utils import shuffle | ||
import numpy as np | ||
import csv | ||
|
||
def gasturbine_Dataset(): | ||
x = [] | ||
y = [] | ||
with open(r"../Datasets/no_predict.csv") as file: | ||
file_reader = csv.reader(file, delimiter=";") | ||
for row in file_reader: | ||
x_row = [] | ||
for i in range(len(row)-1): | ||
x_row.append(row[i]) | ||
x.append(x_row) | ||
y.append(row[len(row)-1]) | ||
return shuffle(np.array(x, dtype=np.float32), np.array(y, dtype=np.float32), random_state=42) | ||
|
||
|
||
if __name__ == "__main__": | ||
X, Y = gasturbine_Dataset() | ||
learning_rate_bound = {'low': 0.2, 'up': 0.4} | ||
gamma_bound = {'low': 0.2, 'up': 0.3} | ||
booster_type = {'booster': ['gblinear', 'gbtree', 'dart']} | ||
|
||
problem = XGB_3D.XGB_3D(X, Y, learning_rate_bound, gamma_bound, booster_type) | ||
method_params = SolverParameters(r=np.double(2.0), iters_limit=1000, number_of_parallel_points=16, | ||
evolvent_density=12) | ||
solver = Solver(problem, parameters=method_params) | ||
apl = StaticDiscreteListener("experiment1.png", mode='analysis') | ||
solver.add_listener(apl) | ||
apl = StaticDiscreteListener("experiment2.png", mode='bestcombination', calc='interpolation', mrkrs=4) | ||
solver.add_listener(apl) | ||
cfol = ConsoleOutputListener(mode='full') | ||
solver.add_listener(cfol) | ||
solver_info = solver.solve() |
64 changes: 64 additions & 0 deletions
64
examples/Machine_learning/XGBoostRegression/_3D/Problems/XGB_3D.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import numpy as np | ||
import xgboost as xgb | ||
from iOpt.trial import Point | ||
from iOpt.trial import FunctionValue | ||
from iOpt.problem import Problem | ||
from sklearn.svm import SVC | ||
from sklearn.model_selection import cross_val_score | ||
from typing import Dict, List | ||
from sklearn.pipeline import Pipeline | ||
from sklearn.preprocessing import StandardScaler | ||
from sklearn.metrics import r2_score | ||
|
||
class XGB_3D(Problem): | ||
""" | ||
Класс XGB_3D представляет возможность поиска оптимального набора гиперпараметров алгоритма XGBoost regression | ||
Найденные параметры являются оптимальными при варьировании параматра скорости обучения | ||
(learning_rate), коэфицента определения минимального снижения потерь (gamma) и типа модели (booster) | ||
""" | ||
|
||
def __init__(self, x_dataset: np.ndarray, y_dataset: np.ndarray, | ||
learning_rate_bound: Dict[str, float], | ||
gamma_bound: Dict[str, float], | ||
booster_type: Dict[str, List[str]] | ||
): | ||
""" | ||
Конструктор класса SVC_3D | ||
:param x_dataset: входные данные обучающе выборки метода SVC | ||
:param y_dataset: выходные данные обучающе выборки метода SVC | ||
:param learning_rate_bound: Границы изменения значений параметра скорости обучения | ||
:param gamma_bound: Границы изменения значений параметра gамма, определяющего минимальное снижение потерь | ||
:param booster_type: Тип модели, для каждой итерации алгоритма XGBoost | ||
""" | ||
super(XGB_3D, self).__init__() | ||
self.dimension = 3 | ||
self.number_of_float_variables = 2 | ||
self.number_of_discrete_variables = 1 | ||
self.number_of_objectives = 1 | ||
self.number_of_constraints = 0 | ||
if x_dataset.shape[0] != y_dataset.shape[0]: | ||
raise ValueError('The input and output sample sizes do not match.') | ||
self.x = x_dataset | ||
self.y = y_dataset | ||
self.float_variable_names = np.array(["learning_rate", "gamma"], dtype=str) | ||
self.lower_bound_of_float_variables = np.array([learning_rate_bound['low'], gamma_bound['low']], | ||
dtype=np.double) | ||
self.upper_bound_of_float_variables = np.array([learning_rate_bound['up'], gamma_bound['up']], | ||
dtype=np.double) | ||
self.discrete_variable_names.append('booster') | ||
self.discrete_variable_values.append(booster_type['booster']) | ||
|
||
|
||
def calculate(self, point: Point, function_value: FunctionValue) -> FunctionValue: | ||
""" | ||
Метод расчёта значения целевой функции в точке | ||
:param point: Точка испытания | ||
:param function_value: объект хранения значения целевой функции в точке | ||
""" | ||
learning_rate, gamma = point.float_variables[0], point.float_variables[1] | ||
booster = point.discrete_variables[0] | ||
regr = xgb.XGBRegressor(learning_rate=learning_rate, gamma=gamma, booster=booster) | ||
function_value.value = -cross_val_score(regr, self.x, self.y, scoring='r2', cv=5).mean() | ||
return function_value |
Empty file.
Empty file.