|
1 | 1 | import pickle |
2 | 2 | from pathlib import Path |
3 | 3 |
|
4 | | -import numpy as np |
5 | 4 | from lir.config.lrsystem_architectures import specific_source |
6 | | -from lir.data.models import FeatureData, LLRData |
| 5 | +from lir.data.models import FeatureData |
7 | 6 | from lir.datasets.feature_data_csv import FeatureDataCsvFileParser |
8 | 7 | from lir.lrsystems.lrsystems import LRSystem |
9 | 8 |
|
10 | | -from lrmodule import persistence |
11 | | -from lrmodule.data_types import ModelSettings |
12 | | -from lrmodule.lrsystem import get_trained_model |
13 | | - |
14 | 9 |
|
15 | 10 | def get_lr_system(lr_system_folder: Path, file_name: str = "model.pkl") -> LRSystem: |
16 | 11 | """ |
@@ -55,31 +50,6 @@ def get_reference_data(lr_system_folder: Path, file_name: str = "reference_data. |
55 | 50 | return FeatureDataCsvFileParser(file=reference_data_file, label_column="hypothesis").get_instances() |
56 | 51 |
|
57 | 52 |
|
58 | | -def get_model(settings: ModelSettings, training_data: FeatureData, model_storage_path: Path | None) -> LRSystem: |
59 | | - """ |
60 | | - Obtain a model by loading it from disk, or by fitting it from training data. |
61 | | -
|
62 | | - :param settings: model settings |
63 | | - :param training_data: training data |
64 | | - :param model_storage_path: path where trained LR models are stored |
65 | | - :return: a fitted LR system |
66 | | - """ |
67 | | - model = None if not model_storage_path else persistence.load_model(settings, model_storage_path) |
68 | | - if not model: |
69 | | - model = get_trained_model(settings, training_data) |
70 | | - if model_storage_path: |
71 | | - persistence.save_model(model, settings, model_storage_path) |
72 | | - return model |
73 | | - |
74 | | - |
75 | | -def calculate_llrs( |
76 | | - features: np.ndarray, settings: ModelSettings, training_data: FeatureData, model_storage_path: Path | None |
77 | | -) -> LLRData: |
78 | | - """Calculate LLRs after fitting a model with a training set.""" |
79 | | - model = get_model(settings, training_data, model_storage_path) |
80 | | - return model.apply(FeatureData(features=features)) |
81 | | - |
82 | | - |
83 | 53 | # create an alias for the specific source system, since the architecture is identical but the name is misleading |
84 | 54 | # in the current application |
85 | 55 | binary_lrsystem = specific_source |
0 commit comments