data-science-ml-ai999x — offline, verified data science and machine learning solver with step-by-step answers

Install · Capability guide · Evaluation · AI999X on Hugging Face · Website · Support: Buy Me a Coffee

License: Apache-2.0 · Author: Ibnul Jaif Farabi (creator and engineer) · Organization: AI999X · Version 1.0.3

Field: Data Science & Machine Learning · Tasks: Question Answering, Token Classification, Text Classification, Tabular Classification, Tabular Regression, Sentence Similarity, Feature Extraction

data-science-ml-ai999x is an offline, deterministic Python solver that answers data science and machine learning questions with verified results from 107 certified capabilities, gives 711 documented answers identically on Windows and Linux, and refuses rather than guesses when an answer cannot be verified.

data-science-ml-ai999x is a compact, deterministic data science and machine learning engine for Python. It reads a question in plain English (or a typed call), picks a certified data science and machine learning capability, computes the answer exactly, checks it, and returns the result with its steps, units, LaTeX and assumptions — or an honest refusal that says what is missing. It runs fully offline on any CPU, needs no GPU, no API key and no internet, and is built to give zero wrong answers: when it is not sure, it refuses instead of guessing.

Buy me a coffee License Python Offline

Highlights

  • Verified, not generated. Every answer is computed by a certified data science and machine learning capability and checked (substituted back, dimension-checked or compared with an independent computation) before it is returned.
  • Zero wrong answers by design. Seven explicit outcomes — SOLVED, NEEDS_INPUT, AMBIGUOUS, INVALID_INPUT, OUT_OF_SCOPE, UNRECOGNIZED_FORMAT, INTERNAL_ERROR — never a silent guess. Every one of its 711 documented answers is reproduced exactly on every tested platform.
  • Plain-English questions and a guaranteed typed interface. ask() reads documented question forms; solve(capability_id, **inputs) always solves a supported task with valid inputs.
  • Explains itself. Steps, formulas in LaTeX, units, assumptions and the model used, ready for notebooks, tutoring apps and homework checkers.
  • Small and portable. Pure Python (sympy, mpmath); identical answers on Windows and Linux (Python 3.10, 3.11, 3.12, 3.13, 3.14).
  • Coverage: classification and regression metrics, loss functions and gradients, information theory, clustering, classical machine-learning algorithms, neural-network arithmetic and ranking metrics.

Model overview

Property Value
Package data-science-ml-ai999x 1.0.3 (import data_science_ml_ai999x)
Type Deterministic neuro-symbolic data science and machine learning engine (rule-based reading + certified symbolic capabilities)
Capabilities 107 certified procedures
Knowledge pack version 1.0.0
Golden answers 711 documented answers, identical on every tested platform
Platforms tested Windows (Python 3.13), Linux x86-64 (Python 3.10, 3.11, 3.12, 3.13, 3.14)
Runtime CPU only, offline; no GPU, no network, no API key
License Apache-2.0
Creator / engineer Ibnul Jaif Farabi
Organization AI999X

Quickstart

pip install data-science-ml-ai999x
# or straight from this repository:
pip install https://huggingface.co/AI999X/data-science-ml-ai999x/resolve/main/dist/data_science_ml_ai999x-1.0.3-py3-none-any.whl
import data_science_ml_ai999x as data_science_ml

data_science_ml.ask("Binary metrics from counts: TP = 40, FP = 10, FN = 5, TN = 45").show()
# -> SOLVED — accuracy = 0.85, precision = 0.8, recall = 0.888889, specificity = 0.818182  (ml_binary_metrics_from_counts)
data_science_ml.ask("ROC AUC: y_true = [0, 1, 1, 0, 1], scores = [0.1, 0.9, 0.8, 0.3, 0.2]").show()
# -> SOLVED — auc = 0.833333, gini = 0.666667, n_pos = 3, n_neg = 2  (ml_roc_auc)
data_science_ml.ask("K-means clustering: X = [[1, 1], [1.5, 2], [3, 4], [5, 7], [3.5, 5], [4.5, 5], [3.5, 4.5]], C = [[1, 1], [5, 6]]").show()
# -> SOLVED — centroids = [[1.25, 1.5], [3.9, 5.1]], labels = [0, 0, 1, 1, 1, 1, 1], inertia = 8.525  (ml_kmeans)
data_science_ml.ask("Scaled dot-product attention: Q = [[1, 0], [0, 1]], K = [[1, 0], [0, 1], [1, 1]], V = [[1, 2], [3, 4], [5, 6]], causal = no").show()
# -> SOLVED — weights = [[0.40111209268, 0.19777581464, 0.40111209268], [0.19777581464, 0.40111209268, 0.40111209268]], output = [[3.0, 4.0], [3.40667255608, 4.40667255608]], output_sum = 14.8133  (ml_scaled_dot_product_attention)
data_science_ml.solve("ml_conv_output_size", n=224, kernel=7, stride=2, padding=3, dilation=1).show()
# -> SOLVED — output_size = 112, effective_kernel = 7  (ml_conv_output_size)
data_science_ml.ask("Who created you?").message
# -> data-science-ml-ai999x was created and engineered by Ibnul Jaif Farabi at AI999X.

Command line: data-science-ml-ai999x "<question>", data-science-ml-ai999x --capabilities. The outputs above were produced by running this exact code on data-science-ml-ai999x 1.0.3.

Find the right capability, and draw it

