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 🙏

© 2024 – Pkg Stats / Ryan Hefner

mkdata

v0.0.11

Published

Make synthetic datasets

Downloads

14

Readme

Generate synthetic datasets for machine learning

Open-source data generator working in terminal and as a JavaScript module

Using synthetic datasets is the easiest and the most robust way to test machine learning models and statistical methods. Instead of relying on real-world data with not fully known dependencies between variables, artificial data has clear rules under the hood. Another benefit is there's almost no size limit. We can generate as many observations as we need for our purposes.

With mkdata, you can generate new data based on nine well-known problems (e.g. Friedman datasets). You can use it as a JavaScript module producing 2D arrays ready for model training. Or create CSV files calling mkdata as a CLI app without writing code at all.

Install mkdata

  • npm i mkdata -S or
  • npm i mkdata -g or run using npx without installation
  • npx mkdata -d moons -s 1000 -o friedman1.csv

CLI

mkdata -d friedman1 -s 1000 -o friedman1.csv

or using stdout

mkdata -d friedman1 -s 1000 > friedman1.csv

Params:

  • -d, --dataset - dataset name
  • -f, --nFeatures - number of features
  • -s, --nSamples - number of samples
  • -n, --noise - noise size
  • -o, --output - output file name
  • -r, --randomState - seed

API

const make = require('mkdata')
const [X, y] = make.spirals({ nSamples: 1000 })

friedman1, friedman2, friedman3 methods also return data generating functions:

const [X, y, f] = make.friedman3({ nSamples: 1000 })
const yt = X.map(f)

Synthetic datasets

  • Friedman 1 (y = 10 * sin(Pi * x1 * x2) + 20 * (x3 - 0.5) ** 2 + 10 * x4 + 5 * x5 + e)
  • Friedman 2 (y = sqrt(x1 ** 2 + (x2 * x3 - 1 / (x2 * x4)) ** 2) + e)
  • Friedman 3 (y = atan(x2 * x3 - 1 / (x2 * x4) / x1) + e)
  • Hastie (binary classification problem used in Hastie et al 2009)
  • Moons (two interleaving half circles)
  • Peak (peak benchmark problem)
  • Ringnorm (from Breiman 1996)
  • Spirals (two entangled spirals)
  • Swissroll (from S. Marsland 2009)

Web demo

Generate same synthetic datasets without installing mkdata here: https://statsim.com/gen/ (CSV format)