Skip to main content

A spooky vector analysis library

Project description

Sp00kyVectors: Vector Analysis Wrapper for Python

Welcome to Sp00kyVectors, the software powering your Tricorder. 🛸

These eerily intuitive Python modules work seamlessly as one toolkit for:

  • 🧲 Data ingestion
  • 🧼 Cleaning
  • 🧮 Vector analysis
  • 📊 Statistical computation
  • 🧠 Bespoke neural net creation
  • 🌌 Visualizations 🪄👻

Perfect for any away missions 🖖

100% open-source and always summoning new engineers to help!

🧼 Analysis Examples

on-the-go data manipulation across space, time, and spreadsheets:

Before After
Before Cleaning After Cleaning
Before Bin After Bin
Vector Projections Normalize

🧹 Dirty Data

Load without worry

Easily load and align mismatched CSV files-hello IoT. This utility intelligently collects, normalizes, and organizes messy datasets — so you can focus on the analysis, not the cleanup. 🚀

Vector.load_folder(path) loads a folder of CSV files with potentially mismatched or missing columns,
aligns all columns based on their headers, and combines them into a single clean DataFrame.
Missing columns in any file are automatically filled with NaN values to maintain consistency.

Perfect for messy datasets where CSVs don't share the exact same structure!

Cleaning is done one layer up with sp00kyDF.get_clean_df() ✨🧹

This method returns a cleaned version of the DataFrame by performing the following steps:

  1. 🧩 Removes duplicate rows (performed twice to ensure thorough cleaning)
  2. 🚫📊 Clips outlier values based on the Z-score method (an Interquartile Range (IQR) method is also available)
  3. 🏷️ Standardizes column names for consistency
  4. ❌🕳️ (Optionally drops null values — currently commented out)

Finally, it returns the cleaned DataFrame ready for analysis. 🎯

🎛️⚙️✨ Granular Control

🧠 Features

  • 🧮 Vector Magic:

    • Load 1D or 2D arrays into Vector objects
    • X/Y decomposition for 2D data
    • Linear algebra methods like magnitude, angle, dot, and projection
  • 📊 Statistical Potions:

    • Mean, median, standard deviation 💀
    • Probability vectors and PDFs 🧪
    • Z-score normalization 🧼
    • Entropy between aligned vectors 🌀
    • Internal entropy of a vector
  • 🖼️ Visualizations:

    • Linear and log-scale histogramming
    • Vector plots with tails, heads, and haunted trails
    • Optional "entropy mode" that colors plots based on mysterious disorder 👀
  • 🔧 Tools of the Craft:

    • Gaussian kernel smoothing for smoothing out your nightmares
    • Elementwise operations: .normalize(), .project(), .difference(), and more
    • Pretty __repr__ so your print statements conjure elegant summaries

🧪 Example


from sp00kyvectors import Vector

v = Vector([1, 2, 3, 4, 5])
print(v.mean())  # Output: 3.0

v2 = Vector([1, 1, 1, 1, 6])
print(v.entropy(v2))  # Output: spooky entropy value

📦 Installation


pip install sp00kyvectors

Or summon it from your own local clone:


git clone https://github.com/LilaShiba/sp00kyvectors.git
cd sp00kyvectors
pip install .

📚 Documentation

🧪 Class: Vector

✨ Initialization

Create a new Vector from a list or numpy array.


from sp00kyvectors import Vector

v = Vector([1, 2, 3, 4, 5])

If you're working with 2D data:


v2d = Vector([[1, 2], [3, 4], [5, 6]])

📊 Methods

.mean()

Returns the mean of the vector.


v.mean()  # ➜ 3.0

.median()

Returns the median.


v.median()  # ➜ 3

.std()

Returns the standard deviation.


v.std()  # ➜ 1.5811...

.normalize()

Normalizes the vector using Z-score (zero mean, unit variance).


v_norm = v.normalize()

.entropy(other: Vector)

Computes Shannon entropy between this vector and another.


