classical-estimators
Use this sub-skill for MLAlgorithms supervised tabular estimators: linear/logistic regression, KNN, Naive Bayes, SVM kernels, random forests, gradient boosting, and experimental factorization machines.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- classical-estimators
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use this sub-skill for MLAlgorithms supervised tabular estimators: linear/logistic regression, KNN, Naive Bayes, SVM kernels, random forests, gradient boosting, and experimental factorization machines.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md6.2 KB
- 参考文档references/troubleshooting.md4.1 KB
- 参考文档references/workflows.md5.5 KB
- 脚本scripts/run_classical_smoke.py7.4 KB
03 SKILL.md 正文
Classical Estimators
Use this sub-skill when a task asks for MLAlgorithms' CPU-only supervised learning APIs, estimator selection, fit/predict examples, or debugging for tabular models. The package exposes scikit-learn-like classes but is intentionally minimal and educational; prefer explicit NumPy arrays, small datasets, and direct metric checks.
Route elsewhere
- Clustering, Gaussian mixtures, PCA, t-SNE, RBM, and package demo dataset loaders belong in
../unsupervised-and-reduction/SKILL.md. - The custom
NeuralNetstack, MLP/CNN/RNN/LSTM recipes, optimizers, activations, and DQN belong in../neural-network-building-blocks/SKILL.md. - Repo-wide install/import checks, package compatibility, provenance, and cross-cutting metrics are summarized in the root skill.
Start here
-
Confirm the environment imports the package and scientific stack:
python - <<'PY' import mla, numpy, scipy, sklearn, autograd from mla.linear_models import LinearRegression, LogisticRegression print("mla import ok") PY -
Pick the estimator family from the data and output shape:
- Continuous targets:
LinearRegression,KNNRegressor,RandomForestRegressor,GradientBoostingRegressor; treatFMRegressoras experimental in this version. - Binary class labels
{0, 1}:LogisticRegression,NaiveBayesClassifier, tree/boosting classifiers, KNN. - SVM: convert labels to
{-1, 1}before fitting.
- Continuous targets:
-
Convert inputs to NumPy arrays before calling
fit. The sharedBaseEstimatorconverts array-like inputs, but explicit arrays make shapes and dtype errors easier to diagnose. -
After
fit, callpredict(X_test)and validate withmla.metricsor an external metric such assklearn.metrics.roc_auc_score. -
For a deterministic smoke check, run
scripts/run_classical_smoke.pyfrom this sub-skill. It uses small synthetic datasets and does not read original repository examples.
Primary workflows
Linear and logistic regression
Use mla.linear_models.LinearRegression for continuous targets and LogisticRegression for binary probabilities. Both use gradient descent, so lr, max_iters, tolerance, penalty, and C directly affect convergence.
import numpy as np
from mla.linear_models import LogisticRegression
from mla.metrics.metrics import accuracy
X = np.asarray([[0.0], [0.2], [1.0], [1.2]])
y = np.asarray([0, 0, 1, 1])
model = LogisticRegression(lr=0.01, max_iters=200, penalty="l1", C=0.01)
model.fit(X, y)
proba = model.predict(np.asarray([[0.1], [1.1]]))
labels = (proba >= 0.5).astype(int)
K-nearest neighbors
Use KNNClassifier or KNNRegressor for simple instance-based baselines. The default distance function is scipy.spatial.distance.euclidean; pass another two-argument distance callable when needed. Set k=0 to use all training examples.
Naive Bayes
NaiveBayesClassifier implements Gaussian Naive Bayes for binary labels exactly [0, 1]. It returns normalized class-probability rows. Avoid constant-variance features unless you add preprocessing, because the Gaussian PDF divides by per-class variance.
SVM kernels
Import kernels from the repository's real module spelling, mla.svm.kernerls:
from mla.svm.svm import SVM
from mla.svm.kernerls import Linear, Poly, RBF
signed_y = (binary_y * 2) - 1
model = SVM(C=0.6, kernel=RBF(gamma=0.05), max_iter=200)
model.fit(X_train, signed_y)
pred = model.predict(X_test)
Tree ensembles and boosting
Use RandomForestClassifier/Regressor for bagged decision trees and GradientBoostingClassifier/Regressor for additive trees. Keep max_features less than the number of columns when you pass it explicitly.
Factorization machines
FMRegressor and FMClassifier exist in the package and expose the BaseFM constructor, but the current source initializes loss functions after the base training call. Treat these classes as experimental and verify a focused smoke before relying on fit.
Bundled references and helpers
- Read
references/api-reference.mdfor import paths, signatures, outputs, and version-specific caveats. - Read
references/workflows.mdfor supervised recipes and model-family selection guidance. - Read
references/troubleshooting.mdwhen fitting fails, scores are unstable, labels have the wrong encoding, or dependency versions drift. - Run
scripts/run_classical_smoke.py --workflow allto test a small installed-package baseline without original examples or downloads.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).