artlib.cvi.CVIART ================= .. py:module:: artlib.cvi.CVIART .. autoapi-nested-parse:: CVIART. Classes ------- .. autoapisummary:: artlib.cvi.CVIART.CVIART Module Contents --------------- .. py:class:: CVIART(base_module: artlib.common.BaseART.BaseART, validity: int) Bases: :py:obj:`artlib.common.BaseART.BaseART` CVI Art Classification. Expanded version of Art that uses Cluster Validity Indicies to help with cluster selection. PBM is not implemented, can be seen here. git.mst.edu/acil-group/CVI-Fuzzy-ART/-/blob/master/PBM_index.m?ref_type=heads Note, the default step_fit function in base ART evaluates the matching function even if the other criteria has failed. This means it could run slower then it would otherwise. .. py:attribute:: CALINSKIHARABASZ :value: 1 .. py:attribute:: DAVIESBOULDIN :value: 2 .. py:attribute:: SILHOUETTE :value: 3 .. py:attribute:: base_module .. py:method:: validate_params(params: dict) Validate clustering parameters. :param params: Dictionary containing parameters for the algorithm. :type params: dict .. py:method:: prepare_data(X: numpy.ndarray) -> numpy.ndarray Prepare data for clustering. :param X: Dataset to be normalized. :type X: np.ndarray :returns: Normalized data. :rtype: np.ndarray .. py:method:: restore_data(X: numpy.ndarray) -> numpy.ndarray Restore data to state prior to preparation. :param X: Dataset to be restored. :type X: np.ndarray :returns: Restored data. :rtype: np.ndarray .. py:property:: W :type: List Get the base module weights. :returns: base module weights :rtype: list of np.ndarray .. py:property:: labels_ :type: numpy.ndarray Get the base module labels. :returns: base module labels :rtype: np.ndarray .. py:method:: CVI_match(x, w, c_, params, extra, cache) Evaluate the cluster validity index (CVI) for a match. :param x: Data sample. :type x: np.ndarray :param w: Cluster weight information. :type w: np.ndarray :param c_: Cluster index. :type c_: int :param params: Parameters for the algorithm. :type params: dict :param extra: Extra information including index and validity type. :type extra: dict :param cache: Cache containing values from previous calculations. :type cache: dict :returns: True if the new validity score improves the clustering, False otherwise. :rtype: bool .. py:method:: _match_tracking(cache: dict, epsilon: float, params: dict, method: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~']) -> bool Adjust the vigilance parameter (rho) based on the match tracking method. :param cache: Cache containing match criterion. :type cache: dict :param epsilon: Epsilon value for adjusting the vigilance parameter. :type epsilon: float :param params: Parameters for the algorithm. :type params: dict :param method: Method for resetting match criterion. :type method: {"MT+", "MT-", "MT0", "MT1", "MT~"} :returns: True if further matching is required, False otherwise. :rtype: bool .. py:method:: _set_params(new_params) .. py:method:: _deep_copy_params() -> dict .. py:method:: fit(X: numpy.ndarray, y: Optional[numpy.ndarray] = None, match_reset_func: Optional[Callable] = None, max_iter=1, match_tracking: Literal['MT+', 'MT-', 'MT0', 'MT1', 'MT~'] = 'MT+', epsilon: float = 0.0) Fit the model to the data. :param X: The dataset. :type X: np.ndarray :param y: Not used. For compatibility. :type y: np.ndarray, optional :param match_reset_func: A callable accepting the data sample, a cluster weight, the params dict, and the cache dict. Returns True if the cluster is valid for the sample, False otherwise. :type match_reset_func: callable, optional :param max_iter: Number of iterations to fit the model on the same dataset, by default 1. :type max_iter: int, optional :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: Epsilon value used for adjusting match criterion, by default 0.0. :type epsilon: float, optional .. py:method:: pre_step_fit(X: numpy.ndarray) Preprocessing step before fitting each sample. :param X: The dataset. :type X: np.ndarray .. py:method:: post_step_fit(X: numpy.ndarray) Postprocessing step after fitting each sample. :param X: The dataset. :type X: np.ndarray .. 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 :abstractmethod: Fit the model to a single sample. :param x: Data sample. :type x: np.ndarray :param match_reset_func: A callable accepting the data sample, a cluster weight, the params dict, and the cache dict. Returns True if the cluster is valid for the sample, False otherwise. :type match_reset_func: callable, optional :param match_tracking: Method for resetting match criterion. :type match_tracking: {"MT+", "MT-", "MT0", "MT1", "MT~"}, optional :param epsilon: Epsilon value used for adjusting match criterion, by default 0.0. :type epsilon: float, optional :returns: Cluster label of the input sample. :rtype: int .. py:method:: step_pred(x: numpy.ndarray) -> 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:: get_cluster_centers() -> List[numpy.ndarray] Get the centers of the clusters. :returns: Cluster centroids. :rtype: list of np.ndarray .. py:method:: plot_cluster_bounds(ax: matplotlib.axes.Axes, colors: Iterable, linewidth: int = 1) Plot the boundaries of each cluster. :param ax: Figure axes. :type ax: matplotlib.axes.Axes :param colors: Colors to use for each cluster. :type colors: IndexableOrKeyable :param linewidth: Width of boundary line, by default 1. :type linewidth: int, optional