v2 = Vector([1, 1, 1, 1, 6])
v.entropy(v2)  # ➜ ~0.72 (varies based on normalization)

.difference(other: Vector)

Returns a new Vector representing the difference between this vector and another.


v3 = v.difference(v2)

.project(dim: int)

Projects a 2D vector onto a specific dimension (0 = x, 1 = y).


vx = v2d.project(0)
vy = v2d.project(1)

🔢 Linear Algebra Methods

.magnitude()

Returns the magnitude (length) of the vector.


v.magnitude()  # ➜ 7.416

.angle(other: Vector)

Returns the angle between this vector and another, in radians.


v.angle(v2)  # ➜ 0.225 (radians)

.dot(other: Vector)

Computes the dot product of this vector and another.


v.dot(v2)  # ➜ 24

.cross(other: Vector)

Computes the cross product (only for 3D vectors).


v3d = Vector([1, 2, 3])
v3d2 = Vector([4, 5, 6])
v3d.cross(v3d2)  # ➜ [-3, 6, -3]

.projection(other: Vector)

Returns the projection of this vector onto another.


v.projection(v2)  # ➜ Vector with projected values

📈 Plotting

.histogram(log=False)

Plots a histogram of the vector values. Set log=True for logarithmic scale.


v.histogram()
v.histogram(log=True)

.plot_vectors(mode="line", entropy=False)

Plots 2D vectors.

  • mode: "line", "arrow", or "trail"
  • entropy: if True, colorizes vectors by entropy

v2d.plot_vectors(mode="arrow", entropy=True)

🔮 Utilities

.gaussian_smooth(sigma=1.0)

Applies Gaussian smoothing to the vector.


v_smooth = v.gaussian_smooth(sigma=2.0)

💀 Dunder Methods

__repr__()

Pretty string representation.


print(v)  # Vector(mean=3.0, std=1.58, ...)

🛠 Developer Notes

  • Internal data is stored as numpy.ndarray
  • Methods use scipy.stats, numpy, and matplotlib
  • Entropy assumes aligned distributions (normalized first)

🧛 License

MIT — haunt and hack as you please.


🕸️ Coming Soon

  • 3D support
  • More spooky plots
  • CLI interface: spookify file.csv --plot

👻 Contributing

Spirits and sorcerers of all levels are welcome. Open an issue, fork the repo, or summon a pull request.


🧛 License

MIT — you’re free to haunt this code as you wish as long as money is never involved!


✨ Stay spooky, and may your vectors always point toward the unknown. 🕸️

Student Opportunities 🎓💻

Learning to code, using GitHub, or just curious? Reach out and join the team!
We’re currently looking for volunteers of all skill levels. Everyone’s welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sp00kyvectors-0.1.13.tar.gz (253.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sp00kyvectors-0.1.13-py3-none-any.whl (254.8 kB view details)

Uploaded Python 3

File details

Details for the file sp00kyvectors-0.1.13.tar.gz.

File metadata

  • Download URL: sp00kyvectors-0.1.13.tar.gz
  • Upload date:
  • Size: 253.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/24.5.0

File hashes

Hashes for sp00kyvectors-0.1.13.tar.gz
Algorithm Hash digest
SHA256 bac3c7739cf81aaf2d128fc375afb70b3b9054271c11d19d4f7c3960e6d58d44
MD5 0f36a98827b924d38484ed775002bd17
BLAKE2b-256 b615b002d0f04c7bd450f1cb6837b52cdc7c11ba79d71b58fd640b1ca42da286

See more details on using hashes here.

File details

Details for the file sp00kyvectors-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: sp00kyvectors-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 254.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/24.5.0

File hashes

Hashes for sp00kyvectors-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 d93bac38e54e29ffcdbbb6bc774bfa38b901b0c80f238690c3b8c64df29d4605
MD5 28062173f98d3f378ff581e98675730d
BLAKE2b-256 22ac4525621b95c0ac3ad63ed7be4cfb3e737788be7b0ce4b44b98dc9d9af7fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page