Skip to content

Import from NPY

FromNPY(npy_file_path)

Bases: FieldContentProductionTechnique

Technique used to import a collection of numpy arrays where each row will be treated as a separate instance of data for the specified field

In this case, the expected field data from the source is a string representing an integer (that is the row of the numpy collection corresponding to the representation associated to that content instance)

Note that if specified, preprocessing operations will NOT be applied! Preprocessing is skipped with this technique

This technique is particularly useful if the user wants to import data generated by a different library

PARAMETER DESCRIPTION
npy_file_path

Path where the numpy collection is stored

TYPE: str

Source code in clayrs/content_analyzer/field_content_production_techniques/field_content_production_technique.py
304
305
306
307
308
309
310
311
312
313
314
def __init__(self, npy_file_path: str):

    self.npy_file_path = npy_file_path
    self.np_matrix = np.load(npy_file_path)

    if len(self.np_matrix) > 0:
        self.dim_if_missing = self.np_matrix[0].shape
    else:
        raise ValueError('Matrix should have at least 1 row')

    self._missing: Optional[int] = None