RutherfordNet¶
- class pyeem.analysis.models.RutherfordNet(**kwargs)¶
Bases:
objectThe convolutional neural network (CNN) described in Rutherford et al. 2020.
Methods Summary
create_model([name, input_shape, …])Builds and compiles the CNN.
get_test_data(dataset, routine_results_df)Assembles the test data in a format that is able to be ingested by the Keras CNN model.
get_training_data(dataset, ss_results_df, …)Assembles a training data in a format that is able to be ingested by the Keras CNN model.
prepare_data(dataset, ss_results_df, …)Assembles both training and test data in a format that is able to be ingested by the Keras CNN model.
train(X, y[, fit_kws])Train the CNN model with a call to Keras’ fit().
Methods Documentation
- create_model(name='rutherfordnet', input_shape=[142, 139, 1], output_dense_units=3, compile_kws={})¶
Builds and compiles the CNN.
- Parameters
name (str, optional) – The name of the model. Defaults to “rutherfordnet”.
compile_kws (dict, optional) – Additional keyword arguments which will be passed to tensorflow.keras.Model.compile(). Defaults to {}.
- Returns
The compiled CNN model.
- Return type
tensorflow.keras.Model
- get_test_data(dataset, routine_results_df)¶
Assembles the test data in a format that is able to be ingested by the Keras CNN model. This data will be fed into the trained CNN for it to make predictions with.
- Parameters
dataset (pyeem.datasets.Dataset) – The PyEEM dataset being used to generate test data.
routine_results_df (pandas.DataFrame) – The results of the preprocessing routine.
- Returns
The formatted test data to be used in pyeem.analysis.models.RutherfordNet.model.predict()
- Return type
tuple of numpy.ndarray
- get_training_data(dataset, ss_results_df, mix_results_df)¶
Assembles a training data in a format that is able to be ingested by the Keras CNN model.
- Parameters
dataset (pyeem.datasets.Dataset) – The PyEEM dataset being used to generate training data.
ss_results_df (pandas.DataFrame) – The augmented single source spectra results.
mix_results_df (pandas.DataFrame) – The augmented mixture spectra results.
- Returns
The formatted training data to be used in pyeem.analysis.models.RutherfordNet.train()
- Return type
tuple of numpy.ndarray
- prepare_data(dataset, ss_results_df, mix_results_df, routine_results_df)¶
Assembles both training and test data in a format that is able to be ingested by the Keras CNN model.
- Parameters
dataset (pyeem.datasets.Dataset) – A PyEEM dataset
ss_results_df (pandas.DataFrame) – The augmented single source spectra results.
mix_results_df (pandas.DataFrame) – The augmented mixture spectra results.
routine_results_df (pandas.DataFrame) – The results of the preprocessing routine.
- Returns
Training and test data.
- Return type
tuple of (tuple of numpy.ndarray)
- train(X, y, fit_kws={})¶
Train the CNN model with a call to Keras’ fit().
- Parameters
X (numpy.ndarray) – Training Spectra.
y (numpy.ndarray) – Concentration labels.
fit_kws (dict, optional) – Additional key word arguments which will be used in the call to Kera’s fit(). Defaults to {}.
- Returns
The model’s training history which contains information about model accuracy and loss across training epochs.
- Return type
tensorflow.python.keras.callbacks.History