initial commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.venv/
|
||||
.pytest_cache/
|
||||
.coverage
|
||||
*.egg-info/
|
||||
.env
|
||||
uv.lock
|
||||
@@ -0,0 +1,21 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any
|
||||
|
||||
|
||||
class ScreeningModel(ABC):
|
||||
"""Standard train()/predict() interface every screening model implements,
|
||||
regardless of which of the three data marts (CaCu/CaMa/TEA) it targets.
|
||||
|
||||
Implementations are free to pull their own data straight from
|
||||
`persistance.<domain>` — the same standard repository API WebApi uses —
|
||||
or accept already-fetched rows from a caller; `data` is intentionally
|
||||
untyped at this scaffolding stage.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def train(self, data: Any = None) -> None:
|
||||
"""Fit the model, optionally on `data` passed in by the caller."""
|
||||
|
||||
@abstractmethod
|
||||
def predict(self, data: Any) -> Any:
|
||||
"""Score `data` and return predictions."""
|
||||
@@ -0,0 +1,19 @@
|
||||
from typing import Any
|
||||
|
||||
from models.base import ScreeningModel
|
||||
|
||||
|
||||
class CaCuModel(ScreeningModel):
|
||||
"""Scaffold for the CaCu (cervical cancer) screening model.
|
||||
|
||||
Can pull its own training data straight from `persistance.cacu`'s
|
||||
repositories (`paciente_repository`, `citologia_cervical_repository`,
|
||||
`biopsia_cervical_repository`, ...) or be handed already-fetched rows.
|
||||
No real model yet — this is interface scaffolding only.
|
||||
"""
|
||||
|
||||
def train(self, data: Any = None) -> None:
|
||||
raise NotImplementedError("CaCu training is not implemented yet.")
|
||||
|
||||
def predict(self, data: Any) -> Any:
|
||||
raise NotImplementedError("CaCu prediction is not implemented yet.")
|
||||
@@ -0,0 +1,19 @@
|
||||
from typing import Any
|
||||
|
||||
from models.base import ScreeningModel
|
||||
|
||||
|
||||
class CaMaModel(ScreeningModel):
|
||||
"""Scaffold for the CaMa (breast cancer) screening model.
|
||||
|
||||
Can pull its own training data straight from `persistance.cama`'s
|
||||
repositories (`paciente_repository`, `mastografia_repository`,
|
||||
`biopsia_mama_repository`, ...) or be handed already-fetched rows.
|
||||
No real model yet — this is interface scaffolding only.
|
||||
"""
|
||||
|
||||
def train(self, data: Any = None) -> None:
|
||||
raise NotImplementedError("CaMa training is not implemented yet.")
|
||||
|
||||
def predict(self, data: Any) -> Any:
|
||||
raise NotImplementedError("CaMa prediction is not implemented yet.")
|
||||
@@ -0,0 +1,19 @@
|
||||
from typing import Any
|
||||
|
||||
from models.base import ScreeningModel
|
||||
|
||||
|
||||
class TeaModel(ScreeningModel):
|
||||
"""Scaffold for the TEA (autism spectrum disorder) screening model.
|
||||
|
||||
Can pull its own training data straight from `persistance.tea`'s
|
||||
repositories (`pacientes_repository`, `evaluacion_psicologica_repository`,
|
||||
...) or be handed already-fetched rows. No real model yet — this is
|
||||
interface scaffolding only.
|
||||
"""
|
||||
|
||||
def train(self, data: Any = None) -> None:
|
||||
raise NotImplementedError("TEA training is not implemented yet.")
|
||||
|
||||
def predict(self, data: Any) -> Any:
|
||||
raise NotImplementedError("TEA prediction is not implemented yet.")
|
||||
@@ -0,0 +1,23 @@
|
||||
[project]
|
||||
name = "models"
|
||||
version = "0.1.0"
|
||||
description = "train()/predict() interfaces for the CaCu, CaMa and TEA screening models."
|
||||
requires-python = ">=3.11"
|
||||
dependencies = [
|
||||
"persistance",
|
||||
]
|
||||
|
||||
[tool.uv.sources]
|
||||
persistance = { path = "../Persistance", editable = true }
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["models"]
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"pytest>=8.0.0",
|
||||
]
|
||||
@@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
|
||||
from models.cacu import CaCuModel
|
||||
from models.cama import CaMaModel
|
||||
from models.tea import TeaModel
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cls", [CaCuModel, CaMaModel, TeaModel])
|
||||
def test_train_not_implemented(cls):
|
||||
model = cls()
|
||||
with pytest.raises(NotImplementedError):
|
||||
model.train()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cls", [CaCuModel, CaMaModel, TeaModel])
|
||||
def test_predict_not_implemented(cls):
|
||||
model = cls()
|
||||
with pytest.raises(NotImplementedError):
|
||||
model.predict(data=None)
|
||||
Reference in New Issue
Block a user