# Predictive & Customer Analytics API > K-means and DBSCAN clustering, PCA, CART and random-forest importance, Kaplan-Meier and Cox survival, cohort retention, RFM segments, BG/NBD CLV, market-basket rules, PELT changepoints, classification metrics, correlations and propensity-score matching — pure computation on the numbers you send. Each paid operation uses a fixed USDC price on Base with the x402 exact scheme. Unpaid GET, HEAD, and POST return 402 payment terms (POST validates the body only after payment terms are satisfied). A request that carries payment-signature is not yet charged: settlement happens only after a successful (2xx) result. HTTP 4xx/5xx are not charged. Coverage bodies with status complete, partial, or failed all return HTTP 200 and are charged at the full listed price. Settled 2xx responses include a payment-response header; 4xx/5xx do not. Follow https://www.brainiac.software/agent-instructions.txt for install, payment pins, idempotency, and billing rules. - Product: https://www.brainiac.software/api/predictive-analytics - Docs: https://www.brainiac.software/api/predictive-analytics/docs - OpenAPI: https://www.brainiac.software/api/predictive-analytics/openapi.json - Contact: support@brainiac.software (https://www.brainiac.software/contact) ## Operations ### POST /api/v1/predictive-analytics/kmeans-cluster $0.04 USDC. Lloyd k-means with k-means++ seeding, optional standardisation, nInit restarts, silhouette and inertia for a k range, and stable label renumbering. Inputs: columns, rows, k?, kRange?, standardize?, seed?, nInit?, maxIter? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-kmeans-cluster Example request: ```json { "columns": [ "x", "y" ], "rows": [ [ 1, 1 ], [ 1.5, 2 ], [ 2, 1.5 ], [ 1.2, 1.4 ], [ 8, 8 ], [ 8.5, 9 ], [ 9, 8.2 ], [ 8.2, 8.8 ], [ 1, 9 ], [ 1.5, 8.5 ], [ 2, 9.2 ], [ 1.3, 8.8 ] ], "k": 3, "kRange": [ 2, 4 ], "standardize": false, "seed": 42, "nInit": 10, "maxIter": 300 } ``` Example response: ```json { "k": 3, "labels": [ 0, 0, "…" ], "centroids": [ [ 1.425, 1.475 ], [ 8.425, 8.5 ], "…" ], "inertia": 3.12, "silhouette": 0.888706231706, "kSelection": [ { "k": 2, "inertia": 100.7025, "silhouette": 0.628401182113 }, { "k": 3, "inertia": 3.12, "silhouette": 0.888706231706 }, "…" ], "rowsUsed": 12, "droppedRows": 0, "caps": { "maxRows": 50000, "maxColumns": 100 }, "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "Lloyd k-means with k-means++ seeding, nInit restarts, labels renumbered by first appearance.", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/dbscan-cluster $0.04 USDC. Density-based clustering with Euclidean or haversine distance, core/border/noise labelling, and an optional k-distance knee suggestion for eps. Inputs: columns, rows, eps, minSamples?, metric?, kDistance? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-dbscan-cluster Example request: ```json { "columns": [ "x", "y" ], "rows": [ [ 1, 1 ], [ 1.5, 2 ], [ 2, 1.5 ], [ 1.2, 1.4 ], [ 8, 8 ], [ 8.5, 9 ], [ 9, 8.2 ], [ 8.2, 8.8 ], [ 1, 9 ], [ 1.5, 8.5 ], [ 2, 9.2 ], [ 1.3, 8.8 ], [ 5, 5 ] ], "eps": 1.5, "minSamples": 3, "metric": "euclidean", "kDistance": false } ``` Example response: ```json { "labels": [ 0, 0, "…" ], "clusters": 3, "noise": 1, "corePoints": 12, "kDistance": null, "rowsUsed": 13, "droppedRows": 0, "caps": { "maxRows": 50000, "maxColumns": 100 }, "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "DBSCAN (Ester et al. 1996). Border points join the first core cluster reached in row order.", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/pca $0.03 USDC. Centre (and optionally standardise) columns, decompose the covariance, and return eigenvalues, explained ratios, signed loadings and optional scores. Inputs: columns, rows, standardize?, components?, returnScores? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-pca Example request: ```json { "columns": [ "x", "y" ], "rows": [ [ 2.5, 2.4 ], [ 0.5, 0.7 ], [ 2.2, 2.9 ], [ 1.9, 2.2 ], [ 3.1, 3 ], [ 2.3, 2.7 ], [ 2, 1.6 ], [ 1, 1.1 ], [ 1.5, 1.6 ], [ 1.1, 0.9 ] ], "standardize": false, "components": 2, "returnScores": true } ``` Example response: ```json { "eigenvalues": [ 1.28402771217, 0.0490833989383 ], "explainedRatio": [ 0.963181314349, 0.0368186856514 ], "loadings": [ [ 0.677873398528, 0.735178655544 ], [ 0.735178655544, -0.677873398528 ] ], "scores": [ [ 0.827970186201, 0.175115307047 ], [ -1.77758032528, -0.142857226544 ], "…" ], "rowsUsed": 10, "droppedRows": 0, "caps": { "maxRows": 50000, "maxColumns": 100 }, "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "PCA via spectral decomposition of the covariance (or correlation when standardize=true). Loadings flip so the largest-a…", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/decision-tree-train $0.03 USDC. Fit a classification or regression CART tree with depth and leaf limits, readable rules, feature importance and optional predictions. Inputs: task, columns, rows, target, maxDepth?, minSamplesLeaf?, predict? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-decision-tree-train Example request: ```json { "task": "classification", "columns": [ "age", "income" ], "rows": [ [ 25, 40 ], [ 35, 60 ], [ 45, 80 ], [ 20, 20 ], [ 50, 90 ], [ 23, 30 ], [ 40, 70 ], [ 60, 100 ], [ 30, 50 ], [ 55, 95 ] ], "target": [ 0, 0, 1, 0, 1, 0, 1, 1, 0, 1 ], "maxDepth": 2, "minSamplesLeaf": 1, "predict": [ [ 33, 66 ] ] } ``` Example response: ```json { "rules": [ "if income <= 65 then 0 (n=5, purity 1)", "if income > 65 then 1 (n=5, purity 1)" ], "tree": { "feature": "income", "threshold": 65, "left": { "value": 0 }, "right": { "value": 1 } }, "featureImportance": { "age": 0, "income": 1 }, "trainAccuracy": 1, "predictions": [ 1 ], "warnings": [], "rowsUsed": 10, "droppedRows": 0, "caps": { "maxRows": 50000, "maxColumns": 100 }, "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "CART with midpoint thresholds, Gini or MSE, ties broken by lower column index then lower threshold.", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/random-forest-importance $0.05 USDC. Train a small seeded random forest, report out-of-bag accuracy or R², and estimate permutation feature importance with Fisher-Yates shuffles. Inputs: task, columns, rows, target, trees?, maxFeatures?, maxDepth?, seed?, permutationRepeats?, minSamplesLeaf? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-random-forest-importance Example request: ```json { "task": "classification", "columns": [ "signal", "noise1", "noise2" ], "rows": [ [ 0, 0, 0 ], [ 0.025, 37, 53 ], [ 0.05, 74, 9 ], [ 0.075, 10, 62 ], [ 0.1, 47, 18 ], [ 0.125, 84, 71 ], [ 0.15, 20, 27 ], [ 0.175, 57, 80 ], [ 0.2, 94, 36 ], [ 0.225, 30, 89 ], [ 0.25, 67, 45 ], [ 0.275, 3, 1 ], [ 0.3, 40, 54 ], [ 0.325, 77, 10 ], [ 0.35, 13, 63 ], [ 0.375, 50, 19 ], [ 0.4, 87, 72 ], [ 0.425, 23, 28 ], [ 0.45, 60, 81 ], [ 0.475, 97, 37 ], [ 0.5, 33, 90 ], [ 0.525, 70, 46 ], [ 0.55, 6, 2 ], [ 0.575, 43, 55 ], [ 0.6, 80, 11 ], [ 0.625, 16, 64 ], [ 0.65, 53, 20 ], [ 0.675, 90, 73 ], [ 0.7, 26, 29 ], [ 0.725, 63, 82 ], [ 0.75, 100, 38 ], [ 0.775, 36, 91 ], [ 0.8, 73, 47 ], [ 0.825, 9, 3 ], [ 0.85, 46, 56 ], [ 0.875, 83, 12 ], [ 0.9, 19, 65 ], [ 0.925, 56, 21 ], [ 0.95, 93, 74 ], [ 0.975, 29, 30 ] ], "target": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], "trees": 40, "maxFeatures": "sqrt", "maxDepth": null, "seed": 42, "permutationRepeats": 2 } ``` Example response: ```json { "oobScore": 0.975, "importance": [ { "feature": "signal", "mean": 0.4125, "sd": 0.053033008589 }, { "feature": "noise1", "mean": 0, "sd": 0 }, "…" ], "seed": 42, "rowsUsed": 40, "droppedRows": 0, "caps": { "maxRows": 50000, "maxColumns": 100 }, "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "Random forest with mulberry32 bootstrap samples and Fisher-Yates permutation importance.", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/kaplan-meier-survival $0.04 USDC. Estimate group Kaplan-Meier curves with Greenwood log-log confidence intervals, median survival, survival at chosen times, and a multi-group log-rank test. Inputs: subjects, confidence?, at? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-kaplan-meier-survival Example request: ```json { "subjects": [ { "time": 6, "event": 1, "group": "6-MP" }, { "time": 1, "event": 1, "group": "placebo" }, { "time": 10, "event": 1, "group": "6-MP" }, { "time": 2, "event": 1, "group": "placebo" }, { "time": 22, "event": 1, "group": "6-MP" }, { "time": 8, "event": 1, "group": "placebo" } ], "confidence": 0.95, "at": [ 10, 22 ] } ``` Example response: ```json { "groups": [ { "group": "6-MP", "median": 23, "survivalAt": [ { "t": 10, "S": 0.752941176471 }, { "t": 13, "S": 0.690196078431 }, "…" ], "curve": [ { "t": 6, "atRisk": 21, "events": 3, "S": 0.857142857143, "ciLow": 0.619717955266, "ciHigh": 0.951551747647 }, { "t": 7, "atRisk": 17, "events": 1, "S": 0.806722689076, "ciLow": 0.563146564622, "ciHigh": 0.922809019203 }, "…" ] }, { "group": "placebo", "median": 8, "survivalAt": [ { "t": 10, "S": 0.380952380952 }, { "t": 13, "S": 0.190476190476 }, "…" ], "curve": [ { "t": 1, "atRisk": 21, "events": 2, "S": 0.904761904762, "ciLow": 0.670045882235, "ciHigh": 0.975294149038 }, { "t": 2, "atRisk": 19, "events": 2, "S": 0.809523809524, "ciLow": 0.568905059924, "ciHigh": 0.923888828559 }, "…" ] } ], "logRank": { "chiSquare": 16.7929409892, "df": 1, "p": 0.0000416880910933 }, "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "Kaplan-Meier with Greenwood variance and log-log confidence intervals; log-rank uses hypergeometric variance.", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/cox-regression $0.05 USDC. Maximise the Cox partial likelihood with Efron or Breslow ties, return hazard ratios with SEs, concordance, and a rank-time proportional-hazards check. Inputs: subjects, ties?, confidence? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-cox-regression Example request: ```json { "subjects": [ { "time": 6, "event": 1, "covariates": { "placebo": 0 } }, { "time": 1, "event": 1, "covariates": { "placebo": 1 } }, { "time": 10, "event": 1, "covariates": { "placebo": 0 } }, { "time": 2, "event": 1, "covariates": { "placebo": 1 } }, { "time": 22, "event": 1, "covariates": { "placebo": 0 } }, { "time": 8, "event": 1, "covariates": { "placebo": 1 } } ], "ties": "efron", "confidence": 0.95 } ``` Example response: ```json { "coefficients": [ { "name": "placebo", "beta": 1.57212515142, "se": 0.412327391981, "hazardRatio": 4.81687391074, "z": 3.81280793368, "p": 0.000137396883573 } ], "logLikelihood": -85.0084245774, "concordance": 0.689801699717, "phTest": [ { "name": "placebo", "chiSquare": 0.0823226487592, "p": 0.774174160233, "timeTransform": "rank" } ], "converged": true, "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "Cox partial likelihood (Efron or Breslow ties) with Newton-Raphson; Grambsch-Therneau PH check vs rank of time.", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/cohort-retention $0.03 USDC. Build day/week/month cohort retention in classic or rolling mode from signup and activity dates, with partial-period flags and a size-weighted curve. Inputs: events, period?, mode?, asOf, timezone? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-cohort-retention Example request: ```json { "events": [ { "userId": "u1", "signup": "2026-01-05", "activity": [ "2026-01-05", "2026-02-10", "2026-03-02" ] }, { "userId": "u2", "signup": "2026-01-20", "activity": [ "2026-01-20", "2026-03-15" ] }, { "userId": "u3", "signup": "2026-01-28", "activity": [ "2026-01-28" ] }, { "userId": "u4", "signup": "2026-02-03", "activity": [ "2026-02-03", "2026-03-04" ] }, { "userId": "u5", "signup": "2026-02-14", "activity": [ "2026-02-14" ] } ], "period": "month", "mode": "classic", "asOf": "2026-03-31", "timezone": "UTC" } ``` Example response: ```json { "cohorts": [ { "cohort": "2026-01", "size": 3, "retention": [ 1, 0.333333333333, "…" ], "partial": true }, { "cohort": "2026-02", "size": 2, "retention": [ 1, 0.5 ], "partial": true } ], "weightedCurve": [ 1, 0.4, "…" ], "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "Cohort retention by signup period; classic counts activity in period k, rolling counts activity in period k or later.", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/rfm-segment $0.03 USDC. Score customers 1–bins on recency, frequency and monetary value with average ranks for ties, then map scores to Champions/Loyal/New/At risk/Hibernating or a custom rule list. Inputs: customers?, transactions?, asOf?, bins?, segmentMap? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-rfm-segment Example request: ```json { "customers": [ { "id": "c1", "recencyDays": 5, "frequency": 12, "monetary": 1200 }, { "id": "c2", "recencyDays": 40, "frequency": 3, "monetary": 150 }, { "id": "c3", "recencyDays": 200, "frequency": 1, "monetary": 40 } ], "bins": 5, "segmentMap": "default" } ``` Example response: ```json { "customers": [ { "id": "c1", "r": 5, "f": 5, "m": 5, "rfm": "555", "segment": "Champions" }, { "id": "c2", "r": 3, "f": 3, "m": 3, "rfm": "333", "segment": "Needs attention" }, "…" ], "segments": [ { "name": "Champions", "count": 4 }, { "name": "Needs attention", "count": 2 }, "…" ], "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "RFM scores use average ranks for ties; default segment map evaluates Champions, Loyal, New, At risk, Hibernating, then …", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/clv-bg-nbd $0.05 USDC. Fit BG/NBD purchase frequency and Gamma-Gamma spend models, then return P(alive), expected purchases over a horizon, expected value and undiscounted CLV per customer. Inputs: customers, horizon?, margin?, minRepeatCustomers? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-clv-bg-nbd Example request: ```json { "customers": [ { "id": "c0", "frequency": 0, "recency": 0, "T": 39 }, { "id": "c1", "frequency": 1, "recency": 3, "T": 39, "monetaryValue": 150 }, { "id": "c2", "frequency": 2, "recency": 10, "T": 39, "monetaryValue": 35 }, { "id": "c3", "frequency": 5, "recency": 38, "T": 39, "monetaryValue": 90 }, { "id": "c4", "frequency": 0, "recency": 0, "T": 39 }, { "id": "c5", "frequency": 3, "recency": 8, "T": 39, "monetaryValue": 200 }, { "id": "c6", "frequency": 1, "recency": 30, "T": 39, "monetaryValue": 45 }, { "id": "c7", "frequency": 4, "recency": 35, "T": 39, "monetaryValue": 60 }, { "id": "c8", "frequency": 0, "recency": 0, "T": 39 }, { "id": "c9", "frequency": 2, "recency": 5, "T": 39, "monetaryValue": 25 }, { "id": "c10", "frequency": 6, "recency": 37, "T": 39, "monetaryValue": 80 }, { "id": "c11", "frequency": 1, "recency": 2, "T": 39, "monetaryValue": 10 }, { "id": "c12", "frequency": 3, "recency": 12, "T": 39, "monetaryValue": 20 }, { "id": "c13", "frequency": 0, "recency": 0, "T": 39 }, { "id": "c14", "frequency": 7, "recency": 36, "T": 39, "monetaryValue": 35 }, { "id": "c15", "frequency": 2, "recency": 33, "T": 39, "monetaryValue": 90 }, { "id": "c16", "frequency": 1, "recency": 15, "T": 39, "monetaryValue": 15 }, { "id": "c17", "frequency": 4, "recency": 9, "T": 39, "monetaryValue": 200 }, { "id": "c18", "frequency": 0, "recency": 0, "T": 39 }, { "id": "c19", "frequency": 5, "recency": 20, "T": 39, "monetaryValue": 60 }, { "id": "c20", "frequency": 2, "recency": 4, "T": 39, "monetaryValue": 300 }, { "id": "c21", "frequency": 8, "recency": 38, "T": 39, "monetaryValue": 25 }, { "id": "c22", "frequency": 1, "recency": 1, "T": 39, "monetaryValue": 80 }, { "id": "c23", "frequency": 3, "recency": 30, "T": 39, "monetaryValue": 10 } ], "horizon": 10, "margin": 1, "minRepeatCustomers": 10 } ``` Example response: ```json { "bgnbd": { "r": 0.966530837691, "alpha": 6.89967524885, "a": 5.18424760567, "b": 20.7911737255, "logLikelihood": -214.342637155 }, "gammaGamma": { "p": 1.41882138979, "q": 2.19572029236, "v": 75.0459385155 }, "customers": [ { "id": "c0", "pAlive": 1, "expectedPurchases": 0.201992995256, "expectedValue": null, "clv": null }, { "id": "c1", "pAlive": 0.164150056375, "expectedPurchases": 0.0662215810115, "expectedValue": 122.124651303, "clv": 8.08728748979 }, "…" ], "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "BG/NBD (Fader, Hardie & Lee 2005) and Gamma-Gamma (Fader & Hardie 2013); CLV is undiscounted expectedPurchases × expect…", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/market-basket-rules $0.04 USDC. Mine frequent itemsets and association rules with support, confidence, lift, leverage and conviction from caller baskets. Inputs: baskets, minSupport?, minConfidence?, maxItemsetSize?, maxRules? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-market-basket-rules Example request: ```json { "baskets": [ [ "bread", "milk" ], [ "bread", "diapers", "beer", "eggs" ], [ "milk", "diapers", "beer", "cola" ], [ "bread", "milk", "diapers", "beer" ], [ "bread", "milk", "diapers", "cola" ] ], "minSupport": 0.4, "minConfidence": 0.6, "maxItemsetSize": 3, "maxRules": 1000 } ``` Example response: ```json { "rules": [ { "antecedent": [ "cola" ], "consequent": [ "diapers", "milk" ], "support": 0.4, "confidence": 1, "lift": 1.66666666667, "leverage": 0.16, "conviction": null }, { "antecedent": [ "diapers", "milk" ], "consequent": [ "cola" ], "support": 0.4, "confidence": 0.666666666667, "lift": 1.66666666667, "leverage": 0.16, "conviction": 1.8 }, "…" ], "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "Frequent itemsets by level-wise search (Apriori-style) with association rules sorted by lift, confidence, then support.", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/changepoint-detect $0.03 USDC. Detect mean or mean-variance changepoints with PELT, BIC/AIC or custom penalties, and MAD-based noise scaling. Inputs: values, model?, penalty?, minSegment? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-changepoint-detect Example request: ```json { "values": [ 1, 1.2, 0.9, 1.1, 1, 0.8, 1.1, 5, 5.2, 4.9, 5.1, 5, 4.8, 5.1, 5.2, 1, 0.9, 1.1, 1, 1.2 ], "model": "mean", "penalty": "bic", "minSegment": 2 } ``` Example response: ```json { "changepoints": [ 7, 15 ], "segments": [ { "start": 0, "end": 7, "mean": 1.01428571429 }, { "start": 7, "end": 15, "mean": 5.0375 }, "…" ], "sigma": 0.209671302757, "penaltyValue": 5.99146454711, "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "PELT changepoint detection (Killick et al. 2012) on mean or mean-variance cost with MAD-based σ.", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/classification-metrics $0.02 USDC. Compute ROC-AUC, average precision, Brier score, confusion at a threshold, Youden-optimal threshold and equal-width calibration bins from binary labels and scores. Inputs: labels, scores, threshold?, calibrationBins? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-classification-metrics Example request: ```json { "labels": [ 0, 0, 1, 1, 0, 1, 0, 1, 1, 0 ], "scores": [ 0.1, 0.4, 0.35, 0.8, 0.2, 0.9, 0.6, 0.7, 0.55, 0.3 ], "threshold": 0.5, "calibrationBins": 5 } ``` Example response: ```json { "rocAuc": 0.88, "prAuc": 0.902857142857, "brier": 0.1425, "confusion": { "threshold": 0.5, "tp": 4, "fp": 1, "fn": 1, "tn": 4, "precision": 0.8, "recall": 0.8, "f1": 0.8 }, "youdenThreshold": 0.55, "youdenJ": 0.6, "calibration": [ { "bin": [ 0, 0.2 ], "meanScore": 0.1, "fraction": 0, "n": 1 }, { "bin": [ 0.2, 0.4 ], "meanScore": 0.283333333333, "fraction": 0.333333333333, "n": 3 }, "…" ], "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "ROC-AUC is the Mann-Whitney statistic; PR-AUC is average precision; Youden maximises TPR − FPR over unique scores.", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/correlation-analysis $0.03 USDC. Pairwise Pearson/Spearman/Kendall correlations with p-values, optional partial correlations, and Holm/BH/Bonferroni adjustment across pair-method tests. Inputs: columns, rows, methods?, partial?, adjust? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-correlation-analysis Example request: ```json { "columns": [ "x", "y", "z" ], "rows": [ [ 1, 2, 1 ], [ 2, 1, 1 ], [ 3, 4, 2 ], [ 4, 3, 2 ], [ 5, 7, 3 ], [ 6, 8, 3 ], [ 7, 6, 4 ], [ 8, 9, 4 ], [ 9, 10, 5 ], [ 10, 12, 5 ] ], "methods": [ "pearson", "spearman", "kendall" ], "partial": [ { "x": "x", "y": "y", "given": [ "z" ] } ], "adjust": "holm" } ``` Example response: ```json { "pairs": [ { "a": "x", "b": "y", "n": 10, "pearson": { "r": 0.946314052952, "p": 0.0000340536228548, "pAdjusted": 0.000238375359983 }, "spearman": { "rho": 0.939393939394, "p": 0.0000548405299851, "pAdjusted": 0.000305281580213 }, "kendall": { "tau": 0.822222222222, "p": 0.000357694003527, "pAdjusted": 0.0010398580534 } }, { "a": "x", "b": "z", "n": 10, "pearson": { "r": 0.984731927835, "p": 2.33418632079e-7, "pAdjusted": 0.00000210076768871 }, "spearman": { "rho": 0.984731927835, "p": 2.33418632079e-7, "pAdjusted": 0.00000210076768871 }, "kendall": { "tau": 0.942809041582, "p": 0.000346619351135, "pAdjusted": 0.0010398580534 } }, "…" ], "partial": [ { "x": "x", "y": "y", "given": [ "z" ], "r": 0.340502612303, "p": 0.369906747904, "df": 7 } ], "rowsUsed": 10, "caps": { "maxRows": 50000, "maxColumns": 100 }, "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "Pairwise deletion; Holm/BH/Bonferroni adjust across all pair-method p-values when requested.", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ``` ### POST /api/v1/predictive-analytics/propensity-score-match $0.04 USDC. Fit logistic propensity scores, match treated to controls 1:1 on the logit within a caliper, and report SMD balance and common-support counts. Inputs: units, caliperSdLogit?, replacement?, order?, seed? Docs: https://www.brainiac.software/api/predictive-analytics/docs#predictive-analytics-propensity-score-match Example request: ```json { "units": [ { "id": "1", "treated": 0, "covariates": { "age": 25 } }, { "id": "2", "treated": 0, "covariates": { "age": 30 } }, { "id": "3", "treated": 0, "covariates": { "age": 35 } }, { "id": "4", "treated": 0, "covariates": { "age": 40 } }, { "id": "5", "treated": 0, "covariates": { "age": 45 } }, { "id": "6", "treated": 0, "covariates": { "age": 50 } }, { "id": "7", "treated": 0, "covariates": { "age": 55 } }, { "id": "8", "treated": 0, "covariates": { "age": 60 } }, { "id": "9", "treated": 1, "covariates": { "age": 28 } }, { "id": "10", "treated": 1, "covariates": { "age": 33 } }, { "id": "11", "treated": 1, "covariates": { "age": 38 } }, { "id": "12", "treated": 1, "covariates": { "age": 43 } }, { "id": "13", "treated": 1, "covariates": { "age": 48 } }, { "id": "14", "treated": 1, "covariates": { "age": 53 } }, { "id": "15", "treated": 1, "covariates": { "age": 58 } }, { "id": "16", "treated": 1, "covariates": { "age": 63 } } ], "caliperSdLogit": 0.2, "replacement": false, "order": "descending_score" } ``` Example response: ```json { "model": { "intercept": -0.998940067346, "coefficients": { "age": 0.0227031833488 } }, "caliper": 0.054184085363, "pairs": [ { "treated": "15", "control": "8", "distance": 0.0454063666975 }, { "treated": "14", "control": "7", "distance": 0.0454063666975 }, "…" ], "unmatchedTreated": [ "16" ], "balance": [ { "covariate": "age", "smdBefore": 0.244948974278, "smdAfter": -0.185164019955 } ], "commonSupport": { "treatedOutside": 1, "controlOutside": 1 }, "sources": [ { "source": "Caller-supplied tabular data processed locally", "url": "https://www.brainiac.software/api/v1/predictive-analytics", "retrievedAt": "2026-11-14", "status": "ok" } ], "limitations": [ "Propensity scores from logistic regression; 1:1 greedy matching on the logit with a caliper of caliperSdLogit × sd(logi…", "Outputs are statistical calculations on caller-supplied inputs for human review. They are not legal, medical, credit, t…", "…" ] } ```