diff --git a/src/safeds/data/tabular/containers/_tagged_table.py b/src/safeds/data/tabular/containers/_tagged_table.py index 23a665162..e18bd6ce8 100644 --- a/src/safeds/data/tabular/containers/_tagged_table.py +++ b/src/safeds/data/tabular/containers/_tagged_table.py @@ -252,7 +252,7 @@ def add_columns_as_features(self, columns: list[Column] | Table) -> TaggedTable: super().add_columns(columns), target_name=self.target.name, feature_names=self.features.column_names - + [col.name for col in (columns.to_columns() if isinstance(columns, Table) else columns)], + + [col.name for col in (columns.to_columns() if isinstance(columns, Table) else columns)], ) # ------------------------------------------------------------------------------------------------------------------ @@ -686,8 +686,8 @@ def replace_column(self, old_column_name: str, new_columns: list[Column]) -> Tag self.features.column_names if old_column_name not in self.features.column_names else self.features.column_names[: self.features.column_names.index(old_column_name)] - + [col.name for col in new_columns] - + self.features.column_names[self.features.column_names.index(old_column_name) + 1:] + + [col.name for col in new_columns] + + self.features.column_names[self.features.column_names.index(old_column_name) + 1 :] ), ) @@ -747,7 +747,7 @@ def slice_rows( def sort_columns( self, comparator: Callable[[Column, Column], int] = lambda col1, col2: (col1.name > col2.name) - - (col1.name < col2.name), + - (col1.name < col2.name), ) -> TaggedTable: """ Sort the columns of a `TaggedTable` with the given comparator and return a new `TaggedTable`. diff --git a/src/safeds/data/tabular/transformation/_imputer.py b/src/safeds/data/tabular/transformation/_imputer.py index 8fb7b0235..06e6c6d32 100644 --- a/src/safeds/data/tabular/transformation/_imputer.py +++ b/src/safeds/data/tabular/transformation/_imputer.py @@ -153,11 +153,9 @@ def fit(self, table: Table, column_names: list[str] | None) -> Imputer: multiple_most_frequent[name] = table.get_column(name).mode() if len(multiple_most_frequent) > 0: warnings.warn( - ( - "There are multiple most frequent values in a column given to the Imputer.\nThe lowest values" - " are being chosen in this cases. The following columns have multiple most frequent" - f" values:\n{multiple_most_frequent}" - ), + "There are multiple most frequent values in a column given to the Imputer.\nThe lowest values" + " are being chosen in this cases. The following columns have multiple most frequent" + f" values:\n{multiple_most_frequent}", UserWarning, stacklevel=2, ) diff --git a/src/safeds/data/tabular/transformation/_label_encoder.py b/src/safeds/data/tabular/transformation/_label_encoder.py index 7ed6b5fd9..26c732327 100644 --- a/src/safeds/data/tabular/transformation/_label_encoder.py +++ b/src/safeds/data/tabular/transformation/_label_encoder.py @@ -56,12 +56,9 @@ def fit(self, table: Table, column_names: list[str] | None) -> LabelEncoder: if table.keep_only_columns(column_names).remove_columns_with_non_numerical_values().number_of_columns > 0: warnings.warn( - ( - "The columns" - f" {table.keep_only_columns(column_names).remove_columns_with_non_numerical_values().column_names} contain" - " numerical data. The LabelEncoder is designed to encode non-numerical values into numerical" - " values" - ), + "The columns" + f" {table.keep_only_columns(column_names).remove_columns_with_non_numerical_values().column_names} contain" + " numerical data. The LabelEncoder is designed to encode non-numerical values into numerical values", UserWarning, stacklevel=2, ) diff --git a/src/safeds/data/tabular/transformation/_one_hot_encoder.py b/src/safeds/data/tabular/transformation/_one_hot_encoder.py index f24098c6c..cf557b548 100644 --- a/src/safeds/data/tabular/transformation/_one_hot_encoder.py +++ b/src/safeds/data/tabular/transformation/_one_hot_encoder.py @@ -111,12 +111,9 @@ def fit(self, table: Table, column_names: list[str] | None) -> OneHotEncoder: > 0 ): warnings.warn( - ( - "The columns" - f" {table._as_table().keep_only_columns(column_names).remove_columns_with_non_numerical_values().column_names} contain" - " numerical data. The OneHotEncoder is designed to encode non-numerical values into numerical" - " values" - ), + "The columns" + f" {table._as_table().keep_only_columns(column_names).remove_columns_with_non_numerical_values().column_names} contain" + " numerical data. The OneHotEncoder is designed to encode non-numerical values into numerical values", UserWarning, stacklevel=2, ) diff --git a/src/safeds/ml/classical/_util_sklearn.py b/src/safeds/ml/classical/_util_sklearn.py index d09d10e3b..9479f4391 100644 --- a/src/safeds/ml/classical/_util_sklearn.py +++ b/src/safeds/ml/classical/_util_sklearn.py @@ -52,11 +52,9 @@ def fit(model: Any, tagged_table: TaggedTable) -> None: if len(non_numerical_column_names) != 0: raise NonNumericColumnError( str(non_numerical_column_names), - ( - "You can use the LabelEncoder or OneHotEncoder to transform your non-numerical data to numerical" - " data.\nThe OneHotEncoder should be used if you work with nominal data. If your data contains too many" - " different values\nor is ordinal, you should use the LabelEncoder." - ), + "You can use the LabelEncoder or OneHotEncoder to transform your non-numerical data to numerical" + " data.\nThe OneHotEncoder should be used if you work with nominal data. If your data contains too many" + " different values\nor is ordinal, you should use the LabelEncoder.", ) null_containing_column_names = set(tagged_table.features.column_names) - set( @@ -65,10 +63,8 @@ def fit(model: Any, tagged_table: TaggedTable) -> None: if len(null_containing_column_names) != 0: raise MissingValuesColumnError( str(null_containing_column_names), - ( - "You can use the Imputer to replace the missing values based on different strategies.\nIf you want to" - " remove the missing values entirely you can use the method `Table.remove_rows_with_missing_values`." - ), + "You can use the Imputer to replace the missing values based on different strategies.\nIf you want to" + " remove the missing values entirely you can use the method `Table.remove_rows_with_missing_values`.", ) try: @@ -138,11 +134,9 @@ def predict(model: Any, dataset: Table, feature_names: list[str] | None, target_ if len(non_numerical_column_names) != 0: raise NonNumericColumnError( str(non_numerical_column_names), - ( - "You can use the LabelEncoder or OneHotEncoder to transform your non-numerical data to numerical" - " data.\nThe OneHotEncoder should be used if you work with nominal data. If your data contains too many" - " different values\nor is ordinal, you should use the LabelEncoder.\n" - ), + "You can use the LabelEncoder or OneHotEncoder to transform your non-numerical data to numerical" + " data.\nThe OneHotEncoder should be used if you work with nominal data. If your data contains too many" + " different values\nor is ordinal, you should use the LabelEncoder.\n", ) null_containing_column_names = set(dataset.keep_only_columns(feature_names).column_names) - set( @@ -151,10 +145,8 @@ def predict(model: Any, dataset: Table, feature_names: list[str] | None, target_ if len(null_containing_column_names) != 0: raise MissingValuesColumnError( str(null_containing_column_names), - ( - "You can use the Imputer to replace the missing values based on different strategies.\nIf you want to" - " remove the missing values entirely you can use the method `Table.remove_rows_with_missing_values`." - ), + "You can use the Imputer to replace the missing values based on different strategies.\nIf you want to" + " remove the missing values entirely you can use the method `Table.remove_rows_with_missing_values`.", ) dataset_df = dataset.keep_only_columns(feature_names)._data