mtralka / GeoBuckets

Lightweight TypeScript library for data classification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🌎πŸͺ£ GeoBuckets

Lightweight Javascript (TypeScript, really) library for classification. Dependency free, tested, and type safe.

Features

  • πŸ”₯ supports 6 classification types
  • βš–οΈ: Small!
    • πŸš€ 4.4kb minifed, 1.7kb gzipped
    • 0️⃣ zero dependencies
    • 🌲 tree-shakeable
  • πŸ§ͺ fully tested
  • 🏷️ fully typed
  • πŸͺ¨ asynchronous and non-blocking

Supports

  • Equal Intervals (EQI)
    • equalIntervalBuckets
  • Standard Deviation (STD)
    • standardDeviationBuckets
  • Arithmetic Progression (APG)
    • arithmeticProgressionBuckets
  • Geometric Progression (GPG)
    • geometricProgressionBuckets
  • Quantiles (QNT)
    • quantileBuckets
  • Jenks (JNK)
    • jenksBuckets

Install

Install through NPM


npm install geobuckets

Usage

All outward facing functions are async and must be called with await XXX

Explicit import:

import { jenksBuckets } from "geobuckets";

const data: Array<number> = [60, 26, 20, 17, 10, 27, 98, 42, 55, 35];
const numClasses: number = 3;

const buckets: Array<number> = await jenksBuckets(data, numClasses);

console.log(buckets) >> [10, 35, 60, 98];

Helper function and type

import { generateBuckets, BucketTypes } from "geobuckets";

const data: Array<number> = [60, 26, 20, 17, 10, 27, 98, 42, 55, 35];
const numClasses: number = 3;

const buckets: Array<number> = await generateBuckets(
  BucketTypes.JNK,
  data,
  numClasses
);

console.log(buckets) >> [10, 35, 60, 98];

A modern implementation of the GeoStats library by Simon Georget (MIT license)

About

Lightweight TypeScript library for data classification

License:MIT License


Languages

Language:TypeScript 99.4%Language:JavaScript 0.6%