MaCh3PythonUtils.machine_learning package

Submodules

MaCh3PythonUtils.machine_learning.file_ml_interface module

class FileMLInterface(chain: ChainHandler, prediction_variable: str, fit_name: str)[source]

Bases: ABC

add_model(ml_model: Any) None[source]

Add model to data set

Parameters:

ml_model (Any) – Sets model to be ml_model

property chain: ChainHandler
evaluate_model(predicted_values: Iterable, true_values: Iterable, outfile: str = '')[source]

Evalulates model

Parameters:
  • predicted_values (Iterable) – Label values predicted by model

  • true_values (Iterable) – Actual label values

  • outfile (str, optional) – File to output plots to, defaults to “”

get_maxlikelihood() OptimizeResult[source]
invert_scaling(input_data)[source]
load_model(input_model: str)[source]

Unpickle model

Parameters:

input_file (str) – Pickled Model

load_scaler(input_scaler: str)[source]
property model: Any

Model used

Returns:

Returns ML model being used

Return type:

Any

abstract model_predict(testing_data: DataFrame) Iterable[source]

Abstract method, should return model prediction

Parameters:

testing_data (pd.DataFrame) – Data to test model on

model_predict_single_sample(sample)[source]
run_likelihood_scan(n_divisions: int = 500)[source]
save_model(output_file: str)[source]

Save model to pickle

Parameters:

output_file (str) – Pickle file to save to

save_scaler(output_file: str)[source]
scale_data(input_data)[source]
scale_labels(labels)[source]
set_training_test_set(test_size: float)[source]

Splits data/labels into training and testing tests

Parameters:

test_size (float) – Proportion of data used for testing

property test_data: DataFrame

Gets training data

Returns:

Training data set

Return type:

pd.DataFrame

test_model()[source]

Test model

Raises:
  • ValueError – No model set

  • ValueError – No test data set

abstract train_model()[source]

Abstract method, should be overwritten with model training

property training_data: DataFrame

Gets training data

Returns:

Training data set

Return type:

pd.DataFrame

white_viridis = <matplotlib.colors.LinearSegmentedColormap object>

MaCh3PythonUtils.machine_learning.ml_factory module

ML Factory implementation, effectively a selector for making models

class MLFactory(input_chain: ChainHandler, prediction_variable: str, plot_name: str)[source]

Bases: object

make_interface(interface_type: str, algorithm: str, **kwargs)[source]

MaCh3PythonUtils.machine_learning.scikit_interface module

MaCh3PythonUtils.machine_learning.tf_interface module

Module contents