Skip to main content

CSMHP

This package is an implementation of:
Cluster-based Superposed Marked Hawkes Process (CIBer)

The CSMHP package implements a novel Hawkes process model in PyTorch for modeling event sequence with high dimension of covariates, especially categorical ones. This model is useful in various fields such as finance, healthcare, and cyber-risk analysis, where temporal event sequences need to be modeled and analyzed. The package allows training a Hawkes process with clustering-based probability estimates.

Features

  • Hawkes Process Model: A self-exciting point process that models events whose intensity is influenced by prior events.
  • Clustering Model Integration: Integrates clustering algorithms to infer event type probabilities.
  • Parameter Optimization: Supports optimization of the model parameters (mu, gamma, alpha_kernel, beta_kernel) using gradient-based methods.
  • Event Simulation: Implements the thinning algorithm for simulating future event times based on the trained model.
  • Mini-batch Optimization: Option for mini-batch optimization to handle large datasets efficiently.

Installation

To install the CSMHP package, you can use pip:

pip install CSMHP

```python
import torch
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from CSMHP import CSM_Hawkes

# Initialize parameters
T = 1000  # Length of observation window
num_clusters = 3  # Number of event clusters
params = None  # Optionally provide initial parameters
X_train = np.random.rand(100, 5)  # Example training data with 100 events and 5 features
y_train = np.random.randint(0, num_clusters, size=100)

# Define a clustering model (e.g., KMeans)
cluster_model = RandomForestClassifier(n_estimators=50, max_depth=2)
cluster_model.fit(X_train, y_train)
probability = cluster_model.predict(X_train)

# Initialize CSM_Hawkes model
hawkes_model = CSMHP(T=T, num_clusters=num_clusters, params=params, 
                          model=cluster_model, X_train=X_train, step=0.01, unit='Week')

# Fit the model (train the probability and parameters)
event_times = np.random.rand(100) * T  # Example event times
hawkes_model.fit_param(event_times, probability epoch=20)
hawkes_model.fit_prob(event_times, probability, step=0.5, epoch=5)
hawkes_model.fit_param(event_times, None, epoch=20)
hawkes_model.fit_prob(event_times, None, step=0.5, epoch=5)
hawkes_model.fit_param(event_times, None, epoch=10)

Metadata

Release files for CSMHP 0.1.5

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

Source distribution (sdist)

Source distribution for CSMHP 0.1.5
File Size Uploaded
csmhp-0.1.5.tar.gz 17.8 kB Details

Built distribution (wheel)

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

Total release size: 38.6 kB

Release files / csmhp-0.1.5.tar.gz

Download URL csmhp-0.1.5.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4dc674f5bb3be7045aed6ae721d4d7549116f2e30fe4b5ba104d22ac1cbabfc9
BLAKE2b-256 checksum
How to use checksums
fc4377f18bc1a20749591df41476e8f89d5b6fa2ed199a0ab1af773254fb3aa8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / CSMHP-0.1.5-py3-none-any.whl

Download URL CSMHP-0.1.5-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6395e5a2451d8bb9b5469a9e2467a8dea10101b49a5e869073c0850177818552
BLAKE2b-256 checksum
How to use checksums
1ee4e579f188218f8db92a0af4fe874dac4cf137fb4bd9076ffa22c49ba3d414
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release 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