Skip to content

settings

  • Name: cognitivefactory.interactive_clustering_gui.models.settings
  • Description: Definition of algorithm settings models required for application runs.
  • Author: Erwan Schild
  • Created: 16/12/2021
  • Licence: CeCILL-C License v1.0 (https://cecill.info/licences.fr.html)

ClusterRestriction

Bases: str, Enum

The enumeration of available cluster restrictions for custom sampling algorithm.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
243
244
245
246
247
class ClusterRestriction(str, enum.Enum):  # noqa: WPS600 (subclassing str)
    """The enumeration of available cluster restrictions for custom sampling algorithm."""

    SAME_CLUSTER: str = "same_cluster"
    DIFFERENT_CLUSTERS: str = "different_clusters"

ClusteringAlgorithmEnum

Bases: str, Enum

The enumeration of available clustering algorithms.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
428
429
430
431
432
433
class ClusteringAlgorithmEnum(str, enum.Enum):  # noqa: WPS600 (subclassing str)
    """The enumeration of available clustering algorithms."""

    KMEANS: str = "kmeans"
    HIERARCHICAL: str = "hierarchical"
    SPECTRAL: str = "spectral"

ClusteringSettingsModel

Bases: BaseModel

The body model for clustering settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
class ClusteringSettingsModel(BaseModel):
    """The body model for clustering settings."""

    # Parameters.
    algorithm: ClusteringAlgorithmEnum
    random_seed: int
    nb_clusters: int
    init_kargs: Union[None, KmeansInitSettingsModel, HierarchicalInitSettingsModel, SpectralInitSettingsModel]

    @validator("random_seed")
    @classmethod
    def validate_random_seed(cls, value: int) -> int:
        """The validation of random_seed settings.

        Args:
            value (int): The value of random_seed setting.

        Raises:
            ValueError: if `random_seed` is incorrectly set.

        Returns:
            int: The value of random_seed setting.
        """
        if value < 0:
            raise ValueError("`random_seed` must be greater than or equal to 0.")
        return value

    @validator("nb_clusters")
    @classmethod
    def validate_nb_clusters(cls, value: int) -> int:
        """The validation of nb_clusters settings.

        Args:
            value (int): The value of nb_clusters setting.

        Raises:
            ValueError: if `nb_clusters` is incorrectly set.

        Returns:
            int: The value of nb_clusters setting.
        """
        if value < 2:
            raise ValueError("`nb_clusters` must be greater than or equal to 2.")
        return value

    @root_validator
    @classmethod
    def validate_clustering_settings(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        """The validation of clustering settings.

        Args:
            values (Dict[str, Any]): The values of clustering settings.

        Raises:
            ValueError: if `algorithm` and `init_kargs` are incompatible.

        Returns:
            Dict[str, Any]: The validated values of clustering settings.
        """

        # Case of no clustering algorithm.
        if "algorithm" not in values.keys():
            raise ValueError("The parameter `algorithm` is required.")

        # Case of kmeans clustering algorithm.
        if values["algorithm"] == ClusteringAlgorithmEnum.KMEANS:
            # Case of no init parameters.
            if ("init_kargs" not in values.keys()) or (values["init_kargs"] is None):
                raise ValueError(
                    "A dictionary of initialization (`init_kargs`) is required when algorithm is `kmeans`."
                )
            # Case of wrong type init parameters.
            if not isinstance(values["init_kargs"], KmeansInitSettingsModel):
                raise ValueError(
                    "The dictionary of initialization (`init_kargs`) is incompatible with algorithm `kmeans`."
                )

        # Case of hierarchical clustering algorithm.
        if values["algorithm"] == ClusteringAlgorithmEnum.HIERARCHICAL:
            # Case of no init parameters.
            if ("init_kargs" not in values.keys()) or (values["init_kargs"] is None):
                raise ValueError(
                    "A dictionary of initialization (`init_kargs`) is required when algorithm is `hierarchical`."
                )
            # Case of wrong type init parameters.
            if not isinstance(values["init_kargs"], HierarchicalInitSettingsModel):
                raise ValueError(
                    "The dictionary of initialization (`init_kargs`) is incompatible with algorithm `hierarchical`."
                )

        # Case of spectral clustering algorithm.
        if values["algorithm"] == ClusteringAlgorithmEnum.SPECTRAL:
            # Case of no init parameters.
            if ("init_kargs" not in values.keys()) or (values["init_kargs"] is None):
                raise ValueError(
                    "A dictionary of initialization (`init_kargs`) is required when algorithm is `spectral`."
                )
            # Case of wrong type init parameters.
            if not isinstance(values["init_kargs"], SpectralInitSettingsModel):
                raise ValueError(
                    "The dictionary of initialization (`init_kargs`) is incompatible with algorithm `spectral`."
                )

        # Return validated values of sampling settings.
        return values

    # Export method.
    def to_dict(self) -> Dict[str, Any]:
        """Export the model as a dictionary

        Returns:
            Dict[str, Any]: A dictionary that contains paramaters and their values.
        """
        return {
            "algorithm": self.algorithm.value,
            "random_seed": self.random_seed,
            "nb_clusters": self.nb_clusters,
            "init_kargs": self.init_kargs.to_dict() if (self.init_kargs is not None) else {},
        }

    # Config for schema.
    class Config:  # noqa: WPS431 (nested class)
        """Configuration for body model of clustering settings."""

        schema_extra = {
            "example": {
                "algorithm": (
                    ClusteringAlgorithmEnum.KMEANS
                    + "|"
                    + ClusteringAlgorithmEnum.HIERARCHICAL
                    + "|"
                    + ClusteringAlgorithmEnum.SPECTRAL
                ),
                "random_seed": 42,
                "nb_clusters": 2,
                "init_kargs": {
                    "!!!SPECIFIC: 'algorithm'=='kmeans'": {
                        "model": KmeansModelEnum.COP,
                        "max_iteration": 150,
                        "tolerance": 0.0001,
                    },
                    "!!!SPECIFIC: 'algorithm'=='hierarchical'": {
                        "linkage": (
                            HierarchicalLinkageEnum.WARD
                            + "|"
                            + HierarchicalLinkageEnum.AVERAGE
                            + "|"
                            + HierarchicalLinkageEnum.COMPLETE
                            + "|"
                            + HierarchicalLinkageEnum.SINGLE
                        ),
                    },
                    "!!!SPECIFIC: 'algorithm'=='spectral'": {
                        "model": SpectralModelEnum.SPEC,
                        "nb_components": None,
                    },
                },
            }
        }

Config

Configuration for body model of clustering settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
class Config:  # noqa: WPS431 (nested class)
    """Configuration for body model of clustering settings."""

    schema_extra = {
        "example": {
            "algorithm": (
                ClusteringAlgorithmEnum.KMEANS
                + "|"
                + ClusteringAlgorithmEnum.HIERARCHICAL
                + "|"
                + ClusteringAlgorithmEnum.SPECTRAL
            ),
            "random_seed": 42,
            "nb_clusters": 2,
            "init_kargs": {
                "!!!SPECIFIC: 'algorithm'=='kmeans'": {
                    "model": KmeansModelEnum.COP,
                    "max_iteration": 150,
                    "tolerance": 0.0001,
                },
                "!!!SPECIFIC: 'algorithm'=='hierarchical'": {
                    "linkage": (
                        HierarchicalLinkageEnum.WARD
                        + "|"
                        + HierarchicalLinkageEnum.AVERAGE
                        + "|"
                        + HierarchicalLinkageEnum.COMPLETE
                        + "|"
                        + HierarchicalLinkageEnum.SINGLE
                    ),
                },
                "!!!SPECIFIC: 'algorithm'=='spectral'": {
                    "model": SpectralModelEnum.SPEC,
                    "nb_components": None,
                },
            },
        }
    }

to_dict()

Export the model as a dictionary

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: A dictionary that contains paramaters and their values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
716
717
718
719
720
721
722
723
724
725
726
727
def to_dict(self) -> Dict[str, Any]:
    """Export the model as a dictionary

    Returns:
        Dict[str, Any]: A dictionary that contains paramaters and their values.
    """
    return {
        "algorithm": self.algorithm.value,
        "random_seed": self.random_seed,
        "nb_clusters": self.nb_clusters,
        "init_kargs": self.init_kargs.to_dict() if (self.init_kargs is not None) else {},
    }

validate_clustering_settings(values) classmethod

The validation of clustering settings.

Parameters:

Name Type Description Default
values Dict[str, Any]

The values of clustering settings.

required

Raises:

Type Description
ValueError

if algorithm and init_kargs are incompatible.

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: The validated values of clustering settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
@root_validator
@classmethod
def validate_clustering_settings(cls, values: Dict[str, Any]) -> Dict[str, Any]:
    """The validation of clustering settings.

    Args:
        values (Dict[str, Any]): The values of clustering settings.

    Raises:
        ValueError: if `algorithm` and `init_kargs` are incompatible.

    Returns:
        Dict[str, Any]: The validated values of clustering settings.
    """

    # Case of no clustering algorithm.
    if "algorithm" not in values.keys():
        raise ValueError("The parameter `algorithm` is required.")

    # Case of kmeans clustering algorithm.
    if values["algorithm"] == ClusteringAlgorithmEnum.KMEANS:
        # Case of no init parameters.
        if ("init_kargs" not in values.keys()) or (values["init_kargs"] is None):
            raise ValueError(
                "A dictionary of initialization (`init_kargs`) is required when algorithm is `kmeans`."
            )
        # Case of wrong type init parameters.
        if not isinstance(values["init_kargs"], KmeansInitSettingsModel):
            raise ValueError(
                "The dictionary of initialization (`init_kargs`) is incompatible with algorithm `kmeans`."
            )

    # Case of hierarchical clustering algorithm.
    if values["algorithm"] == ClusteringAlgorithmEnum.HIERARCHICAL:
        # Case of no init parameters.
        if ("init_kargs" not in values.keys()) or (values["init_kargs"] is None):
            raise ValueError(
                "A dictionary of initialization (`init_kargs`) is required when algorithm is `hierarchical`."
            )
        # Case of wrong type init parameters.
        if not isinstance(values["init_kargs"], HierarchicalInitSettingsModel):
            raise ValueError(
                "The dictionary of initialization (`init_kargs`) is incompatible with algorithm `hierarchical`."
            )

    # Case of spectral clustering algorithm.
    if values["algorithm"] == ClusteringAlgorithmEnum.SPECTRAL:
        # Case of no init parameters.
        if ("init_kargs" not in values.keys()) or (values["init_kargs"] is None):
            raise ValueError(
                "A dictionary of initialization (`init_kargs`) is required when algorithm is `spectral`."
            )
        # Case of wrong type init parameters.
        if not isinstance(values["init_kargs"], SpectralInitSettingsModel):
            raise ValueError(
                "The dictionary of initialization (`init_kargs`) is incompatible with algorithm `spectral`."
            )

    # Return validated values of sampling settings.
    return values

validate_nb_clusters(value) classmethod

The validation of nb_clusters settings.

Parameters:

Name Type Description Default
value int

The value of nb_clusters setting.

required

Raises:

Type Description
ValueError

if nb_clusters is incorrectly set.

Returns:

Name Type Description
int int

The value of nb_clusters setting.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
@validator("nb_clusters")
@classmethod
def validate_nb_clusters(cls, value: int) -> int:
    """The validation of nb_clusters settings.

    Args:
        value (int): The value of nb_clusters setting.

    Raises:
        ValueError: if `nb_clusters` is incorrectly set.

    Returns:
        int: The value of nb_clusters setting.
    """
    if value < 2:
        raise ValueError("`nb_clusters` must be greater than or equal to 2.")
    return value

validate_random_seed(value) classmethod

The validation of random_seed settings.

Parameters:

Name Type Description Default
value int

The value of random_seed setting.

required

Raises:

Type Description
ValueError

if random_seed is incorrectly set.

Returns:

Name Type Description
int int

The value of random_seed setting.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
@validator("random_seed")
@classmethod
def validate_random_seed(cls, value: int) -> int:
    """The validation of random_seed settings.

    Args:
        value (int): The value of random_seed setting.

    Raises:
        ValueError: if `random_seed` is incorrectly set.

    Returns:
        int: The value of random_seed setting.
    """
    if value < 0:
        raise ValueError("`random_seed` must be greater than or equal to 0.")
    return value

CustomSamplingInitSettingsModel

Bases: BaseModel

The body submodel for custom sampling initialization settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
class CustomSamplingInitSettingsModel(BaseModel):
    """The body submodel for custom sampling initialization settings."""

    # Parameters.
    clusters_restriction: ClusterRestriction
    distance_restriction: DistanceRestriction
    without_inferred_constraints: bool

    # Export method.
    def to_dict(self) -> Dict[str, Any]:
        """Export the model as a dictionary

        Returns:
            Dict[str, Any]: A dictionary that contains paramaters and their values.
        """
        return {
            "clusters_restriction": self.clusters_restriction.value,
            "distance_restriction": self.distance_restriction.value,
            "without_inferred_constraints": self.without_inferred_constraints,
        }

to_dict()

Export the model as a dictionary

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: A dictionary that contains paramaters and their values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
266
267
268
269
270
271
272
273
274
275
276
def to_dict(self) -> Dict[str, Any]:
    """Export the model as a dictionary

    Returns:
        Dict[str, Any]: A dictionary that contains paramaters and their values.
    """
    return {
        "clusters_restriction": self.clusters_restriction.value,
        "distance_restriction": self.distance_restriction.value,
        "without_inferred_constraints": self.without_inferred_constraints,
    }

DistanceRestriction

Bases: str, Enum

The enumeration of available distance restrictions for custom sampling algorithm.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
250
251
252
253
254
class DistanceRestriction(str, enum.Enum):  # noqa: WPS600 (subclassing str)
    """The enumeration of available distance restrictions for custom sampling algorithm."""

    CLOSEST_NEIGHBORS: str = "closest_neighbors"
    FARTHEST_NEIGHBORS: str = "farthest_neighbors"

HierarchicalInitSettingsModel

Bases: BaseModel

The body submodel for hierarchical instantiation settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
class HierarchicalInitSettingsModel(BaseModel):
    """The body submodel for hierarchical instantiation settings."""

    # Parameters.
    linkage: HierarchicalLinkageEnum

    # Export method.
    def to_dict(self) -> Dict[str, Any]:
        """Export the model as a dictionary

        Returns:
            Dict[str, Any]: A dictionary that contains paramaters and their values.
        """
        return {
            "linkage": self.linkage.value,
        }

to_dict()

Export the model as a dictionary

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: A dictionary that contains paramaters and their values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
529
530
531
532
533
534
535
536
537
def to_dict(self) -> Dict[str, Any]:
    """Export the model as a dictionary

    Returns:
        Dict[str, Any]: A dictionary that contains paramaters and their values.
    """
    return {
        "linkage": self.linkage.value,
    }

HierarchicalLinkageEnum

Bases: str, Enum

The enumeration of available hierarchical linkages.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
513
514
515
516
517
518
519
class HierarchicalLinkageEnum(str, enum.Enum):  # noqa: WPS600 (subclassing str)
    """The enumeration of available hierarchical linkages."""

    AVERAGE: str = "average"
    COMPLETE: str = "complete"
    SINGLE: str = "single"
    WARD: str = "ward"

ICGUISettings

Bases: str, Enum

The enumeration of available Settings for Interactive Clustering GUI.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class ICGUISettings(str, enum.Enum):  # noqa: WPS600 (subclassing str)
    """The enumeration of available Settings for Interactive Clustering GUI."""

    PREPROCESSING: str = "preprocessing"
    VECTORIZATION: str = "vectorization"
    SAMPLING: str = "sampling"
    CLUSTERING: str = "clustering"

    @classmethod
    def contains(cls, value: Any) -> bool:
        """Test if value is in this enumeration.

        Args:
            value (Any): A value.

        Returns:
            bool: `True` if the value is in the enumeration.
        """
        return value in cls._value2member_map_

contains(value) classmethod

Test if value is in this enumeration.

Parameters:

Name Type Description Default
value Any

A value.

required

Returns:

Name Type Description
bool bool

True if the value is in the enumeration.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
33
34
35
36
37
38
39
40
41
42
43
@classmethod
def contains(cls, value: Any) -> bool:
    """Test if value is in this enumeration.

    Args:
        value (Any): A value.

    Returns:
        bool: `True` if the value is in the enumeration.
    """
    return value in cls._value2member_map_

KmeansInitSettingsModel

Bases: BaseModel

The body submodel for kmeans instantiation settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
class KmeansInitSettingsModel(BaseModel):
    """The body submodel for kmeans instantiation settings."""

    # Parameters.
    model: KmeansModelEnum
    max_iteration: int
    tolerance: float

    @validator("max_iteration")
    @classmethod
    def validate_max_iteration(cls, value: int) -> int:
        """The validation of max_iteration settings.

        Args:
            value (int): The value of max_iteration setting.

        Raises:
            ValueError: if `max_iteration` is incorrectly set.

        Returns:
            int: The value of max_iteration setting.
        """
        if value < 1:
            raise ValueError("`max_iteration` must be greater than or equal to 1.")
        return value

    @validator("tolerance")
    @classmethod
    def validate_tolerance(cls, value: float) -> float:
        """The validation of tolerance settings.

        Args:
            value (float): The value of tolerance setting.

        Raises:
            ValueError: if `tolerance` is incorrectly set.

        Returns:
            float: The value of tolerance setting.
        """
        if value < 0:
            raise ValueError("The `tolerance` must be greater than 0.0.")
        return value

    # Export method.
    def to_dict(self) -> Dict[str, Any]:
        """Export the model as a dictionary

        Returns:
            Dict[str, Any]: A dictionary that contains paramaters and their values.
        """
        return {
            "model": self.model.value,
            "max_iteration": self.max_iteration,
            "tolerance": self.tolerance,
        }

to_dict()

Export the model as a dictionary

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: A dictionary that contains paramaters and their values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
487
488
489
490
491
492
493
494
495
496
497
def to_dict(self) -> Dict[str, Any]:
    """Export the model as a dictionary

    Returns:
        Dict[str, Any]: A dictionary that contains paramaters and their values.
    """
    return {
        "model": self.model.value,
        "max_iteration": self.max_iteration,
        "tolerance": self.tolerance,
    }

validate_max_iteration(value) classmethod

The validation of max_iteration settings.

Parameters:

Name Type Description Default
value int

The value of max_iteration setting.

required

Raises:

Type Description
ValueError

if max_iteration is incorrectly set.

Returns:

Name Type Description
int int

The value of max_iteration setting.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
@validator("max_iteration")
@classmethod
def validate_max_iteration(cls, value: int) -> int:
    """The validation of max_iteration settings.

    Args:
        value (int): The value of max_iteration setting.

    Raises:
        ValueError: if `max_iteration` is incorrectly set.

    Returns:
        int: The value of max_iteration setting.
    """
    if value < 1:
        raise ValueError("`max_iteration` must be greater than or equal to 1.")
    return value

validate_tolerance(value) classmethod

The validation of tolerance settings.

Parameters:

Name Type Description Default
value float

The value of tolerance setting.

required

Raises:

Type Description
ValueError

if tolerance is incorrectly set.

Returns:

Name Type Description
float float

The value of tolerance setting.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
@validator("tolerance")
@classmethod
def validate_tolerance(cls, value: float) -> float:
    """The validation of tolerance settings.

    Args:
        value (float): The value of tolerance setting.

    Raises:
        ValueError: if `tolerance` is incorrectly set.

    Returns:
        float: The value of tolerance setting.
    """
    if value < 0:
        raise ValueError("The `tolerance` must be greater than 0.0.")
    return value

KmeansModelEnum

Bases: str, Enum

The enumeration of available kmeans models.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
436
437
438
439
class KmeansModelEnum(str, enum.Enum):  # noqa: WPS600 (subclassing str)
    """The enumeration of available kmeans models."""

    COP: str = "COP"

PreprocessingSettingsModel

Bases: BaseModel

The body model for preprocessing settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
class PreprocessingSettingsModel(BaseModel):
    """The body model for preprocessing settings."""

    # Parameters.
    apply_stopwords_deletion: bool
    apply_parsing_filter: bool
    apply_lemmatization: bool
    spacy_language_model: PreprocessingSpacyLanguageModel

    # Export method.
    def to_dict(self) -> Dict[str, Any]:
        """Export the model as a dictionary

        Returns:
            Dict[str, Any]: A dictionary that contains paramaters and their values.
        """
        return {
            "apply_stopwords_deletion": self.apply_stopwords_deletion,
            "apply_parsing_filter": self.apply_parsing_filter,
            "apply_lemmatization": self.apply_lemmatization,
            "spacy_language_model": self.spacy_language_model.value,
        }

    # Config for schema.
    class Config:  # noqa: WPS431 (nested class)
        """Configuration for body model of preprocessing settings."""

        schema_extra = {
            "example": {
                "apply_stopwords_deletion": False,
                "apply_parsing_filter": False,
                "apply_lemmatization": False,
                "spacy_language_model": PreprocessingSpacyLanguageModel.FR_CORE_NEWS_MD,
            }
        }

Config

Configuration for body model of preprocessing settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
81
82
83
84
85
86
87
88
89
90
91
class Config:  # noqa: WPS431 (nested class)
    """Configuration for body model of preprocessing settings."""

    schema_extra = {
        "example": {
            "apply_stopwords_deletion": False,
            "apply_parsing_filter": False,
            "apply_lemmatization": False,
            "spacy_language_model": PreprocessingSpacyLanguageModel.FR_CORE_NEWS_MD,
        }
    }

to_dict()

Export the model as a dictionary

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: A dictionary that contains paramaters and their values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
67
68
69
70
71
72
73
74
75
76
77
78
def to_dict(self) -> Dict[str, Any]:
    """Export the model as a dictionary

    Returns:
        Dict[str, Any]: A dictionary that contains paramaters and their values.
    """
    return {
        "apply_stopwords_deletion": self.apply_stopwords_deletion,
        "apply_parsing_filter": self.apply_parsing_filter,
        "apply_lemmatization": self.apply_lemmatization,
        "spacy_language_model": self.spacy_language_model.value,
    }

PreprocessingSpacyLanguageModel

Bases: str, Enum

The enumeration of available spacy language model name.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
51
52
53
54
class PreprocessingSpacyLanguageModel(str, enum.Enum):  # noqa: WPS600 (subclassing str)
    """The enumeration of available spacy language model name."""

    FR_CORE_NEWS_MD: str = "fr_core_news_md"

SamplingAlgorithm

Bases: str, Enum

The enumeration of available sampling algorithms.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
233
234
235
236
237
238
239
240
class SamplingAlgorithm(str, enum.Enum):  # noqa: WPS600 (subclassing str)
    """The enumeration of available sampling algorithms."""

    RANDOM: str = "random"
    RANDOM_IN_SAME_CLUSTER: str = "random_in_same_cluster"
    FARTHEST_IN_SAME_CLUSTER: str = "farthest_in_same_cluster"
    CLOSEST_IN_DIFFERENT_CLUSTERS: str = "closest_in_different_clusters"
    CUSTOM: str = "custom"

SamplingSettingsModel

Bases: BaseModel

Abstract body model for sampling settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
class SamplingSettingsModel(BaseModel):
    """Abstract body model for sampling settings."""

    # Parameters.
    algorithm: SamplingAlgorithm
    random_seed: int
    nb_to_select: int
    init_kargs: Optional[CustomSamplingInitSettingsModel]

    @validator("random_seed")
    @classmethod
    def validate_random_seed(cls, value: int) -> int:
        """The validation of random_seed settings.

        Args:
            value (int): The value of random_seed setting.

        Raises:
            ValueError: if `random_seed` is incorrectly set.

        Returns:
            int: The value of random_seed setting.
        """
        if value < 0:
            raise ValueError("`random_seed` must be greater than or equal to 0.")
        return value

    @validator("nb_to_select")
    @classmethod
    def validate_nb_to_select(cls, value: int) -> int:
        """The validation of nb_to_select settings.

        Args:
            value (int): The value of nb_to_select setting.

        Raises:
            ValueError: if `nb_to_select` is incorrectly set.

        Returns:
            int: The value of nb_to_select setting.
        """
        if value < 1:
            raise ValueError("`nb_to_select` must be greater than or equal to 1.")
        return value

    @root_validator
    @classmethod
    def validate_sampling_settings(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        """The validation of sampling settings.

        Args:
            values (Dict[str, Any]): The values of sampling settings.

        Raises:
            ValueError: if `algorithm` and `init_kargs` are incompatible.

        Returns:
            Dict[str, Any]: The validated values of sampling settings.
        """

        # Case of no sampling algorithm.
        if "algorithm" not in values.keys():
            raise ValueError("The parameter `algorithm` is required.")

        # Case of custom sampling algorithm.
        if values["algorithm"] == SamplingAlgorithm.CUSTOM:
            if ("init_kargs" not in values.keys()) or (values["init_kargs"] is None):
                raise ValueError(
                    "A dictionary of initialization (`init_kargs`) is required when algorithm is `custom`."
                )

        # Case of predefinite sampling algorithms.
        else:
            if ("init_kargs" in values.keys()) and (values["init_kargs"] is not None):
                raise ValueError(
                    "No dictionary of initialization (`init_kargs`) is required when algorithm is different from `custom`."
                )
            values["init_kargs"] = None

        # Return validated values of sampling settings.
        return values

    # Export method.
    def to_dict(self) -> Dict[str, Any]:
        """Export the model as a dictionary

        Returns:
            Dict[str, Any]: A dictionary that contains paramaters and their values.
        """
        return {
            "algorithm": self.algorithm.value,
            "random_seed": self.random_seed,
            "nb_to_select": self.nb_to_select,
            "init_kargs": self.init_kargs.to_dict() if (self.init_kargs is not None) else None,
        }

    # Config for schema.
    class Config:  # noqa: WPS431 (nested class)
        """Configuration for body model of sampling settings."""

        schema_extra = {
            "example": {
                "algorithm": (
                    SamplingAlgorithm.RANDOM
                    + "|"
                    + SamplingAlgorithm.RANDOM_IN_SAME_CLUSTER
                    + "|"
                    + SamplingAlgorithm.CLOSEST_IN_DIFFERENT_CLUSTERS
                    + "|"
                    + SamplingAlgorithm.FARTHEST_IN_SAME_CLUSTER
                    + "|"
                    + SamplingAlgorithm.CUSTOM
                ),
                "random_seed": 42,
                "nb_to_select": 25,
                "!!!SPECIFIC: 'algorithm'=='custom'": {
                    "init_kargs": {
                        "clusters_restriction": (
                            ClusterRestriction.SAME_CLUSTER + "|" + ClusterRestriction.DIFFERENT_CLUSTERS
                        ),
                        "distance_restriction": (
                            DistanceRestriction.CLOSEST_NEIGHBORS + "|" + DistanceRestriction.FARTHEST_NEIGHBORS
                        ),
                        "without_inferred_constraints": True,
                    },
                },
            }
        }

Config

Configuration for body model of sampling settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
class Config:  # noqa: WPS431 (nested class)
    """Configuration for body model of sampling settings."""

    schema_extra = {
        "example": {
            "algorithm": (
                SamplingAlgorithm.RANDOM
                + "|"
                + SamplingAlgorithm.RANDOM_IN_SAME_CLUSTER
                + "|"
                + SamplingAlgorithm.CLOSEST_IN_DIFFERENT_CLUSTERS
                + "|"
                + SamplingAlgorithm.FARTHEST_IN_SAME_CLUSTER
                + "|"
                + SamplingAlgorithm.CUSTOM
            ),
            "random_seed": 42,
            "nb_to_select": 25,
            "!!!SPECIFIC: 'algorithm'=='custom'": {
                "init_kargs": {
                    "clusters_restriction": (
                        ClusterRestriction.SAME_CLUSTER + "|" + ClusterRestriction.DIFFERENT_CLUSTERS
                    ),
                    "distance_restriction": (
                        DistanceRestriction.CLOSEST_NEIGHBORS + "|" + DistanceRestriction.FARTHEST_NEIGHBORS
                    ),
                    "without_inferred_constraints": True,
                },
            },
        }
    }

to_dict()

Export the model as a dictionary

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: A dictionary that contains paramaters and their values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
362
363
364
365
366
367
368
369
370
371
372
373
def to_dict(self) -> Dict[str, Any]:
    """Export the model as a dictionary

    Returns:
        Dict[str, Any]: A dictionary that contains paramaters and their values.
    """
    return {
        "algorithm": self.algorithm.value,
        "random_seed": self.random_seed,
        "nb_to_select": self.nb_to_select,
        "init_kargs": self.init_kargs.to_dict() if (self.init_kargs is not None) else None,
    }

validate_nb_to_select(value) classmethod

The validation of nb_to_select settings.

Parameters:

Name Type Description Default
value int

The value of nb_to_select setting.

required

Raises:

Type Description
ValueError

if nb_to_select is incorrectly set.

Returns:

Name Type Description
int int

The value of nb_to_select setting.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
@validator("nb_to_select")
@classmethod
def validate_nb_to_select(cls, value: int) -> int:
    """The validation of nb_to_select settings.

    Args:
        value (int): The value of nb_to_select setting.

    Raises:
        ValueError: if `nb_to_select` is incorrectly set.

    Returns:
        int: The value of nb_to_select setting.
    """
    if value < 1:
        raise ValueError("`nb_to_select` must be greater than or equal to 1.")
    return value

validate_random_seed(value) classmethod

The validation of random_seed settings.

Parameters:

Name Type Description Default
value int

The value of random_seed setting.

required

Raises:

Type Description
ValueError

if random_seed is incorrectly set.

Returns:

Name Type Description
int int

The value of random_seed setting.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
@validator("random_seed")
@classmethod
def validate_random_seed(cls, value: int) -> int:
    """The validation of random_seed settings.

    Args:
        value (int): The value of random_seed setting.

    Raises:
        ValueError: if `random_seed` is incorrectly set.

    Returns:
        int: The value of random_seed setting.
    """
    if value < 0:
        raise ValueError("`random_seed` must be greater than or equal to 0.")
    return value

validate_sampling_settings(values) classmethod

The validation of sampling settings.

Parameters:

Name Type Description Default
values Dict[str, Any]

The values of sampling settings.

required

Raises:

Type Description
ValueError

if algorithm and init_kargs are incompatible.

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: The validated values of sampling settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
@root_validator
@classmethod
def validate_sampling_settings(cls, values: Dict[str, Any]) -> Dict[str, Any]:
    """The validation of sampling settings.

    Args:
        values (Dict[str, Any]): The values of sampling settings.

    Raises:
        ValueError: if `algorithm` and `init_kargs` are incompatible.

    Returns:
        Dict[str, Any]: The validated values of sampling settings.
    """

    # Case of no sampling algorithm.
    if "algorithm" not in values.keys():
        raise ValueError("The parameter `algorithm` is required.")

    # Case of custom sampling algorithm.
    if values["algorithm"] == SamplingAlgorithm.CUSTOM:
        if ("init_kargs" not in values.keys()) or (values["init_kargs"] is None):
            raise ValueError(
                "A dictionary of initialization (`init_kargs`) is required when algorithm is `custom`."
            )

    # Case of predefinite sampling algorithms.
    else:
        if ("init_kargs" in values.keys()) and (values["init_kargs"] is not None):
            raise ValueError(
                "No dictionary of initialization (`init_kargs`) is required when algorithm is different from `custom`."
            )
        values["init_kargs"] = None

    # Return validated values of sampling settings.
    return values

SpectralInitSettingsModel

Bases: BaseModel

The body submodel for spectral instantiation settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
class SpectralInitSettingsModel(BaseModel):
    """The body submodel for spectral instantiation settings."""

    # Parameters.
    model: SpectralModelEnum = SpectralModelEnum.SPEC
    nb_components: Optional[int] = None

    @validator("nb_components")
    @classmethod
    def validate_nb_components(cls, value: Optional[int]) -> Optional[int]:
        """The validation of nb_components settings.

        Args:
            value (Optional[int]): The value of nb_components setting.

        Raises:
            ValueError: if `nb_components` is incorrectly set.

        Returns:
            Optional[int]: The value of nb_components setting.
        """
        if (value is not None) and (value < 2):
            raise ValueError("`nb_components` must be `None` or greater than or equal to 2.")
        return value

    # Export method.
    def to_dict(self) -> Dict[str, Any]:
        """Export the model as a dictionary

        Returns:
            Dict[str, Any]: A dictionary that contains paramaters and their values.
        """
        return {
            "model": self.model.value,
            "nb_components": self.nb_components,
        }

to_dict()

Export the model as a dictionary

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: A dictionary that contains paramaters and their values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
584
585
586
587
588
589
590
591
592
593
def to_dict(self) -> Dict[str, Any]:
    """Export the model as a dictionary

    Returns:
        Dict[str, Any]: A dictionary that contains paramaters and their values.
    """
    return {
        "model": self.model.value,
        "nb_components": self.nb_components,
    }

validate_nb_components(value) classmethod

The validation of nb_components settings.

Parameters:

Name Type Description Default
value Optional[int]

The value of nb_components setting.

required

Raises:

Type Description
ValueError

if nb_components is incorrectly set.

Returns:

Type Description
Optional[int]

Optional[int]: The value of nb_components setting.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
@validator("nb_components")
@classmethod
def validate_nb_components(cls, value: Optional[int]) -> Optional[int]:
    """The validation of nb_components settings.

    Args:
        value (Optional[int]): The value of nb_components setting.

    Raises:
        ValueError: if `nb_components` is incorrectly set.

    Returns:
        Optional[int]: The value of nb_components setting.
    """
    if (value is not None) and (value < 2):
        raise ValueError("`nb_components` must be `None` or greater than or equal to 2.")
    return value

SpectralModelEnum

Bases: str, Enum

The enumeration of available spectral models.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
552
553
554
555
class SpectralModelEnum(str, enum.Enum):  # noqa: WPS600 (subclassing str)
    """The enumeration of available spectral models."""

    SPEC: str = "SPEC"

VectorizationSettingsModel

Bases: BaseModel

The body model for vectorization settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
class VectorizationSettingsModel(BaseModel):
    """The body model for vectorization settings."""

    # Parameters.
    vectorizer_type: VectorizerType
    spacy_language_model: Optional[VectorizationSpacyLanguageModel]
    random_seed: int

    @validator("random_seed")
    @classmethod
    def validate_random_seed(cls, value: int) -> int:
        """The validation of random_seed settings.

        Args:
            value (int): The value of random_seed setting.

        Raises:
            ValueError: if `random_seed` is incorrectly set.

        Returns:
            int: The value of random_seed setting.
        """
        if value < 0:
            raise ValueError("`random_seed` must be greater than or equal to 0.")
        return value

    @root_validator
    @classmethod
    def validate_vectorization_settings(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        """The validation of vectorization settings.

        Args:
            values (Dict[str, Any]): The values of vectorization settings.

        Raises:
            ValueError: if `vectorizer_type` and `spacy_language_model` are incompatible.

        Returns:
            Dict[str, Any]: The validated values of vectorization settings.
        """

        # Case of no vectorizer.
        if "vectorizer_type" not in values.keys():
            raise ValueError("The parameter `vectorizer_type` is required.")

        # Case of tfidf vectorizer.
        if values["vectorizer_type"] == VectorizerType.TFIDF:
            if ("spacy_language_model" in values.keys()) and (values["spacy_language_model"] is not None):
                raise ValueError("No spacy language model is required when vectorizer is `tfidf`.")
            values["spacy_language_model"] = None

        # Case of spacy vectorizer.
        if values["vectorizer_type"] == VectorizerType.SPACY:
            if ("spacy_language_model" not in values.keys()) or (values["spacy_language_model"] is None):
                raise ValueError("A spacy language model is required when vectorizer is `spacy`.")

        # Return validated values of vectorization settings.
        return values

    # Export method.
    def to_dict(self) -> Dict[str, Any]:
        """Export the model as a dictionary

        Returns:
            Dict[str, Any]: A dictionary that contains paramaters and their values.
        """
        return {
            "vectorizer_type": self.vectorizer_type.value,
            "spacy_language_model": (
                self.spacy_language_model.value if (self.spacy_language_model is not None) else None
            ),
            "random_seed": self.random_seed,
        }

    # Config for schema.
    class Config:  # noqa: WPS431 (nested class)
        """Configuration for body model of vectorization settings."""

        schema_extra = {
            "example": {
                "vectorizer_type": VectorizerType.TFIDF + "|" + VectorizerType.SPACY,
                "random_seed": 42,
                "!!!SPECIFIC: 'vectorizer_type'=='spacy'": {
                    "spacy_language_model": VectorizationSpacyLanguageModel.FR_CORE_NEWS_MD,
                },
            }
        }

Config

Configuration for body model of vectorization settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
201
202
203
204
205
206
207
208
209
210
211
212
class Config:  # noqa: WPS431 (nested class)
    """Configuration for body model of vectorization settings."""

    schema_extra = {
        "example": {
            "vectorizer_type": VectorizerType.TFIDF + "|" + VectorizerType.SPACY,
            "random_seed": 42,
            "!!!SPECIFIC: 'vectorizer_type'=='spacy'": {
                "spacy_language_model": VectorizationSpacyLanguageModel.FR_CORE_NEWS_MD,
            },
        }
    }

to_dict()

Export the model as a dictionary

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: A dictionary that contains paramaters and their values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
186
187
188
189
190
191
192
193
194
195
196
197
198
def to_dict(self) -> Dict[str, Any]:
    """Export the model as a dictionary

    Returns:
        Dict[str, Any]: A dictionary that contains paramaters and their values.
    """
    return {
        "vectorizer_type": self.vectorizer_type.value,
        "spacy_language_model": (
            self.spacy_language_model.value if (self.spacy_language_model is not None) else None
        ),
        "random_seed": self.random_seed,
    }

validate_random_seed(value) classmethod

The validation of random_seed settings.

Parameters:

Name Type Description Default
value int

The value of random_seed setting.

required

Raises:

Type Description
ValueError

if random_seed is incorrectly set.

Returns:

Name Type Description
int int

The value of random_seed setting.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
@validator("random_seed")
@classmethod
def validate_random_seed(cls, value: int) -> int:
    """The validation of random_seed settings.

    Args:
        value (int): The value of random_seed setting.

    Raises:
        ValueError: if `random_seed` is incorrectly set.

    Returns:
        int: The value of random_seed setting.
    """
    if value < 0:
        raise ValueError("`random_seed` must be greater than or equal to 0.")
    return value

validate_vectorization_settings(values) classmethod

The validation of vectorization settings.

Parameters:

Name Type Description Default
values Dict[str, Any]

The values of vectorization settings.

required

Raises:

Type Description
ValueError

if vectorizer_type and spacy_language_model are incompatible.

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: The validated values of vectorization settings.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
@root_validator
@classmethod
def validate_vectorization_settings(cls, values: Dict[str, Any]) -> Dict[str, Any]:
    """The validation of vectorization settings.

    Args:
        values (Dict[str, Any]): The values of vectorization settings.

    Raises:
        ValueError: if `vectorizer_type` and `spacy_language_model` are incompatible.

    Returns:
        Dict[str, Any]: The validated values of vectorization settings.
    """

    # Case of no vectorizer.
    if "vectorizer_type" not in values.keys():
        raise ValueError("The parameter `vectorizer_type` is required.")

    # Case of tfidf vectorizer.
    if values["vectorizer_type"] == VectorizerType.TFIDF:
        if ("spacy_language_model" in values.keys()) and (values["spacy_language_model"] is not None):
            raise ValueError("No spacy language model is required when vectorizer is `tfidf`.")
        values["spacy_language_model"] = None

    # Case of spacy vectorizer.
    if values["vectorizer_type"] == VectorizerType.SPACY:
        if ("spacy_language_model" not in values.keys()) or (values["spacy_language_model"] is None):
            raise ValueError("A spacy language model is required when vectorizer is `spacy`.")

    # Return validated values of vectorization settings.
    return values

VectorizationSpacyLanguageModel

Bases: str, Enum

The enumeration of available spacy language model name.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
120
121
122
123
class VectorizationSpacyLanguageModel(str, enum.Enum):  # noqa: WPS600 (subclassing str)
    """The enumeration of available spacy language model name."""

    FR_CORE_NEWS_MD: str = "fr_core_news_md"

VectorizerType

Bases: str, Enum

The enumeration of available vectorizer type.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
113
114
115
116
117
class VectorizerType(str, enum.Enum):  # noqa: WPS600 (subclassing str)
    """The enumeration of available vectorizer type."""

    TFIDF: str = "tfidf"
    SPACY: str = "spacy"

default_ClusteringSettingsModel()

Create a ClusteringSettingsModel instance with default values.

Returns:

Name Type Description
ClusteringSettingsModel ClusteringSettingsModel

A ClusteringSettingsModel instance with default values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
770
771
772
773
774
775
776
777
778
779
780
781
def default_ClusteringSettingsModel() -> ClusteringSettingsModel:
    """Create a ClusteringSettingsModel instance with default values.

    Returns:
        ClusteringSettingsModel: A ClusteringSettingsModel instance with default values.
    """
    return ClusteringSettingsModel(
        algorithm=ClusteringAlgorithmEnum.KMEANS,
        random_seed=42,
        nb_clusters=2,
        init_kargs=default_KmeansInitSettingsModel(),
    )

default_KmeansInitSettingsModel()

Create a KmeansInitSettingsModel instance with default values.

Returns:

Name Type Description
KmeansInitSettingsModel KmeansInitSettingsModel

A KmeansInitSettingsModel instance with default values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
500
501
502
503
504
505
506
507
508
509
510
def default_KmeansInitSettingsModel() -> KmeansInitSettingsModel:
    """Create a KmeansInitSettingsModel instance with default values.

    Returns:
        KmeansInitSettingsModel: A KmeansInitSettingsModel instance with default values.
    """
    return KmeansInitSettingsModel(
        model=KmeansModelEnum.COP,
        max_iteration=150,
        tolerance=0.0001,
    )

default_PreprocessingSettingsModel()

Create a PreprocessingSettingsModel instance with default values.

Returns:

Name Type Description
PreprocessingSettingsModel PreprocessingSettingsModel

A PreprocessingSettingsModel instance with default values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
def default_PreprocessingSettingsModel() -> PreprocessingSettingsModel:
    """Create a PreprocessingSettingsModel instance with default values.

    Returns:
        PreprocessingSettingsModel: A PreprocessingSettingsModel instance with default values.
    """
    return PreprocessingSettingsModel(
        apply_stopwords_deletion=False,
        apply_parsing_filter=False,
        apply_lemmatization=False,
        spacy_language_model=PreprocessingSpacyLanguageModel.FR_CORE_NEWS_MD,
    )

default_SamplingSettingsModel()

Create a SamplingSettingsModel instance with default values.

Returns:

Name Type Description
SamplingSettingsModel SamplingSettingsModel

A SamplingSettingsModel instance with default values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
409
410
411
412
413
414
415
416
417
418
419
420
def default_SamplingSettingsModel() -> SamplingSettingsModel:
    """Create a SamplingSettingsModel instance with default values.

    Returns:
        SamplingSettingsModel: A SamplingSettingsModel instance with default values.
    """
    return SamplingSettingsModel(
        algorithm=SamplingAlgorithm.CLOSEST_IN_DIFFERENT_CLUSTERS,
        random_seed=42,
        nb_to_select=25,
        init_kargs=None,
    )

default_VectorizationSettingsModel()

Create a VectorizationSettingsModel instance with default values.

Returns:

Name Type Description
VectorizationSettingsModel VectorizationSettingsModel

A VectorizationSettingsModel instance with default values.

Source code in src\cognitivefactory\interactive_clustering_gui\models\settings.py
215
216
217
218
219
220
221
222
223
224
225
def default_VectorizationSettingsModel() -> VectorizationSettingsModel:
    """Create a VectorizationSettingsModel instance with default values.

    Returns:
        VectorizationSettingsModel: A VectorizationSettingsModel instance with default values.
    """
    return VectorizationSettingsModel(
        vectorizer_type=VectorizerType.TFIDF,
        spacy_language_model=None,
        random_seed=42,
    )