From 7f5b035717072b700e70bcbc6476f88f7e214d28 Mon Sep 17 00:00:00 2001 From: Tim Kucera Date: Sun, 7 Jan 2024 19:26:17 +0100 Subject: [PATCH] rearrange --- proteinshake/__init__.py | 2 +- .../adapters/__baseclass__.py => adapter.py} | 0 .../{backend => }/adapters/alphafold.py | 0 proteinshake/{backend => }/adapters/pdb.py | 0 .../{backend => }/adapters/uniprot.py | 0 proteinshake/backend/protein.py | 4 - proteinshake/backend/structure.py | 4 - proteinshake/{backend => }/database.py | 0 .../{backend/collection.py => dataset.py} | 0 proteinshake/{frontend => }/framework.py | 0 proteinshake/frontend/README.md | 42 ------ proteinshake/frontend/__init__.py | 0 proteinshake/frontend/dataset.py | 120 ------------------ proteinshake/frontend/transforms/__init__.py | 3 - .../frontend/transforms/framework/__init__.py | 1 - .../transforms/post_framework/note.md | 13 -- .../post_representation/add_node_degree.py | 0 .../pre_framework/random_residue_masking.py | 0 .../pre_representation/residue_level.py | 0 .../transforms/representation/__init__.py | 1 - .../evaluators/evaluator.py => metric.py} | 2 +- .../evaluators => metrics}/__init__.py | 0 .../evaluators => metrics}/classification.py | 0 .../evaluators => metrics}/regression.py | 0 .../evaluators => metrics}/retrieval.py | 0 proteinshake/readme.md | 27 ---- proteinshake/{frontend => }/representation.py | 0 .../splitters/splitter.py => split.py} | 0 .../splitters => splits}/__init__.py | 0 .../splitters => splits}/attribute.py | 0 .../pairwise_attribute.py | 0 .../{frontend/splitters => splits}/random.py | 0 proteinshake/{frontend/targets => }/target.py | 0 .../{frontend => }/targets/__init__.py | 0 .../targets/pairwise_property_target.py | 0 .../{frontend => }/targets/property_target.py | 0 proteinshake/{frontend => }/task.py | 12 +- .../{frontend/transforms => }/transform.py | 0 proteinshake/transforms/__init__.py | 2 + .../min_max_scaler.py} | 0 .../point.py => transforms/point_cloud.py} | 4 +- .../torch_framework.py} | 4 +- tests/dataset.py | 39 ------ tests/task.py | 16 +-- 44 files changed, 22 insertions(+), 274 deletions(-) rename proteinshake/{backend/adapters/__baseclass__.py => adapter.py} (100%) rename proteinshake/{backend => }/adapters/alphafold.py (100%) rename proteinshake/{backend => }/adapters/pdb.py (100%) rename proteinshake/{backend => }/adapters/uniprot.py (100%) delete mode 100644 proteinshake/backend/protein.py delete mode 100644 proteinshake/backend/structure.py rename proteinshake/{backend => }/database.py (100%) rename proteinshake/{backend/collection.py => dataset.py} (100%) rename proteinshake/{frontend => }/framework.py (100%) delete mode 100644 proteinshake/frontend/README.md delete mode 100644 proteinshake/frontend/__init__.py delete mode 100644 proteinshake/frontend/dataset.py delete mode 100644 proteinshake/frontend/transforms/__init__.py delete mode 100644 proteinshake/frontend/transforms/framework/__init__.py delete mode 100644 proteinshake/frontend/transforms/post_framework/note.md delete mode 100644 proteinshake/frontend/transforms/post_representation/add_node_degree.py delete mode 100644 proteinshake/frontend/transforms/pre_framework/random_residue_masking.py delete mode 100644 proteinshake/frontend/transforms/pre_representation/residue_level.py delete mode 100644 proteinshake/frontend/transforms/representation/__init__.py rename proteinshake/{frontend/evaluators/evaluator.py => metric.py} (87%) rename proteinshake/{frontend/evaluators => metrics}/__init__.py (100%) rename proteinshake/{frontend/evaluators => metrics}/classification.py (100%) rename proteinshake/{frontend/evaluators => metrics}/regression.py (100%) rename proteinshake/{frontend/evaluators => metrics}/retrieval.py (100%) delete mode 100644 proteinshake/readme.md rename proteinshake/{frontend => }/representation.py (100%) rename proteinshake/{frontend/splitters/splitter.py => split.py} (100%) rename proteinshake/{frontend/splitters => splits}/__init__.py (100%) rename proteinshake/{frontend/splitters => splits}/attribute.py (100%) rename proteinshake/{frontend/splitters => splits}/pairwise_attribute.py (100%) rename proteinshake/{frontend/splitters => splits}/random.py (100%) rename proteinshake/{frontend/targets => }/target.py (100%) rename proteinshake/{frontend => }/targets/__init__.py (100%) rename proteinshake/{frontend => }/targets/pairwise_property_target.py (100%) rename proteinshake/{frontend => }/targets/property_target.py (100%) rename proteinshake/{frontend => }/task.py (93%) rename proteinshake/{frontend/transforms => }/transform.py (100%) create mode 100644 proteinshake/transforms/__init__.py rename proteinshake/{frontend/transforms/label/MinMaxScaler.py => transforms/min_max_scaler.py} (100%) rename proteinshake/{frontend/transforms/representation/point.py => transforms/point_cloud.py} (63%) rename proteinshake/{frontend/transforms/framework/torch.py => transforms/torch_framework.py} (81%) delete mode 100644 tests/dataset.py diff --git a/proteinshake/__init__.py b/proteinshake/__init__.py index 8300a52e..5becc17c 100644 --- a/proteinshake/__init__.py +++ b/proteinshake/__init__.py @@ -1 +1 @@ -__version__ = '0.3.13' +__version__ = "1.0.0" diff --git a/proteinshake/backend/adapters/__baseclass__.py b/proteinshake/adapter.py similarity index 100% rename from proteinshake/backend/adapters/__baseclass__.py rename to proteinshake/adapter.py diff --git a/proteinshake/backend/adapters/alphafold.py b/proteinshake/adapters/alphafold.py similarity index 100% rename from proteinshake/backend/adapters/alphafold.py rename to proteinshake/adapters/alphafold.py diff --git a/proteinshake/backend/adapters/pdb.py b/proteinshake/adapters/pdb.py similarity index 100% rename from proteinshake/backend/adapters/pdb.py rename to proteinshake/adapters/pdb.py diff --git a/proteinshake/backend/adapters/uniprot.py b/proteinshake/adapters/uniprot.py similarity index 100% rename from proteinshake/backend/adapters/uniprot.py rename to proteinshake/adapters/uniprot.py diff --git a/proteinshake/backend/protein.py b/proteinshake/backend/protein.py deleted file mode 100644 index bc150cb6..00000000 --- a/proteinshake/backend/protein.py +++ /dev/null @@ -1,4 +0,0 @@ -class Protein: - """ - Takes a result row from a database query and converts it to a dictionary. - """ diff --git a/proteinshake/backend/structure.py b/proteinshake/backend/structure.py deleted file mode 100644 index 19aee811..00000000 --- a/proteinshake/backend/structure.py +++ /dev/null @@ -1,4 +0,0 @@ -class Structure: - """ - Takes a pdb/mmcif file and converts it to a compressed data format. - """ diff --git a/proteinshake/backend/database.py b/proteinshake/database.py similarity index 100% rename from proteinshake/backend/database.py rename to proteinshake/database.py diff --git a/proteinshake/backend/collection.py b/proteinshake/dataset.py similarity index 100% rename from proteinshake/backend/collection.py rename to proteinshake/dataset.py diff --git a/proteinshake/frontend/framework.py b/proteinshake/framework.py similarity index 100% rename from proteinshake/frontend/framework.py rename to proteinshake/framework.py diff --git a/proteinshake/frontend/README.md b/proteinshake/frontend/README.md deleted file mode 100644 index ae992b8c..00000000 --- a/proteinshake/frontend/README.md +++ /dev/null @@ -1,42 +0,0 @@ -## Dataset API - -tba - -## Task API - -A task brings three objects: `Splitter`, `Target`, `Evaluator` to a given `proteinshake.Dataset` instance. - -The `Splitter` object returns a 3-tuple of train, val and test indices for a given dataset. - -The `Target` object returns the prediction target for a single Entity object (or pair of Entity objects in pairwise tasks). - -The `Evaluator` object returns a dictionary of performance measures given a list of predictions and `Target` values. - -We offer many instances of these objects which can be combined to create tasks. - -You can create a task on the fly like this: - -```python -my_task = Task(dataset, splitter=TemporalSplitter(), target=PairwisePropertyTarget(label='is_interface'), evaluator=BinaryPairwiseEval()) -``` - -Or contribute a predefined task like this: - -```python -class ProteinInterfaceTask(Task): - def __init__(self, dataset): - super().__init__(splitter=TemporalSplitter(cutoff=2018), - target=PairwisePropertyTarget(label='is_interface), - evaluation=BinaryPairwiseEval()) -``` - -You can pass any dataset to a `Task` object provided it contains the information needed by the splitter/target/and eval functions (e.g. structure publication date for temporal splits). - -``` -dataset_1 = ProteinshakeECDataset() -dataset_2 = DeepFriECDataset() -task_1 = EnzymeClassTask(dataset_1) -task_2 = EnzymeClassTask(dataset_2) -``` - -Task machinery is fully framework agnostic tokenizing happens at the dataset transform level. diff --git a/proteinshake/frontend/__init__.py b/proteinshake/frontend/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/proteinshake/frontend/dataset.py b/proteinshake/frontend/dataset.py deleted file mode 100644 index ca3e4d9a..00000000 --- a/proteinshake/frontend/dataset.py +++ /dev/null @@ -1,120 +0,0 @@ -import numpy as np -import random -from typing import Generic -from proteinshake.util import amino_acid_alphabet, save -from proteinshake.transforms import Compose -from functools import partial - - -class Dataset: - def __init__( - self, - path: str = "", - shard_size: int = None, - shuffle: bool = False, - random_seed: int = 42, - ) -> None: - """ - `path` is either pointing to a Zenodo repository or a directory in the local filesystem. - """ - self.dummy_proteins = np.array( - [ - { - "ID": f"protein_{i}", - "coords": np.random.rand(3, 300), - "sequence": "".join( - random.choice(amino_acid_alphabet) for _ in range(300) - ), - "label": np.random.random() * 100, - "split": random.choice(["train", "test", "val"]), - } - for i in range(100) - ] - ) - - @property - def proteins(self): - return iter(self.dummy_proteins) - - def split(self, splitter): - # fitting? - # computes splits and saves them as a dict of indices - # rearranges protein shards for optimal data loading - # creates ?_loader properties - # one rng per loader - splitter.fit(self) - for name, index in splitter.assign(self): - save(partition, shard_size=self.shard_size) - setattr(self, f"{name}_index", index) - setattr(self, f"{name}_loader", partial(self.loader, name)) - - def apply(self, *transforms) -> None: - # prepares transforms - self.transform = Compose(transforms) - self.transform.fit() - for partition in self.partitions: - save( - self.transform.deterministic_transform(partition), - self.root, - shard_size=self.shard_size, - ) - - def loader(self, split=None, batch_size=None): - # check if batch_size multiple of shard_size - # creates generator to load data from disk (optionally shuffled) and to apply stochastic transforms - # creates framework dataloader from self.transform.create_dataloader - # uses the index returned from transforms to reshape the data into tuples - def __iter__(): - # create shard order from rng - def generator(): - try: - protein = next(self.current_shard) - except StopIteration: - # create item order from rng - self.current_shard = self.proteins - protein = next(self.current_shard) - return self.transform.stochastic_transform(protein) # reshape here - - return generator - - return self.transform.create_dataloader(__iter__, batch_size=batch_size) - - def partition(self, index: dict[np.ndarray]): - """ - Partitions the data according to `indices`. This will be used to retrieve subsets of the data and also to optimize sharding. - """ - self.partition = index - - def split(self, name): - """ - Returns a new dataset with a subset of the proteins, determined by the partition. - """ - dataset = Dataset() - dataset.dummy_proteins = self.dummy_proteins[self.partition[name]] - return dataset - - def create_dataloader(self, X, y): - """ - Only temporarily a dataset class method. Will most likely be put in a dedicated `Framework` class. - Returns a dataloader of the correct framework. For now only torch. - """ - from torch.utils.data import DataLoader, IterableDataset - - class _Dataset(IterableDataset): - def __iter__(self): - yield next(X), next(y) - - return lambda **kwargs: DataLoader(_Dataset(), **kwargs) - - def __next__(self) -> Generic: - """ - Yields the next protein from a shard. When the shard is finished, loads the next one. - If `shuffle` is True, loads a random shard and applies shuffling within the shard. - Applies pre/framework/post transforms. - """ - try: - protein = next(self.current_shard) - except StopIteration: - self.current_shard = self.proteins - protein = next(self.current_shard) - return self.transform(protein) diff --git a/proteinshake/frontend/transforms/__init__.py b/proteinshake/frontend/transforms/__init__.py deleted file mode 100644 index 54c5b117..00000000 --- a/proteinshake/frontend/transforms/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .transform import * -from .representation import * -from .framework import * diff --git a/proteinshake/frontend/transforms/framework/__init__.py b/proteinshake/frontend/transforms/framework/__init__.py deleted file mode 100644 index 72f4e5e8..00000000 --- a/proteinshake/frontend/transforms/framework/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .torch import * diff --git a/proteinshake/frontend/transforms/post_framework/note.md b/proteinshake/frontend/transforms/post_framework/note.md deleted file mode 100644 index f25992ff..00000000 --- a/proteinshake/frontend/transforms/post_framework/note.md +++ /dev/null @@ -1,13 +0,0 @@ -""" -Post-framework transforms will not be implemented in ProteinShake, but are responsibility of the respective framework. -You can pass the framework-native transforms to the Dataset object though. - -Example: - - from proteinshake.datasets import EnzymeDataset - from torch_geometric.transforms import AddSelfLoops - ds = EnzymeDataset(...).to_graph(...).pyg(..., post_transform=AddSelfLoops) - -""" - -Note: maybe we provide a wrapper here to cast native framework transforms to shake transforms (to deal with shake-specific things like batching, deterministic/stochastic, etc) \ No newline at end of file diff --git a/proteinshake/frontend/transforms/post_representation/add_node_degree.py b/proteinshake/frontend/transforms/post_representation/add_node_degree.py deleted file mode 100644 index e69de29b..00000000 diff --git a/proteinshake/frontend/transforms/pre_framework/random_residue_masking.py b/proteinshake/frontend/transforms/pre_framework/random_residue_masking.py deleted file mode 100644 index e69de29b..00000000 diff --git a/proteinshake/frontend/transforms/pre_representation/residue_level.py b/proteinshake/frontend/transforms/pre_representation/residue_level.py deleted file mode 100644 index e69de29b..00000000 diff --git a/proteinshake/frontend/transforms/representation/__init__.py b/proteinshake/frontend/transforms/representation/__init__.py deleted file mode 100644 index 86ba70b7..00000000 --- a/proteinshake/frontend/transforms/representation/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .point import * diff --git a/proteinshake/frontend/evaluators/evaluator.py b/proteinshake/metric.py similarity index 87% rename from proteinshake/frontend/evaluators/evaluator.py rename to proteinshake/metric.py index c3a98eea..c5409bbe 100644 --- a/proteinshake/frontend/evaluators/evaluator.py +++ b/proteinshake/metric.py @@ -1,4 +1,4 @@ -class Metrics: +class Metric: """For a collection of predictions and target values, return set of performance metrics.,""" pass diff --git a/proteinshake/frontend/evaluators/__init__.py b/proteinshake/metrics/__init__.py similarity index 100% rename from proteinshake/frontend/evaluators/__init__.py rename to proteinshake/metrics/__init__.py diff --git a/proteinshake/frontend/evaluators/classification.py b/proteinshake/metrics/classification.py similarity index 100% rename from proteinshake/frontend/evaluators/classification.py rename to proteinshake/metrics/classification.py diff --git a/proteinshake/frontend/evaluators/regression.py b/proteinshake/metrics/regression.py similarity index 100% rename from proteinshake/frontend/evaluators/regression.py rename to proteinshake/metrics/regression.py diff --git a/proteinshake/frontend/evaluators/retrieval.py b/proteinshake/metrics/retrieval.py similarity index 100% rename from proteinshake/frontend/evaluators/retrieval.py rename to proteinshake/metrics/retrieval.py diff --git a/proteinshake/readme.md b/proteinshake/readme.md deleted file mode 100644 index 421df382..00000000 --- a/proteinshake/readme.md +++ /dev/null @@ -1,27 +0,0 @@ -## Filestructure: - -- **backend:** Collects and processes raw pdb files from various databases. Creates Collections. - - - **adapters:** Database adapters to PDB, AFDB, etc. - - - **protein:** The protein object specification. - - - **collection:** A set of protein objects. - - - **database:** Unifying database mirror that allows query access to create a collection. - -- **frontend:** High level specifications for datasets and tasks. - - - **datasets:** Load a collection and apply transforms. - - - **tasks:** Various ML prediction problems. Takes a dataset and rearranges the data (sklearn-style X_train, y_train, ...) such that it can be fed to the model (X) and evaluated (y). - - - **evaluators:** Groups relevant metrics for a given class of problems (e.g. classification or regression). - - - **splitters:** Takes a dataset and generates split indices, either from the data/labels itself or from other resources. - -- **datasets:** Some relevant collections of proteins, for preprocessed hosting. Each dataset covers some biological topic. - -- **tasks:** The actually implemented biological tasks for the end-user, consisting of a frontend.task in combination with a specific dataset. - -- **transforms:** Various functions to transform proteins, representations, and frameworks. diff --git a/proteinshake/frontend/representation.py b/proteinshake/representation.py similarity index 100% rename from proteinshake/frontend/representation.py rename to proteinshake/representation.py diff --git a/proteinshake/frontend/splitters/splitter.py b/proteinshake/split.py similarity index 100% rename from proteinshake/frontend/splitters/splitter.py rename to proteinshake/split.py diff --git a/proteinshake/frontend/splitters/__init__.py b/proteinshake/splits/__init__.py similarity index 100% rename from proteinshake/frontend/splitters/__init__.py rename to proteinshake/splits/__init__.py diff --git a/proteinshake/frontend/splitters/attribute.py b/proteinshake/splits/attribute.py similarity index 100% rename from proteinshake/frontend/splitters/attribute.py rename to proteinshake/splits/attribute.py diff --git a/proteinshake/frontend/splitters/pairwise_attribute.py b/proteinshake/splits/pairwise_attribute.py similarity index 100% rename from proteinshake/frontend/splitters/pairwise_attribute.py rename to proteinshake/splits/pairwise_attribute.py diff --git a/proteinshake/frontend/splitters/random.py b/proteinshake/splits/random.py similarity index 100% rename from proteinshake/frontend/splitters/random.py rename to proteinshake/splits/random.py diff --git a/proteinshake/frontend/targets/target.py b/proteinshake/target.py similarity index 100% rename from proteinshake/frontend/targets/target.py rename to proteinshake/target.py diff --git a/proteinshake/frontend/targets/__init__.py b/proteinshake/targets/__init__.py similarity index 100% rename from proteinshake/frontend/targets/__init__.py rename to proteinshake/targets/__init__.py diff --git a/proteinshake/frontend/targets/pairwise_property_target.py b/proteinshake/targets/pairwise_property_target.py similarity index 100% rename from proteinshake/frontend/targets/pairwise_property_target.py rename to proteinshake/targets/pairwise_property_target.py diff --git a/proteinshake/frontend/targets/property_target.py b/proteinshake/targets/property_target.py similarity index 100% rename from proteinshake/frontend/targets/property_target.py rename to proteinshake/targets/property_target.py diff --git a/proteinshake/frontend/task.py b/proteinshake/task.py similarity index 93% rename from proteinshake/frontend/task.py rename to proteinshake/task.py index b785b7b7..6305d86b 100644 --- a/proteinshake/frontend/task.py +++ b/proteinshake/task.py @@ -3,10 +3,10 @@ import os from pathlib import Path from functools import partial -from proteinshake.frontend.splitters import Split -from proteinshake.frontend.targets import Target -from proteinshake.frontend.evaluators import Metrics -from proteinshake.frontend.transforms import Transform, Compose +from proteinshake.split import Split +from proteinshake.target import Target +from proteinshake.metric import Metric +from proteinshake.transform import Transform, Compose from proteinshake.util import amino_acid_alphabet, sharded, save_shards, load, warn @@ -14,7 +14,7 @@ class Task: dataset: str = "" split: Split = None target: Target = None - metrics: Metrics = None + metrics: Metric = None augmentation: Transform = None def __init__( @@ -31,7 +31,7 @@ def __init__( if not os.environ.get("PROTEINSHAKE_ROOT", None) is None: root = os.environ["PROTEINSHAKE_ROOT"] else: - root = "~/.proteinshake" + root = Path.home() / ".proteinshake" root = Path(root) / self.__class__.__name__ os.makedirs(root, exist_ok=True) self.root = root diff --git a/proteinshake/frontend/transforms/transform.py b/proteinshake/transform.py similarity index 100% rename from proteinshake/frontend/transforms/transform.py rename to proteinshake/transform.py diff --git a/proteinshake/transforms/__init__.py b/proteinshake/transforms/__init__.py new file mode 100644 index 00000000..f3cca6ad --- /dev/null +++ b/proteinshake/transforms/__init__.py @@ -0,0 +1,2 @@ +from .point_cloud import * +from .torch_framework import * diff --git a/proteinshake/frontend/transforms/label/MinMaxScaler.py b/proteinshake/transforms/min_max_scaler.py similarity index 100% rename from proteinshake/frontend/transforms/label/MinMaxScaler.py rename to proteinshake/transforms/min_max_scaler.py diff --git a/proteinshake/frontend/transforms/representation/point.py b/proteinshake/transforms/point_cloud.py similarity index 63% rename from proteinshake/frontend/transforms/representation/point.py rename to proteinshake/transforms/point_cloud.py index 575c7eae..ac41bb43 100644 --- a/proteinshake/frontend/transforms/representation/point.py +++ b/proteinshake/transforms/point_cloud.py @@ -1,5 +1,5 @@ -from ..transform import Transform -from proteinshake.frontend.representation import Representation +from proteinshake.transform import Transform +from proteinshake.representation import Representation import numpy as np diff --git a/proteinshake/frontend/transforms/framework/torch.py b/proteinshake/transforms/torch_framework.py similarity index 81% rename from proteinshake/frontend/transforms/framework/torch.py rename to proteinshake/transforms/torch_framework.py index 1bf80164..05614e7e 100644 --- a/proteinshake/frontend/transforms/framework/torch.py +++ b/proteinshake/transforms/torch_framework.py @@ -1,8 +1,8 @@ import torch import numpy as np from torch.utils.data import DataLoader, IterableDataset -from ..transform import Transform -from proteinshake.frontend.framework import Framework +from proteinshake.transform import Transform +from proteinshake.framework import Framework class TorchFrameworkTransform(Framework, Transform): diff --git a/tests/dataset.py b/tests/dataset.py deleted file mode 100644 index bd7fdaa9..00000000 --- a/tests/dataset.py +++ /dev/null @@ -1,39 +0,0 @@ -import unittest -import numpy as np -from proteinshake.frontend.dataset import Dataset -from proteinshake.frontend.transforms import * - - -class TestDataset(unittest.TestCase): - def test_dataset(self): - dataset = Dataset() - - X_transform = DataTransform( - representation_transform=PointRepresentationTransform(), - framework_transform=TorchFrameworkTransform(), - ) - - class MyTargetTransform(TargetTransform): - def __call__(self, protein): - return protein["label"] - - class MyLabelTransform(LabelTransform): - def __call__(self, label): - return label * 100 - - target = MyTargetTransform() - y_transform = MyLabelTransform() - - dataset.partition({"train": np.arange(90), "test": np.arange(90, 100)}) - print("train:", [p["ID"] for p in dataset.split("train").proteins]) - print("test:", [p["ID"] for p in dataset.split("test").proteins]) - - X = dataset.split("train").apply(X_transform) - y = dataset.split("train").apply(target, y_transform) - print(next(X), next(y)) - - loader = dataset.create_dataloader(X, y) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/task.py b/tests/task.py index 18d65a55..403a2363 100644 --- a/tests/task.py +++ b/tests/task.py @@ -1,12 +1,12 @@ import unittest import numpy as np import itertools -from proteinshake.frontend.evaluators import Metrics -from proteinshake.frontend.targets import Target -from proteinshake.frontend.splitters import Split -from proteinshake.frontend.task import Task -from proteinshake.frontend.transforms import * -from proteinshake.frontend.transforms import Transform, LabelTransform +from proteinshake.metric import Metric +from proteinshake.target import Target +from proteinshake.split import Split +from proteinshake.task import Task +from proteinshake.transform import * +from proteinshake.transforms import * class TestTask(unittest.TestCase): @@ -16,7 +16,7 @@ class MyTarget(Target): def __call__(self, dataset): return (((p,), p["label"]) for p in dataset) - class MyMetrics(Metrics): + class MyMetric(Metric): def __call__(self, y_true, y_pred): return {"Accuracy": np.random.random()} @@ -39,7 +39,7 @@ class MyTask(Task): dataset = "test" split = MySplit target = MyTarget - metrics = MyMetrics + metrics = MyMetric augmentation = MyAugmentation # END USER