Back to list
pluginagentmarketplace

ml-fundamentals

by pluginagentmarketplace

Machine Learning Plugin Development

1🍴 1📅 Jan 5, 2026

SKILL.md


name: ml-fundamentals description: Master machine learning foundations - algorithms, preprocessing, feature engineering, and evaluation version: "1.4.0" sasmp_version: "1.4.0" bonded_agent: 01-ml-fundamentals bond_type: PRIMARY_BOND

Parameter Validation

parameters: required: - name: dataset type: dataframe validation: "non-empty, numeric or categorical columns" optional: - name: target_column type: string default: null - name: test_size type: float default: 0.2 validation: "0.1 <= x <= 0.4"

Retry Logic

retry_logic: strategy: exponential_backoff max_attempts: 3 base_delay_ms: 1000

Observability

logging: level: info metrics: [execution_time, memory_usage, data_shape]

ML Fundamentals Skill

Master the building blocks of machine learning: from raw data to trained models.

Quick Start

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
from sklearn.ensemble import RandomForestClassifier

# 1. Load and split data
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42, stratify=y
)

# 2. Create pipeline
pipeline = Pipeline([
    ('scaler', StandardScaler()),
    ('classifier', RandomForestClassifier(random_state=42))
])

# 3. Train and evaluate
pipeline.fit(X_train, y_train)
score = pipeline.score(X_test, y_test)
print(f"Accuracy: {score:.4f}")

Key Topics

1. Data Preprocessing

StepPurposeImplementation
Missing ValuesHandle NaN/NoneSimpleImputer(strategy='median')
ScalingNormalize rangesStandardScaler() or MinMaxScaler()
EncodingConvert categoriesOneHotEncoder() or LabelEncoder()
OutliersRemove extremesIQR method or Z-score
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.impute import SimpleImputer

# Define column types
numeric_features = ['age', 'income', 'score']
categorical_features = ['gender', 'city', 'category']

# Create preprocessor
preprocessor = ColumnTransformer([
    ('num', Pipeline([
        ('imputer', SimpleImputer(strategy='median')),
        ('scaler', StandardScaler())
    ]), numeric_features),
    ('cat', Pipeline([
        ('imputer', SimpleImputer(strategy='constant', fill_value='missing')),
        ('encoder', OneHotEncoder(handle_unknown='ignore'))
    ]), categorical_features)
])

2. Feature Engineering

TechniqueUse CaseExample
PolynomialNon-linear relationshipsPolynomialFeatures(degree=2)
BinningDiscretize continuousKBinsDiscretizer(n_bins=5)
Log TransformRight-skewed datanp.log1p(x)
InteractionFeature combinationsx1 * x2

3. Model Evaluation

from sklearn.model_selection import cross_val_score
from sklearn.metrics import classification_report

# Cross-validation
cv_scores = cross_val_score(model, X, y, cv=5, scoring='f1_weighted')
print(f"CV F1: {cv_scores.mean():.4f} (+/- {cv_scores.std()*2:.4f})")

# Detailed report
y_pred = model.predict(X_test)
print(classification_report(y_test, y_pred))

4. Cross-Validation Strategies

StrategyWhen to Use
KFoldStandard, balanced data
StratifiedKFoldImbalanced classification
TimeSeriesSplitTemporal data
GroupKFoldGrouped samples

Best Practices

DO

  • Split data BEFORE any preprocessing
  • Use pipelines for reproducibility
  • Stratify splits for classification
  • Log all preprocessing parameters
  • Version your feature engineering code

DON'T

  • Don't fit on test data
  • Don't ignore data leakage
  • Don't use accuracy for imbalanced data
  • Don't hard-code parameters

Exercises

Exercise 1: Basic Pipeline

# TODO: Create a pipeline that:
# 1. Imputes missing values
# 2. Scales features
# 3. Trains a logistic regression

Exercise 2: Cross-Validation

# TODO: Implement 5-fold stratified CV
# and report mean and std of F1 score

Unit Test Template

import pytest
import numpy as np
from sklearn.datasets import make_classification

def test_preprocessing_pipeline():
    """Test preprocessing handles missing values."""
    X, y = make_classification(n_samples=100, n_features=10)
    X[0, 0] = np.nan  # Introduce missing value

    pipeline = create_preprocessing_pipeline()
    X_transformed = pipeline.fit_transform(X)

    assert not np.isnan(X_transformed).any()
    assert X_transformed.shape[0] == X.shape[0]

def test_no_data_leakage():
    """Verify preprocessing doesn't leak test data."""
    X_train, X_test = X[:80], X[80:]

    pipeline.fit(X_train)
    X_test_transformed = pipeline.transform(X_test)

    # Check that test transform uses train statistics
    assert pipeline.named_steps['scaler'].mean_ is not None

Troubleshooting

ProblemCauseSolution
NaN in predictionMissing imputerAdd SimpleImputer to pipeline
Shape mismatchInconsistent featuresUse ColumnTransformer
Memory errorToo many one-hot featuresUse max_categories or hashing
Poor CV varianceData leakageCheck preprocessing order

Version: 1.4.0 | Status: Production Ready

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon