Skip to main content

Library for maximum likelihood principal component analysis for AnyBody models

Project description

sillywalk

CI pypi-version python-version

sillywalk is a Python library for Maximum Likelihood Principal Component Analysis (ML-PCA). It allows you to build statistical models from data and predict missing values based on observed values. While it can be used with any numerical dataset, it includes special utilities for working with data from the AnyBody Modeling System™.

Installation

You can install sillywalk from PyPI,

pip install sillywalk

or as a conda package:

pixi install sillywalk

For developers

This project is managed by pixi. To set up a development environment:

git clone https://github.com/AnyBody-Research-Group/sillywalk
cd sillywalk

pixi install
pixi run test

Quick Start

Here's a quick example of how to use sillywalk to predict missing data.

1. Create a statistical model

First, you need a dataset to build the model. sillywalk works with both Pandas and Polars DataFrames.

import pandas as pd
import sillywalk

# Sample data of student measurements
data = {
    "Sex": [1, 1, 2, 2, 1, 2],
    "Age": [25, 30, 28, 22, 35, 29],
    "Stature": [175, 180, 165, 160, 185, 170],
    "Bodyweight": [70, 80, 60, 55, 85, 65],
    "Shoesize": [42, 44, 39, 38, 45, 40],
}
df = pd.DataFrame(data)

# Create a PCAPredictor model from the data
model = sillywalk.PCAPredictor(df)

2. Predict missing values

Once the model is created, you can use it to predict missing values based on some known values (constraints).

# Define the known values (constraints)
constraints = {
    "Stature": 180,
    "Bodyweight": 65,
}

# Predict the missing values
result = model.predict(constraints)

# The result is a dictionary containing the original constraints
# and predicted values for the other variables.
print(result)

3. Save and load the model

You can save your trained model to a file and load it later to make new predictions without having to re-train it.

# Save the model to a file
model.save_npz("student_model.npz")

# Load the model from the file
loaded_model = sillywalk.PCAPredictor.from_npz("student_model.npz")

# Use the loaded model to make predictions
new_constraints = {"Age": 24, "Shoesize": 43}
prediction = loaded_model.predict(new_constraints)

print(prediction)

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

sillywalk-1.0.0a0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

sillywalk-1.0.0a0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file sillywalk-1.0.0a0.tar.gz.

File metadata

  • Download URL: sillywalk-1.0.0a0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sillywalk-1.0.0a0.tar.gz
Algorithm Hash digest
SHA256 7e96c9b58373b42bbcfd54958941674a7a7d3ede8b9543a70cd6f4eaecd8aafa
MD5 55ec7bf51ac5cf4e1ffaa593a58c065f
BLAKE2b-256 f459ab0fbc90b943244a13e20a5f8fe8df6a3665478b89c588a7b62e0ed93786

See more details on using hashes here.

Provenance

The following attestation bundles were made for sillywalk-1.0.0a0.tar.gz:

Publisher: build.yml on AnyBody-Research-Group/sillywalk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sillywalk-1.0.0a0-py3-none-any.whl.

File metadata

  • Download URL: sillywalk-1.0.0a0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sillywalk-1.0.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d813730643e9338c43fd91c711273ee0deb715d0030ca1c29486a16ec148517
MD5 c9c52f01040e11c96842a91249c0021f
BLAKE2b-256 ea8386998d38084601791d233639419ca9c6f016fe2ddd5f397ebc6d0a7506f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for sillywalk-1.0.0a0-py3-none-any.whl:

Publisher: build.yml on AnyBody-Research-Group/sillywalk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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