Skip to main content

HIERVAR: Hierarchical feature selection for time series analysis

Project description

HIERVAR

Time series classification stands as a pivotal and intricate challenge across various domains, including finance, healthcare, and industrial systems. In contemporary research, there has been a notable upsurge in exploring feature extraction through random sampling. Unlike deep convolutional networks, these methods sidestep elaborate training procedures, yet they often necessitate generating a surplus of features to comprehensively encapsulate time series nuances. Consequently, some features may lack relevance to labels or exhibit multi-collinearity with others. In this paper, we propose a novel hierarchical feature selection method aided by ANOVA variance analysis to address this challenge. Through meticulous experimentation, we demonstrate that our method substantially reduces features by over 94% while preserving accuracy-- a significant advancement in the field of time series analysis and feature selection.

How to import

# Import necessary libraries and modules from the 'hiervar' package
import hiervar.RASTER as RASTER
import hiervar.anova as anova
import hiervar.classifier as classifier
import hiervar.utils as utils
import numpy as np
import warnings

apply it on MiniROCKET

# Apply MiniROCKET transformation with 10,000 features
# 'shuffle_quant' is set to False to keep the quantization order fixed
x_train_trans_mini, x_test_trans_mini, parameter_raster = RASTER.MiniROCKET(
    x_train, y_train, x_test, y_test, n_features=10000, shuffle_quant=False
)

# Train a classifier on the transformed MiniROCKET data and evaluate its accuracy
accuracy_mini, _, clf = classifier.classic_classifier(
    x_train_trans_mini, y_train, x_test_trans_mini, y_test
)
print("Number of Features: ", x_train_trans_mini.shape[1], "Accuracy: ", accuracy_mini)

# Use HIERVAR to prune features from MiniROCKET-transformed data
result, erocket_index, selected_mean = anova.anova_erocket_pruner(
    x_train_trans_mini, y_train, threshold=None, divider=2, verbose=False
)


# Train the classifier again using only the pruned features
accuracy_erocket_modified, _, _ = classifier.classic_classifier(
    x_train_trans_mini[:, result], y_train, x_test_trans_mini[:, result], y_test
)
print("Number of Features (After HIERVAR): ", len(result), "Accuracy: ", accuracy_erocket_modified)

Apply it on RASTER

# Apply the full RASTER transformation with the same number of features (10,000)
x_train_trans_raster, x_test_trans_raster, parameter_raster = RASTER.RASTER(
    x_train, y_train, x_test, y_test, n_features=10000, shuffle_quant=False
)

# Train a classifier on the RASTER-transformed data and evaluate its accuracy
accuracy_raster, _, clf = classifier.classic_classifier(
    x_train_trans_raster, y_train, x_test_trans_raster, y_test
)
print("Number of Features: ", x_train_trans_raster.shape[1], "Accuracy: ", accuracy_raster)

# Prune features again using HIERVAR on the RASTER-transformed data
result, erocket_index, selected_mean = anova.anova_erocket_pruner(
    x_train_trans_raster, y_train, threshold=None, divider=2, verbose=False
)

# Re-evaluate the classifier using only the pruned RASTER features
accuracy_erocket_modified, _, _ = classifier.classic_classifier(
    x_train_trans_raster[:, result], y_train, x_test_trans_raster[:, result], y_test
)
print("Number of Features (After HIERVAR): ", len(result), "Accuracy: ", accuracy_erocket_modified)

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

hiervar-0.1.0.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

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

hiervar-0.1.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file hiervar-0.1.0.tar.gz.

File metadata

  • Download URL: hiervar-0.1.0.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hiervar-0.1.0.tar.gz
Algorithm Hash digest
SHA256 46b166e77cb6536e8d39f2158d99da5c86285b2d9af3cc050abbbe6a192e123d
MD5 f2610e99bee7e2d09c23c2c69cdf9da5
BLAKE2b-256 8601cec57e4d1a6e954f6e646fc1283d425d7569b9f3404565e87ca07b8c51eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for hiervar-0.1.0.tar.gz:

Publisher: publish.yml on alirezakesha/HIERVAR

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

File details

Details for the file hiervar-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hiervar-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hiervar-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc8ea36c9ca335b18780aef89f39eafdda9a3200ac8ae15ae6ef3ce2e7e7d9b8
MD5 7ef80a180d33268df164b9fa77d3302d
BLAKE2b-256 4e51f7c78e5810ccc5a576f4b8f250834ed30f96f91a0b2fe0698a135a32e361

See more details on using hashes here.

Provenance

The following attestation bundles were made for hiervar-0.1.0-py3-none-any.whl:

Publisher: publish.yml on alirezakesha/HIERVAR

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