data_science_ml.search() finds which certified capability a question is about — across every AI999X model, so a question for another model points you to it. It runs ai999x-encoder, AI999X's own capability encoder (4.7M parameters, a 4.9 MB ONNX model, offline; the root model.safetensors of this repository): pip install "data-science-ml-ai999x[search]". ask(question, suggest=True) adds the same pointers to a question it does not answer; an answer itself never changes.

import data_science_ml_ai999x as data_science_ml

data_science_ml.search("Solve x^2 - 5x + 6 = 0", k=2)
# -> Roots of a quadratic equation (math-foundations-ai999x, 0.63); Roots of a cubic equation (math-foundations-ai999x, 0.59)

How every answer is verified

  1. Reading — the question is turned into typed quantities (value, unit, kind, role) and one asked quantity; every stated number must be used or the question is refused.
  2. Planning — only certified capabilities may answer; a capability applies only under the conditions the wording states (for example a pendulum, a liquid at rest, boiling).
  3. Computing — exact symbolic or high-precision numeric evaluation.
  4. Checking — dimensions, substitution back into the defining equation, and agreement between independent readings; any disagreement becomes a refusal, never a number.

Capabilities are certified before they ship: each must reproduce hand-worked reference cases, reject a deliberately wrong variant (a control), and leave every benchmark answer unchanged.

Worked examples

Each question was put to data-science-ml-ai999x; the answer is the one it returned, with the steps it took.

Binary classification metrics from confusion counts · Classification metrics

Binary metrics from counts: TP = 40, FP = 10, FN = 5, TN = 45

→ accuracy = 0.85, precision = 0.8, recall = 0.8888888889, specificity = 0.8181818182, f1 = 0.8421052632, npv = 0.9, balanced_accuracy = 0.8535353535, fpr = 0.1818181818, fnr = 0.1111111111, jaccard = 0.7272727273

Steps
  • Binary classification metrics from confusion counts: TP = 40, FP = 10, FN = 5, TN = 45 → accuracy = 0.85, precision = 0.8, recall = 0.8888888889, specificity = 0.8181818182, f1 = 0.8421052632, npv = 0.9, balanced_accuracy = 0.8535353535, fpr = 0.1818181818, fnr = 0.1111111111, jaccard = 0.7272727273

ROC AUC from scores · Classification metrics

ROC AUC: y_true = [0, 1, 1, 0, 1], scores = [0.1, 0.9, 0.8, 0.3, 0.2]

→ auc = 0.8333333333, gini = 0.6666666667, n_pos = 3, n_neg = 2

Steps
  • ROC AUC from scores: y_true = [0, 1, 1, 0, 1], scores = [0.1, 0.9, 0.8, 0.3, 0.2] → auc = 0.8333333333, gini = 0.6666666667, n_pos = 3, n_neg = 2

k-means clustering from given initial centroids · Classical algorithms

K-means clustering: X = [[1, 1], [1.5, 2], [3, 4], [5, 7], [3.5, 5], [4.5, 5], [3.5, 4.5]], C = [[1, 1], [5, 6]]

→ centroids = [[1.25, 1.5], [3.9, 5.1]], labels = [0, 0, 1, 1, 1, 1, 1], inertia = 8.525

Steps
  • k-means clustering from given initial centroids: X = [1 1; 1.5 2; 3 4; 5 7; 3.5 5; 4.5 5; 3.5 4.5], C = [1 1; 5 6] → centroids = [[1.25, 1.5], [3.9, 5.1]], labels = [0, 0, 1, 1, 1, 1, 1], inertia = 8.525

Scaled dot-product attention · Neural networks

Scaled dot-product attention: Q = [[1, 0], [0, 1]], K = [[1, 0], [0, 1], [1, 1]], V = [[1, 2], [3, 4], [5, 6]], causal = no

→ weights = [[0.4011120927, 0.1977758146, 0.4011120927], [0.1977758146, 0.4011120927, 0.4011120927]], output = [[3, 4], [3.406672556, 4.406672556]], output_sum = 14.81334511

Steps
  • Scaled dot-product attention: Q = [1 0; 0 1], K = [1 0; 0 1; 1 1], V = [1 2; 3 4; 5 6], causal = False → weights = [[0.4011120927, 0.1977758146, 0.4011120927], [0.1977758146, 0.4011120927, 0.4011120927]], output = [[3, 4], [3.406672556, 4.406672556]], output_sum = 14.81334511

Convolution output size · Neural networks

m.solve("ml_conv_output_size", n=224, kernel=7, stride=2, padding=3, dilation=1)

→ output_size = 112, effective_kernel = 7

Steps
  • Convolution output size: n = 224, kernel = 7, stride = 2, padding = 3, dilation = 1 → output_size = 112, effective_kernel = 7

Adjusted mutual information of two clusterings · Clustering metrics

Adjusted mutual information: labels_true = [0, 0, 1, 1, 2, 2], labels_pred = [0, 0, 1, 1, 1, 1], method = arithmetic

→ ami = 0.6153846154, expected_mi = 0.266835672, mutual_information = 0.6365141683

Steps
  • Adjusted mutual information of two clusterings: labels_true = [0, 0, 1, 1, 2, 2], labels_pred = [0, 0, 1, 1, 1, 1], method = arithmetic → ami = 0.6153846154, expected_mi = 0.266835672, mutual_information = 0.6365141683

Figures

Every point was computed by data-science-ml-ai999x.

ROC curve of a scored classifier

ROC curve of a scored classifier — computed by data-science-ml-ai999x

The ROC curve the package returns for 12 scored examples (labels 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0; scores 0.95, 0.9, 0.85, 0.8, 0.7, 0.65, 0.6, 0.5, 0.4, 0.35, 0.3, 0.1): true against false positive rate at each of its thresholds, with area under the curve 0.777778.

