Skip to main content

A package for classifying 1D signals using Fourier Series and Machine Learning

Project description

Fourier Series Classification

A package for classifying 1D signals using Fourier Series and Machine Learning.

Overview

This package implements the methodology described in the paper "Using Fourier Series and Machine Learning to Classify 1D-Signals". It provides tools for:

  • Generating various types of 1D signals (Box, Sawtooth, Exponential, Sinusoidal, Gaussian)
  • Computing Fourier series and coefficients
  • Detecting jumps in signals using concentration factors
  • Training neural network models for signal classification
  • Visualizing signals, Fourier coefficients, and classification results

Installation

Requirements

  • Python 3.6 or higher
  • NumPy
  • TensorFlow 2.4 or higher
  • Matplotlib
  • Plotly
  • Pandas
  • scikit-learn

Install from source

git clone https://github.com/abbass12/FourierSeriesClassification.git
cd FourierSeriesClassification
pip install -e .

Usage

Basic Example

import numpy as np
from fourier_classification.signals import box_signal
from fourier_classification.fourier import fourier_series
from fourier_classification.visualization import plot_signal_and_fourier

# Create domain
x = np.linspace(-np.pi, np.pi, 1500)

# Generate a box signal
signal = box_signal(x, a=2, b=5, normalized=True)

# Compute Fourier coefficients
fourier_coeffs = box_signal(x, a=2, b=5, normalized=True, fourier=True, n_modes=40)

# Plot signal and Fourier coefficients
fig = plot_signal_and_fourier(x, signal, fourier_coeffs, title="Box Signal")
fig.savefig("box_signal.png")

Signal Classification

import numpy as np
from fourier_classification.utils import create_domain, prepare_dataset
from fourier_classification.models import (
    create_feed_forward_model, 
    train_model, 
    evaluate_model,
    prepare_data_for_model_b
)

# Create domain
domain = create_domain(start=-np.pi, end=np.pi, num_points=1500)

# Prepare dataset
signal_types = ['Box', 'Saw', 'Exp', 'Sin', 'Gaus']
signals, labels = prepare_dataset(
    signal_types, 
    num_per_type=100, 
    domain=domain, 
    fourier=True, 
    n_modes=40
)

# Prepare data for Model B (Fourier coefficients)
x_train, x_test, y_train, y_test = prepare_data_for_model_b(signals, labels)

# Create and train model
model = create_feed_forward_model(input_shape=(x_train.shape[1],))
model, history = train_model(model, x_train, y_train, epochs=100)

# Evaluate model
results = evaluate_model(model, x_test, y_test, class_names=signal_types)
print(f"Test accuracy: {results['accuracy']:.4f}")

Module Structure

  • signals.py: Functions for generating various types of 1D signals
  • fourier.py: Functions for Fourier series calculations and transformations
  • operations.py: Functions for signal operations (noise, jumps)
  • models.py: Neural network models for signal classification
  • visualization.py: Functions for visualizing signals and results
  • utils.py: Utility functions for data handling and preprocessing

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use this code in your research, please cite:

@article{srour2023fourier,
  title={Using Fourier Series and Machine Learning to Classify 1D-Signals},
  author={Srour, Abbass},
  journal={},
  year={2023}
}

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

fourier_classification-1.0.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

fourier_classification-1.0.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file fourier_classification-1.0.0.tar.gz.

File metadata

  • Download URL: fourier_classification-1.0.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for fourier_classification-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d34839a659f981ab077554d0105fb0b36656a57bbf71db01ceb73622c0392c9d
MD5 db55352bd2029f4b2f094d2eaf08f1ce
BLAKE2b-256 0837d90f9373fcb008b19ae9b7cdc4879c27ad5dbce2e1719f2d1e280f2d8cef

See more details on using hashes here.

File details

Details for the file fourier_classification-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fourier_classification-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ba52fc407664ce605271280d14908f41945d4dea45cf8e3c5b60c2652a88707
MD5 28a9a741a1a8188fcc7b2dfac7ceca42
BLAKE2b-256 5240511e052f77578251f4192eb898758896cc615fb36f34b8db4748f1b1569f

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