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: remove target_name parameter of predict #70

Merged
merged 3 commits into from
Mar 24, 2023
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
8 changes: 2 additions & 6 deletions src/safeds/ml/classification/_ada_boost.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

# noinspection PyProtectedMember
import safeds.ml._util_sklearn
from safeds.data.tabular.containers import Table, TaggedTable
Expand Down Expand Up @@ -37,16 +35,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
self._classification, tagged_table
)

def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name : Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand All @@ -61,5 +57,5 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
return safeds.ml._util_sklearn.predict(
self._classification,
dataset,
target_name if target_name is not None else self.target_name,
self.target_name,
)
5 changes: 1 addition & 4 deletions src/safeds/ml/classification/_classifier.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from abc import ABC, abstractmethod
from typing import Optional

from safeds.data.tabular.containers import Table, TaggedTable

Expand All @@ -22,16 +21,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
"""

@abstractmethod
def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name : Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand Down
8 changes: 2 additions & 6 deletions src/safeds/ml/classification/_decision_tree.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

# noinspection PyProtectedMember
import safeds.ml._util_sklearn
from safeds.data.tabular.containers import Table, TaggedTable
Expand Down Expand Up @@ -37,16 +35,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
self._classification, tagged_table
)

def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name : Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand All @@ -61,5 +57,5 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
return safeds.ml._util_sklearn.predict(
self._classification,
dataset,
target_name if target_name is not None else self.target_name,
self.target_name,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

# noinspection PyProtectedMember
import safeds.ml._util_sklearn
from safeds.data.tabular.containers import Table, TaggedTable
Expand Down Expand Up @@ -38,16 +36,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
)

# noinspection PyProtectedMember
def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name : Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand All @@ -62,5 +58,5 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
return safeds.ml._util_sklearn.predict(
self._classification,
dataset,
target_name if target_name is not None else self.target_name,
self.target_name,
)
8 changes: 2 additions & 6 deletions src/safeds/ml/classification/_k_nearest_neighbors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

# noinspection PyProtectedMember
import safeds.ml._util_sklearn
from safeds.data.tabular.containers import Table, TaggedTable
Expand Down Expand Up @@ -41,16 +39,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
self._classification, tagged_table
)

def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name : Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand All @@ -65,5 +61,5 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
return safeds.ml._util_sklearn.predict(
self._classification,
dataset,
target_name if target_name is not None else self.target_name,
self.target_name,
)
8 changes: 2 additions & 6 deletions src/safeds/ml/classification/_logistic_regression.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

# noinspection PyProtectedMember
import safeds.ml._util_sklearn
from safeds.data.tabular.containers import Table, TaggedTable
Expand Down Expand Up @@ -37,16 +35,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
self._classification, tagged_table
)

def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name : Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand All @@ -61,5 +57,5 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
return safeds.ml._util_sklearn.predict(
self._classification,
dataset,
target_name if target_name is not None else self.target_name,
self.target_name,
)
8 changes: 2 additions & 6 deletions src/safeds/ml/classification/_random_forest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

# noinspection PyProtectedMember
import safeds.ml._util_sklearn
from safeds.data.tabular.containers import Table, TaggedTable
Expand Down Expand Up @@ -36,16 +34,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
self._classification, tagged_table
)

def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name : Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand All @@ -60,5 +56,5 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
return safeds.ml._util_sklearn.predict(
self._classification,
dataset,
target_name if target_name is not None else self.target_name,
self.target_name,
)
8 changes: 2 additions & 6 deletions src/safeds/ml/regression/_ada_boost.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

# noinspection PyProtectedMember
import safeds.ml._util_sklearn
from safeds.data.tabular.containers import Table, TaggedTable
Expand Down Expand Up @@ -35,16 +33,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
"""
self.target_name = safeds.ml._util_sklearn.fit(self._regression, tagged_table)

def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name : Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand All @@ -59,5 +55,5 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
return safeds.ml._util_sklearn.predict(
self._regression,
dataset,
target_name if target_name is not None else self.target_name,
self.target_name,
)
8 changes: 2 additions & 6 deletions src/safeds/ml/regression/_decision_tree.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

# noinspection PyProtectedMember
import safeds.ml._util_sklearn
from safeds.data.tabular.containers import Table, TaggedTable
Expand Down Expand Up @@ -35,16 +33,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
"""
self.target_name = safeds.ml._util_sklearn.fit(self._regression, tagged_table)

def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name: Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand All @@ -59,5 +55,5 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
return safeds.ml._util_sklearn.predict(
self._regression,
dataset,
target_name if target_name is not None else self.target_name,
self.target_name,
)
8 changes: 2 additions & 6 deletions src/safeds/ml/regression/_elastic_net_regression.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

# noinspection PyProtectedMember
import safeds.ml._util_sklearn
from safeds.data.tabular.containers import Table, TaggedTable
Expand Down Expand Up @@ -35,16 +33,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
"""
self.target_name = safeds.ml._util_sklearn.fit(self._regression, tagged_table)

def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name: Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand All @@ -59,5 +55,5 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
return safeds.ml._util_sklearn.predict(
self._regression,
dataset,
target_name if target_name is not None else self.target_name,
self.target_name,
)
8 changes: 2 additions & 6 deletions src/safeds/ml/regression/_gradient_boosting_regression.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

# noinspection PyProtectedMember
import safeds.ml._util_sklearn
from safeds.data.tabular.containers import Table, TaggedTable
Expand Down Expand Up @@ -37,16 +35,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
self.target_name = safeds.ml._util_sklearn.fit(self._regression, tagged_table)

# noinspection PyProtectedMember
def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name : Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand All @@ -61,5 +57,5 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
return safeds.ml._util_sklearn.predict(
self._regression,
dataset,
target_name if target_name is not None else self.target_name,
self.target_name,
)
8 changes: 2 additions & 6 deletions src/safeds/ml/regression/_k_nearest_neighbors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

# noinspection PyProtectedMember
import safeds.ml._util_sklearn
from safeds.data.tabular.containers import Table, TaggedTable
Expand Down Expand Up @@ -39,16 +37,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
"""
self.target_name = safeds.ml._util_sklearn.fit(self._regression, tagged_table)

def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name: Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand All @@ -63,5 +59,5 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
return safeds.ml._util_sklearn.predict(
self._regression,
dataset,
target_name if target_name is not None else self.target_name,
self.target_name,
)
8 changes: 2 additions & 6 deletions src/safeds/ml/regression/_lasso_regression.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

# noinspection PyProtectedMember
import safeds.ml._util_sklearn
from safeds.data.tabular.containers import Table, TaggedTable
Expand Down Expand Up @@ -35,16 +33,14 @@ def fit(self, tagged_table: TaggedTable) -> None:
"""
self.target_name = safeds.ml._util_sklearn.fit(self._regression, tagged_table)

def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
def predict(self, dataset: Table) -> Table:
"""
Predict a target vector using a dataset containing feature vectors. The model has to be trained first.

Parameters
----------
dataset : Table
The dataset containing the feature vectors.
target_name: Optional[str]
The name of the target vector. The name of the target column inferred from fit is used by default.

Returns
-------
Expand All @@ -59,5 +55,5 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
return safeds.ml._util_sklearn.predict(
self._regression,
dataset,
target_name if target_name is not None else self.target_name,
self.target_name,
)
Loading