Confusion matrix of a three-class classifier

Confusion matrix of a three-class classifier — computed by data-science-ml-ai999x

The confusion matrix the package returns for true labels [0, 1, 2, 2, 1, 0, 2, 1] and predictions [0, 2, 2, 2, 1, 0, 1, 1]: rows are the true classes 0, 1, 2, columns the predicted ones; 6 of 8 on the diagonal, accuracy 0.75.

k-means clusters and their centroids

k-means clusters and their centroids — computed by data-science-ml-ai999x

k-means on 7 points from the starting centres [[1, 1], [5, 6]]: the package's final centroids (1.25, 1.5), (3.9, 5.1) (marked; arrows from the starting centres), cluster labels 1, 1, 2, 2, 2, 2, 2 and inertia 8.525.

Principal components: projection onto the first component

Principal components: projection onto the first component — computed by data-science-ml-ai999x

Principal components of 10 points: the package's first component (0.677873, 0.735179) through the mean of the points explains 96.3181 % of the variance (variance 1.28403 against 0.0490834); each point is joined to its projection at the score the package returns; the short arrow is two standard deviations (0.443095) along the second component.

Logistic regression: fitted probability and decision boundary

Logistic regression: fitted probability and decision boundary — computed by data-science-ml-ai999x

Logistic regression fitted by the package to x = 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4 with labels 0, 0, 1, 0, 1, 0, 1, 1 (C = 1): weight 0.738776, intercept -1.66225, training accuracy 0.75; the curve is the package's predicted probability at 81 points; marked: the decision boundary x = 2.25, P = 0.5.

k-nearest neighbours of a query point

k-nearest neighbours of a query point — computed by data-science-ml-ai999x

k-nearest-neighbour classification of the query point (3, 2.2) among 6 labelled points (k = 3, euclidean distance): the package's 3 nearest neighbours are points 2, 3, 5 at distances 1.28062, 1.56205, 2.00998 (dashed lines; the circle reaches the farthest of them); 2 of 3 votes give class 0.

Capabilities

107 certified procedures. A few of them:

  • Procedures: 2-D convolution of an image with a kernel (deep-learning convention); Adam optimizer: one update; AdamW optimizer (decoupled weight decay): one update; Adjusted R^2; Adjusted mutual information of two clusterings; Agglomerative hierarchical clustering merge heights; Average precision and precision-recall AUC; Averaged precision, recall and F1 (multi-class); Backpropagation gradients of a one-hidden-layer network; Balanced accuracy (multi-class); Balanced class weights; Batch normalisation forward pass (training mode); Bernoulli naive Bayes prediction (binary features); Best decision-tree split (classification, Gini or entropy); Best regression-tree split (squared error); Bias-variance decomposition of predictions; Binary classification metrics from confusion counts; Binary confusion matrix from labels; Binary cross-entropy with logits and its gradient; Binary focal loss and its gradient; Binary log loss (cross-entropy); Brier score; Calinski-Harabasz index; Cohen's kappa (unweighted, linear or quadratic) …

data_science_ml_ai999x.templates() lists every question form ask() reads; the capability guide (PDF, every example executed) is included in this repository.

All 107 formulas

Show every formula, by topic

Classical algorithms

Agglomerative hierarchical clustering merge heights

d(k,i∪j)=(ni+nk)dki2+(nj+nk)dkj2−nkdij2ni+nj+nk (Ward) d(k, i \cup j) = \sqrt{\frac{(n_i + n_k)d_{ki}^2 + (n_j + n_k)d_{kj}^2 - n_k d_{ij}^2}{n_i + n_j + n_k}}\ \text{(Ward)}

Bernoulli naive Bayes prediction (binary features)

P(x∣c)=∏jpcjxj(1−pcj)1−xj P(x \mid c) = \prod_j p_{cj}^{x_j}(1 - p_{cj})^{1 - x_j}

Best decision-tree split (classification, Gini or entropy)

ΔI=I(S)−∣SL∣∣S∣I(SL)−∣SR∣∣S∣I(SR) \Delta I = I(S) - \frac{\vert S_L\vert }{\vert S\vert }I(S_L) - \frac{\vert S_R\vert }{\vert S\vert }I(S_R)

Best regression-tree split (squared error)

Δ=1n[SSE(S)−SSE(SL)−SSE(SR)] \Delta = \frac{1}{n}\left[SSE(S) - SSE(S_L) - SSE(S_R)\right]

Distances and cosine similarity between two vectors

d2=∑i(xi−zi)2,cos⁡θ=x⋅zvertxvertvertzvert d_2 = \sqrt{\sum_i (x_i - z_i)^2},\quad \cos\theta = \frac{x \cdot z}{\\vert x\\vert \\vert z\\vert }

Gaussian naive Bayes prediction

P(c∣x)∝P(c)∏jN(xj; μcj,σcj2) P(c \mid x) \propto P(c)\prod_j \mathcal{N}(x_j;\ \mu_{cj}, \sigma^2_{cj})

Multinomial naive Bayes prediction (word counts)

θ^cj=Ncj+αNc+αd,log⁡P(c∣x)=log⁡P(c)+∑jxjlog⁡θ^cj+const \hat\theta_{cj} = \frac{N_{cj} + \alpha}{N_c + \alpha d},\quad \log P(c \mid x) = \log P(c) + \sum_j x_j \log\hat\theta_{cj} + \text{const}

One k-means iteration (assignment and update)

