artlib.elementary.BinaryFuzzyART ================================ .. py:module:: artlib.elementary.BinaryFuzzyART .. autoapi-nested-parse:: Fuzzy ART :cite:`carpenter1991fuzzy`. Classes ------- .. autoapisummary:: artlib.elementary.BinaryFuzzyART.BinaryFuzzyART Functions --------- .. autoapisummary:: artlib.elementary.BinaryFuzzyART._and_popcount artlib.elementary.BinaryFuzzyART._category_choice_binary Module Contents --------------- .. py:function:: _and_popcount(i, w) .. py:function:: _category_choice_binary(i: numpy.ndarray, w: numpy.ndarray, pre_MT: bool, rho_int: int) -> Tuple[int, bool] Optimized category choice for binary data using count_nonzero. .. py:class:: BinaryFuzzyART(rho: float) Bases: :py:obj:`artlib.elementary.FuzzyART.FuzzyART` Fuzzy ART optimized for binary input data. .. py:attribute:: w_count_cache :type: List[int] :value: [] .. py:method:: prepare_data(X: numpy.ndarray) -> numpy.ndarray Prepare data for clustering. :param X: Dataset. :type X: np.ndarray :returns: Normalized and complement coded data. :rtype: np.ndarray .. py:method:: restore_data(X: numpy.ndarray) -> numpy.ndarray Restore data to its state prior to preparation. :param X: Dataset. :type X: np.ndarray :returns: Restored data. :rtype: np.ndarray .. py:method:: validate_params(params: dict) :staticmethod: Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: validate_data(X: numpy.ndarray) Validate the data prior to clustering. :param X: Dataset. :type X: np.ndarray .. py:method:: category_choice(i: numpy.ndarray, w: numpy.ndarray, params: dict) -> tuple[int, Optional[dict]] Get the activation of the cluster using optimized binary operations. .. py:method:: match_criterion(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> Tuple[float, Optional[Dict]] Get the match criterion using optimized binary operations. .. py:method:: match_criterion_bin(i: numpy.ndarray, w: numpy.ndarray, params: Dict, cache: Optional[Dict] = None, op: Callable = operator.ge) -> Tuple[bool, Dict] Get the binary match criterion of the cluster. :param i: Data sample. :type i: np.ndarray :param w: Cluster weight or information. :type w: np.ndarray :param params: Dictionary containing parameters for the algorithm. :type params: dict :param cache: Cache containing values from previous calculations. :type cache: dict, optional :returns: Binary match criterion and cache used for later processing. :rtype: tuple .. py:method:: set_weight(idx: int, new_w: numpy.ndarray, cache: Optional[dict] = None) Set the value of a cluster weight. :param idx: Index of cluster to update. :type idx: int :param new_w: New cluster weight. :type new_w: np.ndarray :param cache: cache of values created during training step :type cache: Optional[dict] .. py:method:: update(i: numpy.ndarray, w: numpy.ndarray, params: dict, cache: Optional[dict] = None) -> numpy.ndarray Get the updated cluster weight using optimized binary operations. .. py:method:: add_weight(new_w: numpy.ndarray) Add a new cluster weight. :param new_w: New cluster weight to add. :type new_w: np.ndarray .. py:method:: step_pred(x) -> int Predict the label for a single sample. :param x: Data sample. :type x: np.ndarray :returns: Cluster label of the input sample. :rtype: int .. py:method:: _match_tracking_integer(cache: Union[List[Dict], Dict], epsilon: int, params: Union[List[Dict], Dict], method: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~']) -> bool Perform match tracking using the specified method. :param cache: Cached match criterion value. :type cache: dict :param epsilon: Small adjustment factor for match tracking. :type epsilon: float :param params: Parameters :type params: dict :param method: Match tracking method to apply. :type method: Literal["MT+", "MT-", "MT0", "MT1", "MT~"] :returns: Whether to continue searching for a match. :rtype: bool .. py:method:: step_fit(x: numpy.ndarray, match_reset_func: Optional[Callable] = None, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) -> int Fit the model to a single sample. :param x: Data sample. :type x: np.ndarray :param match_reset_func: A callable that influences cluster creation. :type match_reset_func: callable, optional :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, default="MT+" :param epsilon: Epsilon value used for adjusting match criterion. Rounded up to nearest int :type epsilon: float, default=0.0 :returns: Cluster label of the input sample. :rtype: int