Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/safeds/data/tabular/transformation/_discretizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,9 @@ def transform(self, table: Table) -> Table:
data[self._column_names] = self._wrapped_transformer.transform(data[self._column_names])
return Table._from_pandas_dataframe(data)

@property
def is_fitted(self) -> bool:
"""
Check if the transformer is fitted.

Returns
-------
is_fitted :
Whether the transformer is fitted.
"""
"""Whether the transformer is fitted."""
return self._wrapped_transformer is not None

def get_names_of_added_columns(self) -> list[str]:
Expand All @@ -174,7 +168,7 @@ def get_names_of_added_columns(self) -> list[str]:
TransformerNotFittedError
If the transformer has not been fitted yet.
"""
if not self.is_fitted():
if not self.is_fitted:
raise TransformerNotFittedError
return []

Expand Down Expand Up @@ -211,6 +205,6 @@ def get_names_of_removed_columns(self) -> list[str]:
TransformerNotFittedError
If the transformer has not been fitted yet.
"""
if not self.is_fitted():
if not self.is_fitted:
raise TransformerNotFittedError
return []
14 changes: 4 additions & 10 deletions src/safeds/data/tabular/transformation/_imputer.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,9 @@ def transform(self, table: Table) -> Table:
)
return Table._from_pandas_dataframe(data, table.schema)

@property
def is_fitted(self) -> bool:
"""
Check if the transformer is fitted.

Returns
-------
is_fitted : bool
Whether the transformer is fitted.
"""
"""Whether the transformer is fitted."""
return self._wrapped_transformer is not None

def get_names_of_added_columns(self) -> list[str]:
Expand All @@ -286,7 +280,7 @@ def get_names_of_added_columns(self) -> list[str]:
TransformerNotFittedError
If the transformer has not been fitted yet.
"""
if not self.is_fitted():
if not self.is_fitted:
raise TransformerNotFittedError
return []

Expand Down Expand Up @@ -323,6 +317,6 @@ def get_names_of_removed_columns(self) -> list[str]:
TransformerNotFittedError
If the transformer has not been fitted yet.
"""
if not self.is_fitted():
if not self.is_fitted:
raise TransformerNotFittedError
return []
14 changes: 4 additions & 10 deletions src/safeds/data/tabular/transformation/_label_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,9 @@ def inverse_transform(self, transformed_table: Table) -> Table:
data[self._column_names] = self._wrapped_transformer.inverse_transform(data[self._column_names])
return Table._from_pandas_dataframe(data)

@property
def is_fitted(self) -> bool:
"""
Check if the transformer is fitted.

Returns
-------
is_fitted : bool
Whether the transformer is fitted.
"""
"""Whether the transformer is fitted."""
return self._wrapped_transformer is not None

def get_names_of_added_columns(self) -> list[str]:
Expand All @@ -202,7 +196,7 @@ def get_names_of_added_columns(self) -> list[str]:
TransformerNotFittedError
If the transformer has not been fitted yet.
"""
if not self.is_fitted():
if not self.is_fitted:
raise TransformerNotFittedError
return []

Expand Down Expand Up @@ -239,6 +233,6 @@ def get_names_of_removed_columns(self) -> list[str]:
TransformerNotFittedError
If the transformer has not been fitted yet.
"""
if not self.is_fitted():
if not self.is_fitted:
raise TransformerNotFittedError
return []
12 changes: 3 additions & 9 deletions src/safeds/data/tabular/transformation/_one_hot_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,9 @@ def inverse_transform(self, transformed_table: Table) -> Table:

return table.sort_columns(lambda col1, col2: column_names.index(col1.name) - column_names.index(col2.name))

