npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lp-labs/forecast-evaluator

v0.1.0

Published

Bounded deterministic forecast-evaluator utilities with explicit validation and zero runtime dependencies.

Readme

@lp-labs/forecast-evaluator

Ordered time splits, training-only naive baselines, paired error metrics, and explicit feature-timing leakage diagnosis. Original independent implementation, zero runtime/peer dependencies, Node >=18, version 0.1.0. Evaluation is not predictive certainty.

npm install @lp-labs/forecast-evaluator

Runnable example

import {
  splitTimeSeries,
  evaluateBaseline,
  evaluateForecast,
  diagnoseLeakage,
} from '@lp-labs/forecast-evaluator';

const split = splitTimeSeries(
  [
    { time: 1, value: 2 },
    { time: 2, value: 4 },
    { time: 3, value: 5 },
  ],
  2,
);
const baseline = evaluateBaseline(split, 'last');
const metrics = evaluateForecast([5], baseline.predictions);
const leakage = diagnoseLeakage([{ name: 'price', sourceTime: 2, availableAt: 3 }], 2);
if (metrics.mae !== 1 || leakage[0].reason !== 'late-availability')
  throw new Error('Unexpected evaluation');
console.log(baseline, leakage);

CommonJS supports the same runtime functions through require('@lp-labs/forecast-evaluator'). ESM and CommonJS include matching declarations.

API and types

  • TimePoint: { time: number; value: number }, both finite. Time units/epochs and value units are caller-defined, consistent numeric scales.
  • splitTimeSeries(input: Iterable<TimePoint>, trainCount, maxPoints = 100000): TimeSplit. Requires strictly increasing times, rejecting ties/reversals rather than silently sorting. trainCount is an integer strictly between zero and total length. TimeSplit contains isolated train and test arrays; neither partition is empty.
  • evaluateForecast(actual, predicted, maxPoints = 100000): ForecastMetrics. Equal nonempty finite numeric arrays, positionally paired; no implicit alignment. ForecastMetrics: count, mae (mean absolute error), rmse (root mean squared error), bias (mean predicted minus actual), mape (mean absolute percentage error multiplied by 100), percentageCount. Zero actuals are excluded from MAPE; mape is null if every actual is zero. Negative actuals use absolute denominators.
  • evaluateBaseline(split: TimeSplit, kind: 'last' | 'mean' = 'last', maxPoints = 100000): BaselineReport. Revalidates strict ordering across the training/test boundary. Predicts every test value using the last training value or training arithmetic mean only. BaselineReport contains predictions: number[] and metrics: ForecastMetrics. Test outcomes do not influence predictions; there is no fitted model or refitting.
  • FeatureTiming: { name: string; sourceTime: number; availableAt: number }.
  • diagnoseLeakage(features: Iterable<FeatureTiming>, forecastOrigin, maxFeatures = 10000): LeakageIssue[]. For each unique feature emits future-source if sourceTime > origin and late-availability if availableAt > origin, in input order, source first. Both issues can occur. Equality is permitted. LeakageIssue has name and reason. Metadata is supplied by you; the function does not inspect datasets, features, target joins, preprocessing, overlap windows, or causal relationships.

All listed interfaces are exported as types; the four functions are runtime exports.

Errors, customization and limits

TypeError: nonfinite/nonnumeric values, nonarray metric or partition inputs, unknown baseline kinds, or duplicate/empty/over-128-unit feature names. RangeError: invalid split, nonincreasing timestamps, unmatched/empty metric arrays, capacity exhaustion, invalid limits, or intermediate/final arithmetic overflow. All limits are positive safe integers <=100,000; iterables stop at limit + 1 consumed items. Arithmetic is IEEE-754; squared error overflow is rejected even if a differently scaled implementation could represent the final RMSE.

Functions have no retained state or external mutation; errors return no partial report. External iterable/getter exceptions propagate. Inputs should be plain trusted data and may not be concurrently mutated during evaluation. O(N) time/storage for splits/baselines/diagnosis; paired metrics use O(N) time and O(1) working storage. Feature diagnosis produces at most two issues per feature.

Customize count-based holdout sizes, baseline kind, limits, timing origins, and units. Use multiple ordered holdouts yourself for rolling evaluation. MAPE is unstable near zero; baseline performance does not imply generalization, calibrated uncertainty, statistical significance, causal inference, or future success.

Related design context: virtual-time's ordered time, performance-budgets' honest metrics, incremental-aggregation's bounded numeric checks, unit-system's explicit units. No imports or dependencies on those packages.

Development

npm run build, npm run typecheck, npm test, npm run format, npm run format:check. Dev-only TypeScript ^5.9.3, Prettier ^3.6.2; strict ESM/CommonJS declaration builds. Tests include seeded arithmetic oracles, time-boundary leakage races, baseline independence from test outcomes, overflow and generator bounds.

Support

If this library is useful to you, consider supporting its maintenance with a donation via PayPal.

Author

Created by Libin Prasanth. Connect on LinkedIn for updates and discussion.