Conversions
Conversions between different data repesentations and formats.
def probabilities_to_classes(probabilities, classes)
#
Convert probabilities to classes.
Note
Converts using the logic of predict()
of RandomForestClassifier
.
PARAMETER | DESCRIPTION |
---|---|
probabilities |
The probabilities to convert
TYPE:
|
classes |
The classes to use. |
RETURNS | DESCRIPTION |
---|---|
ndarray
|
The classes corresponding to the probabilities |
Source code in src/amltk/data/conversions.py
def to_numpy(x, *, flatten_if_1d=False)
#
Convert to numpy array.
PARAMETER | DESCRIPTION |
---|---|
x |
The data to convert |
flatten_if_1d |
Whether to flatten the array if it is 1d
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
The converted data |
Source code in src/amltk/data/conversions.py
def flatten_if_1d(x)
#
Flatten if 1d.
Retains the type of the input, i.e. pandas stays pandas and numpy stays numpy.
PARAMETER | DESCRIPTION |
---|---|
x |
The data to flatten |
RETURNS | DESCRIPTION |
---|---|
ndarray | DataFrame | Series
|
The flattened data |