c(i)=arg⁡min⁡kvertxi−μkvert2,μk′=1∣Sk∣∑i∈Skxi c(i) = \arg\min_k \\vert x_i - \mu_k\\vert ^2,\quad \mu_k' = \frac{1}{\vert S_k\vert }\sum_{i \in S_k} x_i

Polynomial kernel

k(x,z)=(γ x⊤z+c0)d k(x, z) = (\gamma\, x^\top z + c_0)^d

RBF (Gaussian) kernel matrix

Kij=exp⁡(−γ vertxi−xjvert2) K_{ij} = \exp\left(-\gamma\,\\vert x_i - x_j\\vert ^2\right)

k-means clustering from given initial centroids

min⁡∑k∑i∈Skvertxi−μkvert2 \min \sum_k \sum_{i \in S_k} \\vert x_i - \mu_k\\vert ^2

k-nearest-neighbour classification of a query point

y^=arg⁡max⁡c∑i∈Nk(x)1(yi=c) \hat y = \arg\max_c \sum_{i \in N_k(x)} \mathbb{1}(y_i = c)

k-nearest-neighbour regression of a query point

y^=∑i∈Nkwiyi∑i∈Nkwi,wi=1 or 1/di \hat y = \frac{\sum_{i \in N_k} w_i y_i}{\sum_{i \in N_k} w_i},\quad w_i = 1 \text{ or } 1/d_i

Classification metrics

Average precision and precision-recall AUC

AP=∑k(Rk−Rk−1) Pk \mathrm{AP} = \sum_k (R_k - R_{k-1})\,P_k

Averaged precision, recall and F1 (multi-class)

F1macro=1K∑k2PkRkPk+Rk F_1^{\mathrm{macro}} = \frac{1}{K}\sum_k \frac{2P_kR_k}{P_k+R_k}

Balanced accuracy (multi-class)

BA=1K∑kTPkTPk+FNk \mathrm{BA} = \frac{1}{K}\sum_{k} \frac{TP_k}{TP_k + FN_k}

Balanced class weights

wc=nK nc w_c = \frac{n}{K\, n_c}

Binary classification metrics from confusion counts

P=TPTP+FP,  R=TPTP+FN,  F1=2PRP+R=2TP2TP+FP+FN P = \frac{TP}{TP+FP},\; R = \frac{TP}{TP+FN},\; F_1 = \frac{2PR}{P+R} = \frac{2TP}{2TP+FP+FN}

Binary confusion matrix from labels

accuracy=TP+TNTP+FP+FN+TN \mathrm{accuracy} = \frac{TP + TN}{TP + FP + FN + TN}

Binary log loss (cross-entropy)

L=−1n∑i[yiln⁡pi+(1−yi)ln⁡(1−pi)] \mathcal{L} = -\frac{1}{n}\sum_i \left[y_i \ln p_i + (1-y_i)\ln(1-p_i)\right]

Brier score

BS=1n∑i(pi−yi)2 \mathrm{BS} = \frac{1}{n}\sum_i (p_i - y_i)^2

Cohen's kappa (unweighted, linear or quadratic)

κ=1−∑ijwijOij∑ijwijEij,Eij=ricjn \kappa = 1 - \frac{\sum_{ij} w_{ij} O_{ij}}{\sum_{ij} w_{ij} E_{ij}},\quad E_{ij} = \frac{r_i c_j}{n}

Confusion counts, precision and recall at a score threshold

y^i=1(si≥t) \hat y_i = \mathbb{1}(s_i \ge t)

Expected calibration error

ECE=∑bnbn∣yˉb−pˉb∣ \mathrm{ECE} = \sum_b \frac{n_b}{n}\left\vert \bar y_b - \bar p_b\right\vert

F-beta score

Fβ=(1+β2) PRβ2P+R F_\beta = \frac{(1+\beta^2)\,P R}{\beta^2 P + R}

Hamming loss and subset accuracy (multi-label)

HL=1nL∑i,j1(Yij≠Y^ij) \mathrm{HL} = \frac{1}{nL}\sum_{i,j} \mathbb{1}(Y_{ij} \neq \hat Y_{ij})

Matthews correlation coefficient

MCC=TP TN−FP FN(TP+FP)(TP+FN)(TN+FP)(TN+FN) \mathrm{MCC} = \frac{TP\,TN - FP\,FN}{\sqrt{(TP+FP)(TP+FN)(TN+FP)(TN+FN)}}

Multi-class confusion matrix

Cij=#{n:yn=ci, y^n=cj} C_{ij} = \#\{n : y_n = c_i,\ \hat y_n = c_j\}

Multi-class log loss (categorical cross-entropy)

L=−1n∑iln⁡Pi,yi \mathcal{L} = -\frac{1}{n}\sum_i \ln P_{i, y_i}

Per-class precision, recall, F1 and support

Pk=TPkTPk+FPk,Rk=TPkTPk+FNk P_k = \frac{TP_k}{TP_k + FP_k},\quad R_k = \frac{TP_k}{TP_k + FN_k}

ROC AUC from scores

AUC=1n+n−∑i∈+∑j∈−[1(si>sj)+121(si=sj)] \mathrm{AUC} = \frac{1}{n_+ n_-}\sum_{i \in +}\sum_{j \in -}\left[\mathbb{1}(s_i > s_j) + \tfrac12 \mathbb{1}(s_i = s_j)\right]

ROC curve points

TPR(t)=TP(t)P, FPR(t)=FP(t)N \mathrm{TPR}(t) = \frac{TP(t)}{P},\ \mathrm{FPR}(t) = \frac{FP(t)}{N}

