tessl install tessl/pypi-scikit-learn@1.7.0A comprehensive machine learning library providing supervised and unsupervised learning algorithms with consistent APIs and extensive tools for data preprocessing, model evaluation, and deployment.
Agent Success
Agent success rate when using this tile
87%
Improvement
Agent success rate improvement when using this tile compared to baseline
0.99x
Baseline
Agent success rate without this tile
88%
Design a small module that trains and serves multi-class and multi-label predictors using reduction strategies. Emphasis is on using built-in tooling from the declared dependency rather than hand-rolled loops.
[[0, 0], [1, 1], [1, 0], [0, 1]], label names ["primary", "secondary"], and binary targets [[0, 0], [1, 1], [1, 0], [0, 1]], fitting the independent-model trainer and predicting for [[1, 0], [0, 1]] should yield [["primary"], ["secondary"]] when using the default threshold of 0.5. @test[[1, 1]] using a threshold of 0.8 should return ["primary", "secondary"] as both labels clear the higher confidence cutoff. @test[[0], [1], [2], [3]] with label names ["base", "bonus"] and binary targets [[0, 0], [1, 0], [1, 1], [1, 1]], fitting the chain-based trainer with explicit order [0, 1] and predicting for [[0.5], [2.5]] should yield [[], ["base", "bonus"]]. @test[[0], [1], [2], [3]] and targets [0, 0, 1, 2], fitting the pairwise multiclass reducer and predicting for [[0.2], [2.6]] should yield [0, 2]. @test@generates
from typing import Any, Dict, List, Optional, Sequence, Tuple
Label = str
def train_independent(
X_train: Sequence[Sequence[float]],
Y_train: Sequence[Sequence[int]],
label_names: Sequence[Label]
) -> Any:
"""Fits and returns a multi-label model built from independent binary problems."""
def train_chained(
X_train: Sequence[Sequence[float]],
Y_train: Sequence[Sequence[int]],
label_names: Sequence[Label],
order: Optional[Sequence[int]] = None
) -> Any:
"""Fits and returns a dependency-aware chain model using the provided or inferred label order."""
def predict_labels(
model: Any,
X: Sequence[Sequence[float]],
label_names: Sequence[Label],
threshold: float = 0.5
) -> List[List[Label]]:
"""Predicts label sets for each sample using the provided fitted model."""
def train_pairwise(
X_train: Sequence[Sequence[float]],
y_train: Sequence[int]
) -> Any:
"""Fits and returns a multiclass model built from pairwise binary reductions."""
def predict_class(
model: Any,
X: Sequence[Sequence[float]]
) -> List[int]:
"""Predicts a single class label for each sample using the pairwise model."""Provides multioutput reduction strategies and base estimators.