Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added and improved errors and warnings in the table transformers #372

Merged
merged 8 commits into from
Jun 23, 2023

Conversation

Marsmaennchen221
Copy link
Contributor

Closes #152.

Summary of Changes

feat: Added and improved errors and warnings in the table transformers
feat: Added ability for the Imputer with strategy Mode to work if multiple most frequent values (warns if this is the case, takes the lowest most frequent value)
feat: Added ability for the OneHotEncoder to encode python NaNs
fix: fixed grammar in NonNumericColumnError
feat: Changed ValueNotPresentWhenFittedError to allow info about multiple columns
test: Changed test for Imputer to test all strategies

Marsmaennchen221 and others added 4 commits June 16, 2023 10:47
…aviour with multiple most frequent values

Co-authored-by: alex-senger <[email protected]>
feat: Added ability for the `Imputer` with strategy `Mode` to work if multiple most frequent values (warns if this is the case, takes the lowest most frequent value)
feat: Added ability for the `OneHotEncoder` to encode python NaNs
fix: fixed grammar in `NonNumericColumnError`
feat: Changed `ValueNotPresentWhenFittedError` to allow info about multiple columns
test: Changed test for `Imputer` to test all strategies

Co-authored-by: alex-senger <[email protected]>
…rove-error-handling-of-table-transformers

# Conflicts:
#	src/safeds/exceptions/_data.py
#	tests/safeds/data/tabular/containers/_table/test_plot_boxplots.py
@Marsmaennchen221 Marsmaennchen221 requested a review from a team as a code owner June 18, 2023 16:38
@Marsmaennchen221 Marsmaennchen221 linked an issue Jun 18, 2023 that may be closed by this pull request
@lars-reimann
Copy link
Member

lars-reimann commented Jun 18, 2023

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ PYTHON black 14 0 0 1.41s
✅ PYTHON mypy 14 0 2.24s
✅ PYTHON ruff 14 0 0 0.04s
✅ REPOSITORY git_diff yes no 0.0s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@codecov
Copy link

codecov bot commented Jun 18, 2023

Codecov Report

Merging #372 (f2a4a8e) into main (c877530) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #372   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           47        47           
  Lines         2296      2382   +86     
=========================================
+ Hits          2296      2382   +86     
Impacted Files Coverage Δ
src/safeds/data/tabular/containers/_table.py 100.00% <ø> (ø)
src/safeds/data/tabular/transformation/_imputer.py 100.00% <100.00%> (ø)
...feds/data/tabular/transformation/_label_encoder.py 100.00% <100.00%> (ø)
...ds/data/tabular/transformation/_one_hot_encoder.py 100.00% <100.00%> (ø)
...afeds/data/tabular/transformation/_range_scaler.py 100.00% <100.00%> (ø)
...ds/data/tabular/transformation/_standard_scaler.py 100.00% <100.00%> (ø)
src/safeds/exceptions/_data.py 100.00% <100.00%> (ø)

Copy link
Contributor

@sibre28 sibre28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alex-senger alex-senger merged commit 544e307 into main Jun 23, 2023
@alex-senger alex-senger deleted the 152-improve-error-handling-of-table-transformers branch June 23, 2023 08:33
Comment on lines +128 to +147
if table.number_of_rows == 0:
raise ValueError("The Imputer cannot be fitted because the table contains 0 rows")

if (isinstance(self._strategy, Imputer.Strategy.Mean | Imputer.Strategy.Median)) and table.keep_only_columns(
column_names,
).remove_columns_with_non_numerical_values().number_of_columns < len(
column_names,
):
raise NonNumericColumnError(
str(
sorted(
set(table.keep_only_columns(column_names).column_names)
- set(
table.keep_only_columns(column_names)
.remove_columns_with_non_numerical_values()
.column_names,
),
),
),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe put the NonNumericColumnError before the ValueError to keep the order of Errors the same as in the other transformations

lars-reimann pushed a commit that referenced this pull request Jun 30, 2023
## [0.14.0](v0.13.0...v0.14.0) (2023-06-30)

### Features

* 290 properties for width-height of image ([#359](#359)) ([d9ebdc1](d9ebdc1)), closes [#290](#290)
* Add `find_edges` method to `Image` class ([#383](#383)) ([d14b6ce](d14b6ce)), closes [#288](#288)
* Add `StandardScaler` transformer ([#316](#316)) ([57b0572](57b0572)), closes [#142](#142)
* Add docstrings to the getter methods for hyperparameters in Regression and Classification models ([#371](#371)) ([9073f04](9073f04)), closes [#313](#313)
* Added `Table.group_by` to group a table by a given key ([#343](#343)) ([afb98be](afb98be)), closes [#160](#160)
* Added and improved errors and warnings in the table transformers ([#372](#372)) ([544e307](544e307)), closes [#152](#152)
* added crop() method in image and tests ([#365](#365)) ([eba8163](eba8163))
* added invert_colors method ([#367](#367)) ([1e4d110](1e4d110))
* adjust brightness and contrast of image ([#368](#368)) ([1752feb](1752feb)), closes [#289](#289) [#291](#291)
* blur Image method ([#363](#363)) ([c642176](c642176))
* check that methods of table can handle an empty table ([#314](#314)) ([686c2e7](686c2e7)), closes [#123](#123)
* convert image to grayscale ([#366](#366)) ([1312fe7](1312fe7)), closes [#287](#287)
* enhance `replace_column` to accept a list of new columns ([#312](#312)) ([d50c5b5](d50c5b5)), closes [#301](#301)
* Explicitly throw `UnknownColumnNameError` in `TaggedTable._from_table` ([#334](#334)) ([498999f](498999f)), closes [#333](#333)
* flip images / eq method for image ([#360](#360)) ([54f4ae1](54f4ae1)), closes [#280](#280)
* improve `table.summary`. Catch `ValueError` thrown by `column.stability` ([#390](#390)) ([dbbe0e3](dbbe0e3)), closes [#320](#320)
* improve error handling of `column.stability` when given a column that contains only None ([#388](#388)) ([1da2499](1da2499)), closes [#319](#319)
* Improve Error Handling of classifiers and regressors ([#355](#355)) ([66f5f64](66f5f64)), closes [#153](#153)
* Resize image ([#354](#354)) ([3a971ca](3a971ca)), closes [#283](#283)
* rotate_left and rotate_right added to Image ([#361](#361)) ([c877530](c877530)), closes [#281](#281)
* set kernel of support vector machine ([#350](#350)) ([1326f40](1326f40)), closes [#172](#172)
* sharpen image ([#364](#364)) ([3444700](3444700)), closes [#286](#286)

### Bug Fixes

* Keeping no columns with Table.keep_only_columns results in an empty Table with a row count above 0 ([#386](#386)) ([15dab06](15dab06)), closes [#318](#318)
* remove default value of `positive_class` parameter of classifier metrics ([#382](#382)) ([58fc09e](58fc09e))
* remove default value of `radius` parameter of `blur` ([#378](#378)) ([7f07f29](7f07f29))
@lars-reimann
Copy link
Member

🎉 This PR is included in version 0.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lars-reimann lars-reimann added the released Included in a release label Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Included in a release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error handling of table transformers
8 participants