Top-k accuracy

top-k=1n∑i1[ranki(yi)≤k] \mathrm{top}\text{-}k = \frac{1}{n}\sum_i \mathbb{1}\left[\mathrm{rank}_i(y_i) \le k\right]

Clustering metrics

Adjusted mutual information of two clusterings

AMI=I−E[I]mean(H(U),H(V))−E[I] \mathrm{AMI} = \frac{I - E[I]}{\mathrm{mean}(H(U), H(V)) - E[I]}

Calinski-Harabasz index

CH=tr(B)tr(W)⋅n−KK−1 CH = \frac{\mathrm{tr}(B)}{\mathrm{tr}(W)}\cdot\frac{n - K}{K - 1}

Davies-Bouldin index

DB=1K∑kmax⁡m≠kSk+Smvertck−cmvert DB = \frac{1}{K}\sum_k \max_{m \ne k}\frac{S_k + S_m}{\\vert c_k - c_m\\vert }

Homogeneity, completeness and V-measure

h=1−H(C∣K)H(C),c=1−H(K∣C)H(K),Vβ=(1+β)hcβh+c h = 1 - \frac{H(C \mid K)}{H(C)},\quad c = 1 - \frac{H(K \mid C)}{H(K)},\quad V_\beta = \frac{(1+\beta)hc}{\beta h + c}

Normalised mutual information of two clusterings

NMI=I(U,V)mean(H(U),H(V)) \mathrm{NMI} = \frac{I(U, V)}{\mathrm{mean}(H(U), H(V))}

Rand index, adjusted Rand index and Fowlkes-Mallows index

ARI=∑ij(nij2)−∑i(ai2)∑j(bj2)(n2)12[∑i(ai2)+∑j(bj2)]−∑i(ai2)∑j(bj2)(n2) \mathrm{ARI} = \frac{\sum_{ij}\binom{n_{ij}}{2} - \frac{\sum_i\binom{a_i}{2}\sum_j\binom{b_j}{2}}{\binom{n}{2}}}{\frac12\left[\sum_i\binom{a_i}{2} + \sum_j\binom{b_j}{2}\right] - \frac{\sum_i\binom{a_i}{2}\sum_j\binom{b_j}{2}}{\binom{n}{2}}}

Silhouette score

si=bi−aimax⁡(ai,bi) s_i = \frac{b_i - a_i}{\max(a_i, b_i)}

Dimensionality reduction

Principal component analysis (explained variance and first component)

Σ=1n−1(X−Xˉ)⊤(X−Xˉ)=VΛV⊤ \Sigma = \frac{1}{n-1}(X - \bar X)^\top (X - \bar X) = V \Lambda V^\top

Gradients

Logistic regression loss and gradient (L2-regularised)

L=1n∑i[log⁡(1+ezi)−yizi]+λ2vertwvert2,∇wL=1nX⊤(σ(z)−y)+λw L = \frac{1}{n}\sum_i \left[\log(1 + e^{z_i}) - y_i z_i\right] + \frac{\lambda}{2}\\vert w\\vert ^2,\quad \nabla_w L = \frac{1}{n}X^\top(\sigma(z) - y) + \lambda w

Mean squared error loss and gradient of a linear model

L=1nvertXw+b−yvert2,∇wL=2nX⊤(Xw+b−y) L = \frac{1}{n}\\vert Xw + b - y\\vert ^2,\quad \nabla_w L = \frac{2}{n}X^\top(Xw + b - y)

One gradient-descent step for linear regression

w←w−η∇wL,b←b−η∂L∂b w \leftarrow w - \eta \nabla_w L,\quad b \leftarrow b - \eta \frac{\partial L}{\partial b}

Information theory

Gini impurity decrease of a split

ΔG=G(S)−∑v∣Sv∣∣S∣G(Sv) \Delta G = G(S) - \sum_v \frac{\vert S_v\vert }{\vert S\vert }G(S_v)

Information gain and gain ratio of a split

IG=H(Y)−∑v∣Sv∣∣S∣H(Y∣X=v),GR=IGH(X) IG = H(Y) - \sum_v \frac{\vert S_v\vert }{\vert S\vert } H(Y \mid X = v),\quad GR = \frac{IG}{H(X)}

Joint, marginal and conditional entropy and mutual information

H(Y∣X)=H(X,Y)−H(X),I(X;Y)=∑ijPijlog⁡PijPiPj H(Y \mid X) = H(X, Y) - H(X),\quad I(X;Y) = \sum_{ij} P_{ij}\log\frac{P_{ij}}{P_i P_j}

KL divergence, Jensen-Shannon divergence and cross-entropy of discrete distributions

DKL(pvertq)=∑ipilog⁡piqi,H(p,q)=H(p)+DKL(pvertq) D_{KL}(p \\vert q) = \sum_i p_i \log\frac{p_i}{q_i},\quad H(p, q) = H(p) + D_{KL}(p \\vert q)

Mutual information between two label sequences

I(X;Y)=∑ijnijnlog⁡n nijaibj I(X;Y) = \sum_{ij} \frac{n_{ij}}{n}\log\frac{n\,n_{ij}}{a_i b_j}

Node impurity from class counts (entropy, Gini, misclassification)

G=1−∑kpk2,H=−∑kpklog⁡2pk G = 1 - \sum_k p_k^2,\quad H = -\sum_k p_k \log_2 p_k

Shannon entropy and perplexity of a distribution

H(p)=−∑ipilog⁡pi H(p) = -\sum_i p_i \log p_i

Linear models