@property
def is_fitted(self) -> bool:
"""
Check if the transformer is fitted.

Returns
-------
is_fitted : bool
Whether the transformer is fitted.
"""
"""Whether the transformer is fitted."""
return (
self._column_names is not None
and self._value_to_column is not None
Expand Down Expand Up @@ -387,7 +381,7 @@ def get_names_of_changed_columns(self) -> list[str]:
TransformerNotFittedError
If the transformer has not been fitted yet.
"""
if not self.is_fitted():
if not self.is_fitted:
raise TransformerNotFittedError
return []

Expand Down
14 changes: 4 additions & 10 deletions src/safeds/data/tabular/transformation/_range_scaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,9 @@ def inverse_transform(self, transformed_table: Table) -> Table:
data[self._column_names] = self._wrapped_transformer.inverse_transform(data[self._column_names])
return Table._from_pandas_dataframe(data)

@property
def is_fitted(self) -> bool:
"""
Check if the transformer is fitted.

Returns
-------
is_fitted : bool
Whether the transformer is fitted.
"""
"""Whether the transformer is fitted."""
return self._wrapped_transformer is not None

def get_names_of_added_columns(self) -> list[str]:
Expand All @@ -248,7 +242,7 @@ def get_names_of_added_columns(self) -> list[str]:
TransformerNotFittedError
If the transformer has not been fitted yet.
"""
if not self.is_fitted():
if not self.is_fitted:
raise TransformerNotFittedError
return []

Expand Down Expand Up @@ -285,6 +279,6 @@ def get_names_of_removed_columns(self) -> list[str]:
TransformerNotFittedError
If the transformer has not been fitted yet.
"""
if not self.is_fitted():
if not self.is_fitted:
raise TransformerNotFittedError
return []
14 changes: 4 additions & 10 deletions src/safeds/data/tabular/transformation/_standard_scaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,9 @@ def inverse_transform(self, transformed_table: Table) -> Table:
data[self._column_names] = self._wrapped_transformer.inverse_transform(data[self._column_names])
return Table._from_pandas_dataframe(data)

@property
def is_fitted(self) -> bool:
"""
Check if the transformer is fitted.

Returns
-------
is_fitted : bool
Whether the transformer is fitted.
"""
"""Whether the transformer is fitted."""
return self._wrapped_transformer is not None

def get_names_of_added_columns(self) -> list[str]:
Expand All @@ -230,7 +224,7 @@ def get_names_of_added_columns(self) -> list[str]:
TransformerNotFittedError
If the transformer has not been fitted yet.
"""
if not self.is_fitted():
if not self.is_fitted:
raise TransformerNotFittedError
return []

Expand Down Expand Up @@ -267,6 +261,6 @@ def get_names_of_removed_columns(self) -> list[str]:
TransformerNotFittedError
If the transformer has not been fitted yet.
"""
if not self.is_fitted():
if not self.is_fitted:
raise TransformerNotFittedError
return []
18 changes: 6 additions & 12 deletions src/safeds/data/tabular/transformation/_table_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def __hash__(self) -> int:
hash:
The hash value.
"""
added = self.get_names_of_added_columns() if self.is_fitted() else []
changed = self.get_names_of_changed_columns() if self.is_fitted() else []
removed = self.get_names_of_removed_columns() if self.is_fitted() else []
return _structural_hash(self.__class__.__qualname__, self.is_fitted(), added, changed, removed)
added = self.get_names_of_added_columns() if self.is_fitted else []
changed = self.get_names_of_changed_columns() if self.is_fitted else []
removed = self.get_names_of_removed_columns() if self.is_fitted else []
return _structural_hash(self.__class__.__qualname__, self.is_fitted, added, changed, removed)

@abstractmethod
def fit(self, table: Table, column_names: list[str] | None) -> TableTransformer:
Expand Down Expand Up @@ -117,16 +117,10 @@ def get_names_of_removed_columns(self) -> list[str]:
If the transformer has not been fitted yet.
"""

@property
@abstractmethod
def is_fitted(self) -> bool:
"""
Check if the transformer is fitted.

Returns
-------
is_fitted : bool
Whether the transformer is fitted.
"""
"""Whether the transformer is fitted."""

def fit_and_transform(self, table: Table, column_names: list[str] | None = None) -> Table:
"""
Expand Down
10 changes: 2 additions & 8 deletions src/safeds/ml/classical/classification/_ada_boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,9 @@ def predict(self, dataset: Table) -> TaggedTable:
"""
return predict(self._wrapped_classifier, dataset, self._feature_names, self._target_name)

@property
def is_fitted(self) -> bool:
"""
Check if the classifier is fitted.

Returns
-------
is_fitted : bool
Whether the classifier is fitted.
"""
"""Whether the classifier is fitted."""
return self._wrapped_classifier is not None

def _get_sklearn_classifier(self) -> ClassifierMixin:
Expand Down
12 changes: 3 additions & 9 deletions src/safeds/ml/classical/classification/_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __hash__(self) -> int:
hash:
The hash value.
"""
return _structural_hash(self.__class__.__qualname__, self.is_fitted())
return _structural_hash(self.__class__.__qualname__, self.is_fitted)

@abstractmethod
def fit(self, training_set: TaggedTable) -> Classifier:
Expand Down Expand Up @@ -77,16 +77,10 @@ def predict(self, dataset: Table) -> TaggedTable:
If predicting with the given dataset failed.
"""

@property
@abstractmethod
def is_fitted(self) -> bool:
"""
Check if the classifier is fitted.

Returns
-------
is_fitted : bool
Whether the classifier is fitted.
"""
"""Whether the classifier is fitted."""

@abstractmethod
def _get_sklearn_classifier(self) -> ClassifierMixin:
Expand Down
10 changes: 2 additions & 8 deletions src/safeds/ml/classical/classification/_decision_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,9 @@ def predict(self, dataset: Table) -> TaggedTable:
"""
return predict(self._wrapped_classifier, dataset, self._feature_names, self._target_name)

@property
def is_fitted(self) -> bool:
"""
Check if the classifier is fitted.

Returns
-------
is_fitted : bool
Whether the classifier is fitted.
"""
"""Whether the classifier is fitted."""
return self._wrapped_classifier is not None

def _get_sklearn_classifier(self) -> ClassifierMixin:
Expand Down
10 changes: 2 additions & 8 deletions src/safeds/ml/classical/classification/_gradient_boosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,9 @@ def predict(self, dataset: Table) -> TaggedTable:
"""
return predict(self._wrapped_classifier, dataset, self._feature_names, self._target_name)

@property
def is_fitted(self) -> bool:
"""
Check if the classifier is fitted.

Returns
-------
is_fitted : bool
Whether the classifier is fitted.
"""
"""Whether the classifier is fitted."""
return self._wrapped_classifier is not None

def _get_sklearn_classifier(self) -> ClassifierMixin:
Expand Down
10 changes: 2 additions & 8 deletions src/safeds/ml/classical/classification/_k_nearest_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,9 @@ def predict(self, dataset: Table) -> TaggedTable:
"""
return predict(self._wrapped_classifier, dataset, self._feature_names, self._target_name)

@property
def is_fitted(self) -> bool:
"""
Check if the classifier is fitted.

Returns
-------
is_fitted : bool
Whether the classifier is fitted.
"""
"""Whether the classifier is fitted."""
return self._wrapped_classifier is not None

def _get_sklearn_classifier(self) -> ClassifierMixin:
Expand Down
10 changes: 2 additions & 8 deletions src/safeds/ml/classical/classification/_logistic_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,9 @@ def predict(self, dataset: Table) -> TaggedTable:
"""
return predict(self._wrapped_classifier, dataset, self._feature_names, self._target_name)

@property
def is_fitted(self) -> bool:
"""
Check if the classifier is fitted.

Returns
-------
is_fitted : bool
Whether the classifier is fitted.
"""
"""Whether the classifier is fitted."""
return self._wrapped_classifier is not None

def _get_sklearn_classifier(self) -> ClassifierMixin:
Expand Down
10 changes: 2 additions & 8 deletions src/safeds/ml/classical/classification/_random_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,9 @@ def predict(self, dataset: Table) -> TaggedTable:
"""
return predict(self._wrapped_classifier, dataset, self._feature_names, self._target_name)

@property
def is_fitted(self) -> bool:
"""
Check if the classifier is fitted.

Returns
-------
is_fitted : bool
Whether the classifier is fitted.
"""
"""Whether the classifier is fitted."""
return self._wrapped_classifier is not None

def _get_sklearn_classifier(self) -> ClassifierMixin:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,9 @@ def predict(self, dataset: Table) -> TaggedTable:
"""
return predict(self._wrapped_classifier, dataset, self._feature_names, self._target_name)

@property
def is_fitted(self) -> bool:
"""
Check if the classifier is fitted.

Returns
-------
is_fitted : bool
Whether the classifier is fitted.
"""
"""Whether the classifier is fitted."""
return self._wrapped_classifier is not None

def _get_sklearn_classifier(self) -> ClassifierMixin:
Expand Down
Loading