Skip to content

Utilities

groot.util

convert_numpy(obj)

Convert numpy ints and floats to python types. Useful when converting objects to JSON.

Parameters:

Name Type Description Default
obj {np.int32, np.int64, np.float32, np.float64, np.longlong}

Number to convert to python int or float.

required

numpy_to_chensvmlight(X, y, filename)

Export a numpy dataset to the SVM-Light format that is needed for Chen et al. (2019).

The difference between SVM-Light and this format is that zero values are also included.

Parameters:

Name Type Description Default
X array-like of shape (n_samples, n_features)

Array of amples.

required
y array-like of shape (n_samples,)

Array of class labels as integers.

required
filename str

Exported SVM-Light dataset filename or path.

required