Lasso regression coefficients (stated alpha)

min⁡w,b 12nverty−Xw−bvert2+αvertwvert1 \min_{w,b}\ \frac{1}{2n}\\vert y - Xw - b\\vert ^2 + \alpha\\vert w\\vert _1

Linear SVM decision values, classes and margin

f(x)=w⊤x+b,margin=2vertwvert f(x) = w^\top x + b,\quad \text{margin} = \frac{2}{\\vert w\\vert }

Logistic regression fit (L2, stated C)

min⁡w,b 12vertwvert2+C∑ilog⁡(1+e−y~i(w⊤xi+b)) \min_{w,b}\ \tfrac12\\vert w\\vert ^2 + C\sum_i \log\left(1 + e^{-\tilde y_i (w^\top x_i + b)}\right)

Logistic regression prediction from given weights

P(y=1∣x)=σ(w⊤x+b) P(y = 1 \mid x) = \sigma(w^\top x + b)

Perceptron training epoch

if yi(w⊤xi+b)≤0: w←w+ηyixi, b←b+ηyi \text{if } y_i(w^\top x_i + b) \le 0:\ w \leftarrow w + \eta y_i x_i,\ b \leftarrow b + \eta y_i

Ridge regression coefficients (stated alpha)

w^=(Xc⊤Xc+αI)−1Xc⊤yc \hat w = (X_c^\top X_c + \alpha I)^{-1} X_c^\top y_c

Loss functions and activations

Binary cross-entropy with logits and its gradient

ℓ(z,y)=max⁡(z,0)−zy+log⁡(1+e−∣z∣),∂ℓ∂z=σ(z)−y \ell(z, y) = \max(z, 0) - z y + \log(1 + e^{-\vert z\vert }),\quad \frac{\partial \ell}{\partial z} = \sigma(z) - y

Binary focal loss and its gradient

FL=−αt(1−pt)γlog⁡pt FL = -\alpha_t (1 - p_t)^\gamma \log p_t

Cross-entropy loss from logits and its gradient

L=−log⁡ezy∑jezj,∂L∂zj=pj−1(j=y) L = -\log\frac{e^{z_y}}{\sum_j e^{z_j}},\quad \frac{\partial L}{\partial z_j} = p_j - \mathbb{1}(j = y)

Cross-entropy with label smoothing

qj=εK+(1−ε)1(j=y),L=−∑jqjlog⁡σ(z)j q_j = \frac{\varepsilon}{K} + (1-\varepsilon)\mathbb{1}(j=y),\quad L = -\sum_j q_j \log \sigma(z)_j

Hinge and squared hinge loss

ℓ(y,f)=max⁡(0, 1−yf) \ell(y, f) = \max(0,\ 1 - y f)

Huber, smooth L1 and pseudo-Huber loss

