MultiLabelBinarizer-class: class MultiLabelBinarizer

MultiLabelBinarizerR Documentation

class MultiLabelBinarizer

Description

A class for encoding labels as a multiple binary numeric matrix.

Super class

deepANN::Encoder -> MultiLabelBinarizer

Public fields

categories

('NULL' | character vector)
Holds the labels for the input.

Methods

Public methods


Method new()

Creates a new instance of this R6 class.

Usage
MultiLabelBinarizer$new(categories = NULL)
Arguments
categories

Desired categories of the input data. If NULL (default), the categories are automatically determined from the input data.


Method fit()

Extract labels from input.

Usage
MultiLabelBinarizer$fit(x)
Arguments
x

The input, usually a list consisting of vectors.

Returns

The instance self itself.


Method transform()

Encode input to numeric values between 0 and n_labels-1.

Usage
MultiLabelBinarizer$transform(x)
Arguments
x

The input that will be encoded.

Returns

The encoded x.


Method fit_transform()

Run fit() and transform().

Usage
MultiLabelBinarizer$fit_transform(x)
Arguments
x

The input that will be encoded.

Returns

The encoded x.


Method inverse_transform()

Transform labels back to original encoding.

Usage
MultiLabelBinarizer$inverse_transform(x)
Arguments
x

The data that will be transformed back.

Returns

The original encoded x.


Method clone()

The objects of this class are cloneable with this method.

Usage
MultiLabelBinarizer$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

x <- list(
  c("sci-fi", "thriller"),
  c("comedy"),
  c("comedy", "horror"),
  c("horror"),
  c("western", "comedy"),
  c("thriller", "comedy", "sci-fi")
)
mlb <- MultiLabelBinarizer$new()
bm <- mlb$fit_transform(x)
mlb$inverse_transform(bm)

stschn/deepANN documentation built on June 25, 2024, 7:27 a.m.