Skip to main content

ou

Window pairs of sequences

To install: pip install ou

Overview

The ou package provides tools for analyzing sequences by creating and manipulating pairs of sliding windows over data. This can be particularly useful in time series analysis, event sequence analysis, or any scenario where relationships between different segments of a dataset are of interest.

Main Features

  • Window Pair Iterators: Generate pairs of indices representing windows over a data range, which can be used to extract and analyze overlapping or consecutive segments of data.
  • Event Window Analysis: Functions to handle timestamped event data, allowing analysis of events occurring within specified past and future windows relative to a present moment.
  • Feature Extraction: Utilities to extract features from data within generated windows, which can be used for further statistical analysis or machine learning.
  • Aggregation and Counting: Tools to aggregate and count occurrences across pairs of windows, useful for frequency analysis in categorical data.

Usage Examples

Window Pair Iteration

Generate sliding window pairs from a data sequence:

from ou import wp_iter_with_sliding_discrete_step
data_range = 10
x_range = 2
y_range = 3
offset = 1

for window_pair in wp_iter_with_sliding_discrete_step(data_range, x_range, y_range, offset):
    print(window_pair)

Event Window Analysis

Analyze events with past and future context:

from ou import past_present_future_idx_and_duration_iter
timestamp_seq = [0, 5, 10, 15, 20]
past_range = 5
future_range = 5

for ppf_idx, duration, present_timestamp in past_present_future_idx_and_duration_iter(timestamp_seq, past_range, future_range):
    print(f"Past-Present-Future Index: {ppf_idx}, Duration: {duration}, Present Timestamp: {present_timestamp}")

Feature Extraction from Data Windows

Extract features using predefined or custom functions applied to data windows:

import pandas as pd
from ou import FeaturePairFactory, extract_series

# Sample data
data = pd.DataFrame({'timestamp': range(0, 100, 10), 'value': range(10)})

# Define feature extraction functions
def sum_values(df):
    return df['value'].sum()

# Setup feature pair factory
factory = FeaturePairFactory(past_feat_func=sum_values, past_range=30)

# Generate feature pairs
for feature_pair in factory.feature_pair_and_duration_iter(data):
    print(feature_pair)

Aggregation of Windowed Data

Aggregate counts across pairs of windows:

from ou import extract_series, agg_counts

# Using the same 'data' DataFrame from the previous example
window_iterator = wp_iter_with_sliding_discrete_step(data_range=len(data))
pairs_of_series = extract_series(data, window_iterator)

# Aggregate counts
aggregated_counts = agg_counts(pairs_of_series)
print(aggregated_counts)

Documentation

Each function and class in the ou package is documented with docstrings, providing detailed usage instructions and examples. Users are encouraged to refer to these docstrings for more specific information on function parameters and expected data formats.

Download files

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

Source Distribution

ou-0.0.6.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

ou-0.0.6-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file ou-0.0.6.tar.gz.

File metadata

  • Download URL: ou-0.0.6.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ou-0.0.6.tar.gz
Algorithm Hash digest
SHA256 5d553a70fce05d8b131a204f78259e5736cfa3909eb6de75ddabc2275faeed70
MD5 7c1e29e3c6c2abc59d122e342b74dd2e
BLAKE2b-256 f4c41aefa770933e1847c85e72e52892c7e7b73b9e0c538bd36fc9b7a19843af

See more details on using hashes here.

File details

Details for the file ou-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: ou-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ou-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 387609b7131c95b84412229949cbbb527cfe77e8adbfb8ed54722391c1515c5f
MD5 5836c201c95cec843b2d29b336a7d6a7
BLAKE2b-256 08be597d90a8c64df0054c7513f95bdbb48ecf7896aa2790ea00ac0600ddfd7d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

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