Lδ(r)={12r2∣r∣≤δδ (∣r∣−12δ)∣r∣>δ L_\delta(r) = \begin{cases} \tfrac12 r^2 & \vert r\vert \le \delta \\ \delta\,(\vert r\vert - \tfrac12\delta) & \vert r\vert > \delta \end{cases}

Log-softmax

log⁡σ(z)i=zi−m−log⁡∑jezj−m \log\sigma(z)_i = z_i - m - \log\sum_j e^{z_j - m}

Multi-class hinge loss (Crammer-Singer and Weston-Watkins)

ℓCS=max⁡(0, 1−fy+max⁡j≠yfj),ℓWW=1K∑j≠ymax⁡(0, 1−fy+fj) \ell_{CS} = \max\left(0,\ 1 - f_y + \max_{j \ne y} f_j\right),\quad \ell_{WW} = \frac{1}{K}\sum_{j \ne y}\max(0,\ 1 - f_y + f_j)

Quantile (pinball) loss

Lα(y,q)=max⁡{α(y−q), (α−1)(y−q)} L_\alpha(y, q) = \max\{\alpha (y - q),\ (\alpha - 1)(y - q)\}

Sigmoid (logistic function) and its derivative

σ(z)=11+e−z,σ′(z)=σ(z) (1−σ(z)) \sigma(z) = \frac{1}{1 + e^{-z}},\quad \sigma'(z) = \sigma(z)\,(1 - \sigma(z))

Softmax

σ(z)i=ezi−m∑jezj−m, m=max⁡jzj \sigma(z)_i = \frac{e^{z_i - m}}{\sum_j e^{z_j - m}},\ m = \max_j z_j

Softmax with temperature

pi=ezi/T∑jezj/T p_i = \frac{e^{z_i / T}}{\sum_j e^{z_j / T}}

Triplet margin loss

L=max⁡(0, verta−pvert2−verta−nvert2+m) L = \max\left(0,\ \\vert a - p\\vert _2 - \\vert a - n\\vert _2 + m\right)

Model selection

Bias-variance decomposition of predictions

E[(f^−f)2]=(E[f^]−f)2+E[(f^−E[f^])2] E[(\hat f - f)^2] = (E[\hat f] - f)^2 + E[(\hat f - E[\hat f])^2]

Leave-one-out cross-validation of linear regression (PRESS)

PRESS=∑i(ei1−hii)2,hii=xi⊤(X⊤X)−1xi \mathrm{PRESS} = \sum_i \left(\frac{e_i}{1 - h_{ii}}\right)^2,\quad h_{ii} = x_i^\top (X^\top X)^{-1} x_i

Train/test split sizes

ntest=⌈t n⌉,ntrain=n−ntest n_{\mathrm{test}} = \lceil t\,n \rceil,\quad n_{\mathrm{train}} = n - n_{\mathrm{test}}

k-fold cross-validated MSE of linear regression

CVk=1k∑i=1kMSEi \mathrm{CV}_k = \frac{1}{k}\sum_{i=1}^k \mathrm{MSE}_i

k-fold cross-validation fold sizes

∣Fi∣=⌊n/k⌋+1(i<n  k) \vert F_i\vert = \lfloor n/k \rfloor + \mathbb{1}(i < n \bmod k)

Neural networks

2-D convolution of an image with a kernel (deep-learning convention)

Yij=∑a,bXis+a, js+b Kab Y_{ij} = \sum_{a,b} X_{is + a,\ js + b}\, K_{ab}

Backpropagation gradients of a one-hidden-layer network

δ2=∂L∂z2, ∇W2=δ2h⊤, δ1=(W2⊤δ2)⊙ϕ′(z1), ∇W1=δ1x⊤ \delta_2 = \frac{\partial L}{\partial z_2},\ \nabla_{W_2} = \delta_2 h^\top,\ \delta_1 = (W_2^\top \delta_2) \odot \phi'(z_1),\ \nabla_{W_1} = \delta_1 x^\top

Batch normalisation forward pass (training mode)

x^=x−μBσB2+ε,y=γx^+β \hat x = \frac{x - \mu_B}{\sqrt{\sigma_B^2 + \varepsilon}},\quad y = \gamma \hat x + \beta

Convolution output size

nout=⌊n+2p−d(k−1)−1s⌋+1 n_{\mathrm{out}} = \left\lfloor \frac{n + 2p - d(k-1) - 1}{s} \right\rfloor + 1

Forward pass of a one-hidden-layer dense network

h=ϕ(W1x+b1),y^=g(W2h+b2) h = \phi(W_1 x + b_1),\quad \hat y = g(W_2 h + b_2)

Max pooling and average pooling

Yij=max⁡a,b<kXis+a, js+b Y_{ij} = \max_{a,b < k} X_{is+a,\ js+b}

Multi-head attention (identity projections)

MHA=[head1,…,headh],headi=softmax ⁣(QiKi⊤d/h)Vi \mathrm{MHA} = [\mathrm{head}_1, \dots, \mathrm{head}_h],\quad \mathrm{head}_i = \mathrm{softmax}\!\left(\frac{Q_i K_i^\top}{\sqrt{d/h}}\right)V_i

Parameter count of a 2-D convolution layer

P=Cout Cing khkw+Cout P = C_{\mathrm{out}}\,\frac{C_{\mathrm{in}}}{g}\,k_h k_w + C_{\mathrm{out}}

Parameter count of a dense (fully connected) network

P=∑l(nl−1nl+nl) P = \sum_l (n_{l-1} n_l + n_l)

Parameter count of a transformer encoder

Player=4d2+4d+2d dff+dff+d+4d P_{\mathrm{layer}} = 4d^2 + 4d + 2 d\,d_{ff} + d_{ff} + d + 4d

Parameter count of an LSTM, GRU or simple RNN

P=G h (nin+h)+2Gh P = G\,h\,(n_{\mathrm{in}} + h) + 2Gh

Receptive field of stacked convolutions

r=1+∑l(kl−1) dl∏i<lsi r = 1 + \sum_l (k_l - 1)\, d_l \prod_{i < l} s_i

Scaled dot-product attention

Attention(Q,K,V)=softmax ⁣(QK⊤dk)V \mathrm{Attention}(Q, K, V) = \mathrm{softmax}\!\left(\frac{QK^\top}{\sqrt{d_k}}\right)V

Optimizers

Adam optimizer: one update

m^=mt1−β1t, v^=vt1−β2t,wt=wt−1−ηm^v^+ε \hat m = \frac{m_t}{1 - \beta_1^t},\ \hat v = \frac{v_t}{1 - \beta_2^t},\quad w_t = w_{t-1} - \eta \frac{\hat m}{\sqrt{\hat v} + \varepsilon}

AdamW optimizer (decoupled weight decay): one update

w←w(1−ηλ),wt=w−ηm^v^+ε w \leftarrow w(1 - \eta\lambda),\quad w_t = w - \eta \frac{\hat m}{\sqrt{\hat v} + \varepsilon}

Cosine-annealing learning-rate schedule

ηt=ηmin⁡+12(ηmax⁡−ηmin⁡)(1+cos⁡πtT) \eta_t = \eta_{\min} + \tfrac12(\eta_{\max} - \eta_{\min})\left(1 + \cos\frac{\pi t}{T}\right)

Linear warm-up followed by cosine decay

ηt={ηmax⁡(f+(1−f)tW)t<Wηmin⁡+12(ηmax⁡−ηmin⁡)(1+cos⁡π(t−W)T−W)t≥W \eta_t = \begin{cases} \eta_{\max}\left(f + (1-f)\frac{t}{W}\right) & t < W \\ \eta_{\min} + \tfrac12(\eta_{\max}-\eta_{\min})\left(1 + \cos\frac{\pi (t - W)}{T - W}\right) & t \ge W \end{cases}

SGD with momentum: one update

bt=μbt−1+gt,wt=wt−1−η bt b_t = \mu b_{t-1} + g_t,\quad w_t = w_{t-1} - \eta\, b_t

Step learning-rate schedule

ηt=η0 γ⌊t/s⌋ \eta_t = \eta_0\, \gamma^{\lfloor t / s \rfloor}

Preprocessing

Label encoding and one-hot encoding of categories

onehot(v)j=1(v=cj) \mathrm{onehot}(v)_j = \mathbb{1}(v = c_j)

Min-max scaling to [0, 1]

x′=x−min⁡jmax⁡j−min⁡j x' = \frac{x - \min_j}{\max_j - \min_j}

Robust scaling (median and interquartile range)

x′=x−medianQ3−Q1 x' = \frac{x - \mathrm{median}}{Q_3 - Q_1}

Standardisation (z-scores of features)

zij=xij−xˉjsj,sj2=1n∑i(xij−xˉj)2 z_{ij} = \frac{x_{ij} - \bar x_j}{s_j},\quad s_j^2 = \frac{1}{n}\sum_i (x_{ij} - \bar x_j)^2

Ranking metrics

Mean average precision (MAP) of rankings

AP=1∣rel∣∑k: relk=1P@k,MAP=1Q∑qAPq \mathrm{AP} = \frac{1}{\vert \mathrm{rel}\vert }\sum_{k:\ \mathrm{rel}_k = 1} P@k,\quad \mathrm{MAP} = \frac{1}{Q}\sum_q \mathrm{AP}_q

Mean reciprocal rank (MRR)

MRR=1Q∑q1rankq \mathrm{MRR} = \frac{1}{Q}\sum_q \frac{1}{\mathrm{rank}_q}

NDCG@k (normalised discounted cumulative gain)

DCG@k=∑i=1kgilog⁡2(i+1),NDCG@k=DCG@kIDCG@k \mathrm{DCG}@k = \sum_{i=1}^k \frac{g_i}{\log_2(i + 1)},\quad \mathrm{NDCG}@k = \frac{\mathrm{DCG}@k}{\mathrm{IDCG}@k}

Precision@k and recall@k of a ranking

P@k=∣rel∩topk∣k,R@k=∣rel∩topk∣∣rel∣ P@k = \frac{\vert \mathrm{rel} \cap \mathrm{top}_k\vert }{k},\quad R@k = \frac{\vert \mathrm{rel} \cap \mathrm{top}_k\vert }{\vert \mathrm{rel}\vert }

Regression metrics

Adjusted R^2

Rˉ2=1−(1−R2)n−1n−p−1 \bar R^2 = 1 - (1 - R^2)\frac{n-1}{n-p-1}

Mean Tweedie deviance (normal, Poisson, gamma, compound Poisson-gamma)

dp(y,μ)=2(y2−p(1−p)(2−p)−yμ1−p1−p+μ2−p2−p) d_p(y, \mu) = 2\left(\frac{y^{2-p}}{(1-p)(2-p)} - \frac{y\mu^{1-p}}{1-p} + \frac{\mu^{2-p}}{2-p}\right)

Mean absolute percentage error

MAPE=1n∑i∣yi−y^i∣∣yi∣ \mathrm{MAPE} = \frac{1}{n}\sum_i \frac{\vert y_i - \hat y_i\vert }{\vert y_i\vert }

Mean squared logarithmic error

MSLE=1n∑i(ln⁡(1+yi)−ln⁡(1+y^i))2 \mathrm{MSLE} = \frac{1}{n}\sum_i \left(\ln(1+y_i) - \ln(1+\hat y_i)\right)^2

Regression metrics (MAE, MSE, RMSE, R^2, explained variance)

R2=1−∑(yi−y^i)2∑(yi−yˉ)2,RMSE=1n∑(yi−y^i)2 R^2 = 1 - \frac{\sum (y_i - \hat y_i)^2}{\sum (y_i - \bar y)^2},\quad \mathrm{RMSE} = \sqrt{\tfrac{1}{n}\sum (y_i - \hat y_i)^2}

Out of scope

  • Open-ended explanation, essay writing or tutoring dialogue: it is a solver, not a chatbot.
  • Questions outside its certified data science and machine learning capabilities, and any question whose stated numbers it cannot all use — it refuses with the reason instead.
  • High-stakes engineering, medical or legal decisions without independent review.

Limitations

  • It answers what its certified capabilities cover (classification and regression metrics, loss functions and gradients, information theory, clustering, classical machine-learning algorithms, neural-network arithmetic and ranking metrics); anything else is refused with a reason.
  • ask() reads documented question forms and common phrasings; unusual wording may be refused — use solve() for guaranteed results.
  • Results are as correct as the certified relations and their stated conditions; a certified relation is a checked model, not a claim about every physical situation.

Citation

@software{data_science_ml_ai999x_1_0_3,
  title  = {data-science-ml-ai999x: an offline, verified data science and machine learning solver},
  author = {Farabi, Ibnul Jaif}, organization = {AI999X},
  year   = {2026}, version = {1.0.3},
  url    = {https://huggingface.co/AI999X/data-science-ml-ai999x}
}

Contact

Questions, bug reports and requests: open a discussion on https://huggingface.co/AI999X/data-science-ml-ai999x/discussions or visit https://ai999x.com.

Support the project

data-science-ml-ai999x is free and open source. If it helps you, you can support further development on Buy Me a Coffee.

Created and engineered by Ibnul Jaif Farabi · AI999X · ai999x.com

Downloads last month
63
Safetensors
Model size
4.72M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collections including AI999X/data-science-ml-ai999x

Evaluation results

  • identical on every platform on Golden answers (711 documented questions, Windows + Linux Python 3.10-3.14)
    self-reported
    1.000
  • right capability first on Capability search, 12998 held-out verified questions across all AI999X models
    self-reported
    0.918
  • in the top five on Capability search, 12998 held-out verified questions across all AI999X models
    self-reported
    0.988