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%
A small library for training and evaluating binary classifiers with two selectable algorithm families.
[[0, 0], [0, 1], [1, 0], [1, 1]] and labels [0, 0, 0, 1] produces a fitted model whose label predictions match the labels on the same points when using predict_labels. @test[[0, 0], [0, 1], [1, 0], [1, 1]] and labels [0, 1, 1, 0] produces a fitted model whose label predictions match [0, 1, 1, 0] on the same points when using predict_labels. @testValueError. @testpredict_probabilities returns an array shaped (n_samples, 2) where column 0 corresponds to label 0, column 1 corresponds to label 1, each row sums to 1.0, and the largest probability in each row corresponds to the label returned by predict_labels for the same input. @testevaluate_model trains using the chosen algorithm and returns an accuracy score between 0.0 and 1.0; on the [[0, 0], [0, 1], [1, 0], [1, 1]] and [0, 0, 0, 1] training data with identical test data it returns 1.0 when using the "linear" algorithm. @test@generates
from typing import Any, Literal
import numpy as np
Algorithm = Literal["linear", "ensemble"]
def train_model(features: np.ndarray, labels: np.ndarray, algorithm: Algorithm, random_state: int | None = None) -> Any:
"""Train a binary classifier using the selected algorithm and return the fitted model."""
def predict_labels(model: Any, features: np.ndarray) -> np.ndarray:
"""Return integer label predictions for each row in features."""
def predict_probabilities(model: Any, features: np.ndarray) -> np.ndarray:
"""Return probability estimates for class 0 then class 1, shaped (n_samples, 2)."""
def evaluate_model(
train_features: np.ndarray,
train_labels: np.ndarray,
test_features: np.ndarray,
test_labels: np.ndarray,
algorithm: Algorithm,
random_state: int | None = None,
) -> float:
"""Train on provided training data and report accuracy on provided test data."""Provides supervised learning estimators, preprocessing utilities, and evaluation helpers.