Export results#

Obtain the results as BaseSignal instances#

The decomposition and BSS results are internally stored as numpy arrays in the BaseSignal class. Frequently it is useful to obtain the decomposition/BSS factors and loadings as HyperSpy signals, and HyperSpy provides the following methods for that purpose:

Save and load results#

Save in the main file#

If you save the dataset on which you’ve performed machine learning analysis in the HSpy-HDF5 format (the default in HyperSpy, see Saving), the result of the analysis is also saved in the same file automatically, and it is loaded along with the rest of the data when you next open the file.

Note

This approach currently supports storing one decomposition and one BSS result, which may not be enough for your purposes.

Save to an external file#

Alternatively, you can save the results of the current machine learning analysis to a separate file with the save() method:

>>> # Save the result of the analysis
>>> s.learning_results.save('my_results.npz') 

>>> # Load back the results
>>> s.learning_results.load('my_results.npz') 

Export in different formats#

You can also export the results of a machine learning analysis to any format supported by HyperSpy with the following methods:

These methods accept many arguments to customise the way in which the data is exported, so please consult the method documentation. The options include the choice of file format, the prefixes for loadings and factors, saving figures instead of data and more.

Warning

Data exported in this way cannot be easily loaded into HyperSpy’s machine learning structure.