Skip to main content

bitskitten

A small toolbox of things I kept re-typing in every EDA notebook: quick dataset reports, a few plots, and sklearn-compatible encoders that can be dropped straight into a Pipeline / GridSearchCV.

Nothing here is a framework. Each helper is one function or one class you can read in a minute.

Install

pip install bitskitten

The latest commit: pip install git+https://github.com/Caerno/bitskit.git. On Kaggle / Colab the same lines work in a cell (!pip install ...). For a kernel with no internet, add the archive GitHub builds for every commit as a dataset and install it from disk:

pip install --no-deps /kaggle/input/<your-dataset>/bitskit-main.zip

Requires Python ≥ 3.9, numpy, pandas, scikit-learn, matplotlib, seaborn.

Quick start

import pandas as pd
from bitskitten import informer, informer_print, imperfection, NanFixer, Digitalize

df = pd.concat([train, test])          # test rows have no target -> NaN

informer_print(informer(df, "Survived"))
#   Features:       12
#   Observations:   891/418
#   train dataset:  68.0%
#   classes:        0: 61.6%, 1: 38.4%

imperfection(df)                       # what is missing and how varied it is

imperfection returns a frame sorted by NA share — share of missing values, number of unique values, dtype and the values themselves. By default it shows non-numeric columns only; numeric=True adds the rest, no_nan=True keeps only columns that actually have gaps.

Encoders

Both are BaseEstimator + TransformerMixin, so fit/transform/fit_transform, get_params, clone and grid search over their parameters all work.

from sklearn.pipeline import Pipeline
from sklearn.model_selection import GridSearchCV
from sklearn.ensemble import RandomForestClassifier

pipe = Pipeline([
    ("nan", NanFixer()),               # fill the gaps
    ("dig", Digitalize()),             # make everything numeric
    ("clf", RandomForestClassifier()),
])

grid = GridSearchCV(pipe, {
    "nan__lim":    [0.1, 0.225, 0.5],
    "nan__method": ["mean", "median"],
    "dig__mode":   ["raw", "cut", "qcut"],
    "dig__ncut":   [5, 10],
})

NanFixer(lim=0.225, method="mean", filler="U") — picks a filling strategy per column at fit time and applies it at transform time:

column condition strategy
numeric NA share ≤ lim method (mean/median)
numeric NA share > lim random draw from the column's own normal distribution, clipped to its range
object one value dominates (>25%) mode
object otherwise the filler string

Columns of any other dtype pass through untouched.

Digitalize(alim=10, mode="raw", ncut=5) — turns a mixed frame into a numeric one:

column condition result
numeric < 3 unique values as is
any < alim unique values one-hot (pd.get_dummies)
numeric mode="cut" / "qcut" binned into ncut equal-spaced / equal-sized bins
numeric mode="raw" as is
non-numeric ≥ alim unique values top-ncut frequency rating (most frequent → 1, the tail → ncut)

FeatureTrans(series) is the shared kit both encoders are built from, and it is iterable: it yields every transformation that makes sense for that column's dtype — handy when you want to throw candidate features at a selector.

candidates = pd.concat(list(FeatureTrans(df["Fare"])), axis=1)
# Fare_count, Fare_freqn, Fare_top5..., Fare_cut5..., Fare_qcut5..., Fare_sqrt, Fare_log2, Fare_pow2 ...

Its pieces are static methods you can also call directly: count, freq, top, cut, qcut, math, bilabel, fuzzy_mean, robust, fill.

Plots

from bitskitten import plot_conf_map, plot_some_scatters

hm, precision, recall = plot_conf_map(confusion_matrix(y_true, y_pred), title="RF")

plot_conf_map draws the confusion matrix as shares, with a precision row, a recall column and — in the corner — the harmonic mean of all of them. That last number is the point of it: a class-agnostic generalization of F1 for when no class is "the positive one". Returns (harmonic_mean, precision, recall); blind=True computes without drawing, which is what you want inside a scoring loop.

plot_some_scatters(X, y) — pairwise scatter plots of every column combination, coloured by y.

multicolumn(series, cols=5) folds a long series into several columns so a wide df.sample().T fits on one screen.

Image compression demo

img_squeeze reduces the dimensionality of an RGBA image by unrolling channels into a flat 2D matrix, running any sklearn decomposition on it and rebuilding the picture:

from sklearn.decomposition import PCA
from bitskitten import img_framaker

img_framaker(img, 20, PCA)   # image restored from 20 components

Estimator from scratch

SlowPolyLinearReg(gener=[0, 1], norm=None, alpha=None) — linear regression written on numpy/pandas, with polynomial and non-linear feature generation (0 = intercept, integers = powers, "sqrt"/"cbrt"/"log2"/"ln"/"log10"), optional normalization ("minmax", "std", "max", "mean") and L2 regularization. Closed-form solution, so it warns you about singular and ill-conditioned matrices instead of hiding them (and falls back to the least-norm solution rather than giving up). It exists to show the mechanics, not to compete with sklearn.linear_model.

The default gener=[0, 1] is the plain intercept + x. Drop the 0 only if you really want the line forced through the origin.

model = SlowPolyLinearReg(gener=[0, 1, 2], norm="std", alpha=0.01)
model.fit(X, y)
model.score(X, y)   # R²

Input

number("How many? ", t=int, op=">=", limit=0) — keeps asking until the answer parses and satisfies the condition.

Development

pip install -e .[test]
pytest

The drop-in zip in download/ is a plain stdlib call, no notebook needed:

python -m zipfile -c download/bitskitten.zip __init__.py classes.py input.py output.py

Metadata

Release files for bitskitten 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bitskitten 0.2.1
File Size Uploaded Provenance
bitskitten-0.2.1.tar.gz 20.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bitskitten 0.2.1
File Interpreter ABI Platform
bitskitten-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.2 kB

Release files / bitskitten-0.2.1.tar.gz

Download URL bitskitten-0.2.1.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
10c557bb0054501ca628f9404448aba82feaffab9d8316365c02237fc8a03bea
BLAKE2b-256 checksum
How to use checksums
6c1e493d18c19c05fe3cc95fa5de90de3b18d99629a312feaf80996e5d402ae4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / bitskitten-0.2.1-py3-none-any.whl

Download URL bitskitten-0.2.1-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c2747d7d5c1fb603afeea12f5ddebdb7ed64cd681a4947f5a49b038bd4ca38d
BLAKE2b-256 checksum
How to use checksums
d3e8910ad58fb6a3463b144534c7b499993fca5ef28a8fa0368a56e270c5e9d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Security for bitskitten 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bitskitten-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page