diff --git a/fedot_ind/tools/uml/uml.py b/fedot_ind/tools/uml/uml.py new file mode 100644 index 000000000..47dff49f1 --- /dev/null +++ b/fedot_ind/tools/uml/uml.py @@ -0,0 +1,48 @@ +import re +import os + +from fedot_ind.api.utils.path_lib import DEFAULT_PATH_MODELS + +with open(DEFAULT_PATH_MODELS, 'r') as file: + file_content = [string for string in file.read().split("\n") if not string.startswith("from")] +file_content = file_content[:next((i for i, line in enumerate(file_content) if line.startswith("def")), None)] +file_content = file_content[next((i for i, line in enumerate(file_content) if line == '}'), None) + 1:] + +pattern = re.compile(r'\b[A-Z_]+\b') + +substrings = [] +for s in file_content: + matches = pattern.findall(s) + substrings.extend(matches) +substrings = list(set(substrings)) + +res = ["@startuml", "'https://plantuml.com/sequence-diagram", "", "class AtomizedModel {", " Enum", "}", ""] +for ind in substrings: + res += ["abstract " + ind] +res += ["", ""] + +res += ["INDUSTRIAL_CLF_PREPROC_MODEL --> AtomizedModel", + "AtomizedModel <-- SKLEARN_CLF_MODELS", + "FEDOT_PREPROC_MODEL --> AtomizedModel", + "AtomizedModel <- INDUSTRIAL_PREPROC_MODEL", + "SKLEARN_REG_MODELS --> AtomizedModel", + "AtomizedModel <-- FORECASTING_MODELS", + "FORECASTING_PREPROC -> AtomizedModel", + "NEURAL_MODEL -> AtomizedModel", ""] + +for ind in substrings: + start_index = next((i for i, line in enumerate(file_content) if line.endswith(ind + " = {")), None) + end_index = next((i for i, line in enumerate(file_content[start_index:]) if line.endswith("}")), + None) + 1 + start_index + list_of_strings = file_content[start_index:end_index] + pattern = re.compile(r"': ([^']*)") + formatted_strings = [pattern.search(string).group(1) if pattern.search(string) else "" + for string in list_of_strings] + res = res + ["abstract " + ind + " {"] + [string for string in formatted_strings if + string.strip() and string.strip() != "{"] + ["}", ""] + +with open('your_file.puml', 'w') as f: + for line in res + ["@enduml"]: + f.write(f"{line}\n") + +os.system('python -m plantuml your_file.puml') diff --git a/fedot_ind/tools/uml/your_file.png b/fedot_ind/tools/uml/your_file.png new file mode 100644 index 000000000..305862588 Binary files /dev/null and b/fedot_ind/tools/uml/your_file.png differ diff --git a/fedot_ind/tools/uml/your_file.puml b/fedot_ind/tools/uml/your_file.puml new file mode 100644 index 000000000..9f8869fbc --- /dev/null +++ b/fedot_ind/tools/uml/your_file.puml @@ -0,0 +1,101 @@ +@startuml +'https://plantuml.com/sequence-diagram + +class AtomizedModel { + Enum +} + +abstract FEDOT_PREPROC_MODEL +abstract NEURAL_MODEL +abstract INDUSTRIAL_PREPROC_MODEL +abstract SKLEARN_CLF_MODELS +abstract INDUSTRIAL_CLF_PREPROC_MODEL +abstract SKLEARN_REG_MODELS +abstract FORECASTING_PREPROC +abstract FORECASTING_MODELS + + +INDUSTRIAL_CLF_PREPROC_MODEL --> AtomizedModel +AtomizedModel <-- SKLEARN_CLF_MODELS +FEDOT_PREPROC_MODEL --> AtomizedModel +AtomizedModel <- INDUSTRIAL_PREPROC_MODEL +SKLEARN_REG_MODELS --> AtomizedModel +AtomizedModel <-- FORECASTING_MODELS +FORECASTING_PREPROC -> AtomizedModel +NEURAL_MODEL -> AtomizedModel + +abstract FEDOT_PREPROC_MODEL { +ScalingImplementation, +NormalizationImplementation, +ImputationImplementation, +KernelPCAImplementation, +TopologicalFeaturesImplementation +} + +abstract NEURAL_MODEL { +InceptionTimeModel, +OmniScaleModel, +ResNetModel, +NBeatsModel, +TSTModel, +XCModel, +DummyOverComplicatedNeuralNetwork, +LoraModel +} + +abstract INDUSTRIAL_PREPROC_MODEL { +ChannelCentroidFilter, +EigenBasisImplementation, +WaveletBasisImplementation, +FourierBasisImplementation, +RecurrenceExtractor, +QuantileExtractor, +RiemannExtractor, +TopologicalFeaturesImplementation, +MiniRocketExtractor, +ChronosExtractor, +IsolationForestClassImplementation, +IsolationForestRegImplementation, +} + +abstract SKLEARN_CLF_MODELS { +GradientBoostingClassifier, +SklearnLogReg, +DecisionTreeClassifier, +RandomForestClassifier, +MLPClassifier, +LGBMClassifier +} + +abstract INDUSTRIAL_CLF_PREPROC_MODEL { +DecomposerClassImplementation, +ResampleImplementation, +} + +abstract SKLEARN_REG_MODELS { +XGBRegressor, +SklearnSGD, +ExtraTreesRegressor, +SklearnRidgeReg, +SklearnLassoReg, +DecisionTreeRegressor, +LGBMRegressor, +} + +abstract FORECASTING_PREPROC { +LaggedTransformationImplementation, +SparseLaggedTransformationImplementation, +TsSmoothingImplementation, +GaussianFilterImplementation, +ExogDataTransformationImplementation, +} + +abstract FORECASTING_MODELS { +AutoRegImplementation, +STLForecastARIMAImplementation, +ExpSmoothingImplementation, +CGRUImplementation, +GLMIndustrial +} + +@enduml