Skip to content

abstract

  • Name: cognitivefactory.interactive_clustering.sampling.abstract
  • Description: The abstract class used to define constraints sampling algorithms.
  • Author: Erwan SCHILD
  • Created: 17/03/2021
  • Licence: CeCILL (https://cecill.info/licences.fr.html)

AbstractConstraintsSampling

Bases: ABC

Abstract class that is used to define constraints sampling algorithms. The main inherited method is sample.

Source code in src\cognitivefactory\interactive_clustering\sampling\abstract.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class AbstractConstraintsSampling(ABC):
    """
    Abstract class that is used to define constraints sampling algorithms.
    The main inherited method is `sample`.
    """

    # ==============================================================================
    # ABSTRACT METHOD - SAMPLE
    # ==============================================================================
    @abstractmethod
    def sample(
        self,
        constraints_manager: AbstractConstraintsManager,
        nb_to_select: int,
        clustering_result: Optional[Dict[str, int]] = None,
        vectors: Optional[Dict[str, csr_matrix]] = None,
        **kargs,
    ) -> List[Tuple[str, str]]:
        """
        (ABSTRACT METHOD)
        An abstract method that represents the main method used to sample couple of data IDs for constraints annotation.

        Args:
            constraints_manager (AbstractConstraintsManager): A constraints manager over data IDs.
            nb_to_select (int): The number of couple of data IDs to select.
            clustering_result (Optional[Dict[str,int]], optional): A dictionary that represents the predicted cluster for each data ID. The keys of the dictionary represents the data IDs. If `None`, no clustering result are used during the sampling. Defaults to `None`.
            vectors (Optional[Dict[str, csr_matrix]], optional): vectors (Dict[str, csr_matrix]): The representation of data vectors. The keys of the dictionary represents the data IDs. This keys have to refer to the list of data IDs managed by the `constraints_manager`. The value of the dictionary represent the vector of each data. If `None`, no vectors are used during the sampling. Defaults to `None`
            **kargs (dict): Other parameters that can be used in the sampling.

        Raises:
            ValueError: if some parameters are incorrectly set or incompatible.

        Returns:
            List[Tuple[str,str]]: A list of couple of data IDs.
        """

sample(constraints_manager, nb_to_select, clustering_result=None, vectors=None, **kargs) abstractmethod

(ABSTRACT METHOD) An abstract method that represents the main method used to sample couple of data IDs for constraints annotation.

Parameters:

Name Type Description Default
constraints_manager AbstractConstraintsManager

A constraints manager over data IDs.

required
nb_to_select int

The number of couple of data IDs to select.

required
clustering_result Optional[Dict[str, int]]

A dictionary that represents the predicted cluster for each data ID. The keys of the dictionary represents the data IDs. If None, no clustering result are used during the sampling. Defaults to None.

None
vectors Optional[Dict[str, csr_matrix]]

vectors (Dict[str, csr_matrix]): The representation of data vectors. The keys of the dictionary represents the data IDs. This keys have to refer to the list of data IDs managed by the constraints_manager. The value of the dictionary represent the vector of each data. If None, no vectors are used during the sampling. Defaults to None

None
**kargs dict

Other parameters that can be used in the sampling.

{}

Raises:

Type Description
ValueError

if some parameters are incorrectly set or incompatible.

Returns:

Type Description
List[Tuple[str, str]]

List[Tuple[str,str]]: A list of couple of data IDs.

Source code in src\cognitivefactory\interactive_clustering\sampling\abstract.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
@abstractmethod
def sample(
    self,
    constraints_manager: AbstractConstraintsManager,
    nb_to_select: int,
    clustering_result: Optional[Dict[str, int]] = None,
    vectors: Optional[Dict[str, csr_matrix]] = None,
    **kargs,
) -> List[Tuple[str, str]]:
    """
    (ABSTRACT METHOD)
    An abstract method that represents the main method used to sample couple of data IDs for constraints annotation.

    Args:
        constraints_manager (AbstractConstraintsManager): A constraints manager over data IDs.
        nb_to_select (int): The number of couple of data IDs to select.
        clustering_result (Optional[Dict[str,int]], optional): A dictionary that represents the predicted cluster for each data ID. The keys of the dictionary represents the data IDs. If `None`, no clustering result are used during the sampling. Defaults to `None`.
        vectors (Optional[Dict[str, csr_matrix]], optional): vectors (Dict[str, csr_matrix]): The representation of data vectors. The keys of the dictionary represents the data IDs. This keys have to refer to the list of data IDs managed by the `constraints_manager`. The value of the dictionary represent the vector of each data. If `None`, no vectors are used during the sampling. Defaults to `None`
        **kargs (dict): Other parameters that can be used in the sampling.

    Raises:
        ValueError: if some parameters are incorrectly set or incompatible.

    Returns:
        List[Tuple[str,str]]: A list of couple of data IDs.
    """