Skip to content

Commit

Permalink
feat: move existing ML solutions into safeds.ml.classical package (#…
Browse files Browse the repository at this point in the history
…213)

Closes #210.

### Summary of Changes

We eventually want to support neural networks as well, which are
supposed to reside in the `safeds.ml.neural` package. We do not want to
have packages with different semantics (classification and regression as
tasks, neural networks as a subset of ML methods) on the same package
level, however. Because of this, we moved the existing methods into the
`safeds.ml.classical` package.

---------

Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
  • Loading branch information
lars-reimann and megalinter-bot committed Apr 19, 2023
1 parent e50c3b0 commit 655f07f
Show file tree
Hide file tree
Showing 28 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/tutorials/machine_learning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"execution_count": null,
"outputs": [],
"source": [
"from safeds.ml.regression import LinearRegression\n",
"from safeds.ml.classical.regression import LinearRegression\n",
"\n",
"model = LinearRegression()\n",
"fitted_model = model.fit(tagged_table)"
Expand Down
1 change: 1 addition & 0 deletions src/safeds/ml/classical/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Classes for classical machine learning, i.e. machine learning that does not use neural networks."""
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.ensemble import AdaBoostClassifier as sk_AdaBoostClassifier

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._classifier import Classifier

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.tree import DecisionTreeClassifier as sk_DecisionTreeClassifier

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._classifier import Classifier

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.ensemble import GradientBoostingClassifier as sk_GradientBoostingClassifier

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._classifier import Classifier

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.neighbors import KNeighborsClassifier as sk_KNeighborsClassifier

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._classifier import Classifier

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.linear_model import LogisticRegression as sk_LogisticRegression

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._classifier import Classifier

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.ensemble import RandomForestClassifier as sk_RandomForestClassifier

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._classifier import Classifier

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.ensemble import AdaBoostRegressor as sk_AdaBoostRegressor

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._regressor import Regressor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.tree import DecisionTreeRegressor as sk_DecisionTreeRegressor

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._regressor import Regressor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.linear_model import ElasticNet as sk_ElasticNet

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._regressor import Regressor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.ensemble import GradientBoostingRegressor as sk_GradientBoostingRegressor

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._regressor import Regressor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.neighbors import KNeighborsRegressor as sk_KNeighborsRegressor

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._regressor import Regressor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.linear_model import Lasso as sk_Lasso

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._regressor import Regressor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.linear_model import LinearRegression as sk_LinearRegression

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._regressor import Regressor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.ensemble import RandomForestRegressor as sk_RandomForestRegressor

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._regressor import Regressor

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sklearn.linear_model import Ridge as sk_Ridge

from safeds.ml._util_sklearn import fit, predict
from safeds.ml.classical._util_sklearn import fit, predict

from ._regressor import Regressor

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from safeds.data.tabular.containers import Table, TaggedTable
from safeds.ml.classification import (
from safeds.ml.classical.classification import (
AdaBoost,
Classifier,
DecisionTree,
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@
import pytest
from safeds.data.tabular.containers import Column, Table, TaggedTable
from safeds.data.tabular.exceptions import ColumnLengthMismatchError
from safeds.ml.exceptions import (
DatasetContainsTargetError,
DatasetMissesFeaturesError,
LearningError,
ModelNotFittedError,
PredictionError,
)
from safeds.ml.regression import (
from safeds.ml.classical.regression import (
AdaBoost,
DecisionTree,
ElasticNetRegression,
Expand All @@ -27,7 +20,14 @@
)

# noinspection PyProtectedMember
from safeds.ml.regression._regressor import _check_metrics_preconditions
from safeds.ml.classical.regression._regressor import _check_metrics_preconditions
from safeds.ml.exceptions import (
DatasetContainsTargetError,
DatasetMissesFeaturesError,
LearningError,
ModelNotFittedError,
PredictionError,
)

if TYPE_CHECKING:
from _pytest.fixtures import FixtureRequest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import warnings

from safeds.data.tabular.containers import Table
from safeds.ml.regression import LinearRegression
from safeds.ml.classical.regression import LinearRegression


def test_predict_should_not_warn_about_feature_names() -> None:
Expand Down

0 comments on commit 655f07f

Please sign in to comment.