Parameters — miml documentation

Skip to main content
`Ctrl`+`K`

# Parameters

class miml.data.bag.Bag(key: str)

  Bases: `object`

  Class to manage MIML Bag data representation

  add_attribute(position: int, values=None) → None

    Add attribute to the bag

    # Parameters

    positionint

      Index for the new attribute

    values: array-like of shape (n_attributes)

      Values for the new attribute. If not provided, new values would be zero

  add_instance(instance: Instance) → None

    Add instance to the bag

    # Parameters

    instanceInstance

      Instance to be added

  delete_attribute(position: int) → None

    Delete attribute of the bag

    # Parameters

    positionint

      Position of the attribute in the bag

  delete_instance(index: int) → None

    Delete an instance of the bag

    # Parameters

    indexint

      Index of the instance to be removed

  get_attribute(instance: int, attribute) → float

    Get value of an attribute of the bag

    # Parameters

    instanceint

      Index of the instance in the bag

    attributeint/str

      Index/Name of the attribute

    # Returns

    valuefloat

      Value of the attribute

  get_attributes() → ndarray

    Get attributes values of the bag

    # Returns

    attributes data: ndarray of shape(n_instances, n_attributes)

      Values of the attributes of the bag

  get_attributes_name() → list[str]

    Get attributes name of the bag

    # Returns

    attributeslist[str]

      Attributes name of the bag

  get_features() → ndarray

    Get features values of the bag

    # Returns

    features data: ndarray of shape (n_instances, n_features)

      Values of the features of the bag

  get_features_name() → list[str]

    Get features name of the bag

    # Returns

    featureslist[str]

      Features name of the bag

  get_instance(index: int) → Instance

    Get an Instance of the Bag

    # Parameters

    indexint

      Index of the instance in the bag

    # Returns

    instanceInstance

      Instance of Instance class

  get_labels() → ndarray

    Get labels values of the bag

    # Returns

    labels datandarray of shape (n_instances, n_labels)

      Values of the labels of the bag

  get_labels_name() → list[str]

    Get labels name of the bag

    # Returns

    labelslist[str]

      Labels name of the bag

  get_number_attributes() → int

    Get numbers of attributes of the bag

    # Returns

    > numbers of attributes: int

    >   Numbers of attributes of the bag

  get_number_features() → int

    Get numbers of features of the bag

    # Returns

    > numbers of features: int

    >   Numbers of features of the bag

  get_number_instances() → int

    Get numbers of instances of a bag

    # Returns

    numbers of instances: int

      Numbers of instances of a bag

  get_number_labels() → int

    Get numbers of labels of the bag

    # Returns

    numbers of labels: int

      Numbers of labels of the bag

  set_attribute(instance: int, attribute, value: float) → None

    Update value from attributes

    # Parameters

    instanceint

      Index of instance to be updated

    attribute: int/str

      Attribute name/index_instance of the bag to be updated

    value: float

      New value for the update

  set_dataset(dataset) → None

    Set dataset which contains the bag

    # Parameters

    datasetMIMLDataset

      Dataset for the bag

  show_bag(start: int = 0, end: int | None = None, attributes: list[str] | None = None, mode='table') → None

    Show bag info in table format

    # Parameters

    startint

      Index of instance to start showing

    endint

      Index of instance to end showing

    modestr

      Mode to show the bag. Modes available are “table” and “compact” (csv format)

    attributeslist[str]

      List of attributes to display. If empty, all attributes will be displayed.