NumericalDifferentiator¶
yohou.preprocessing.signal.NumericalDifferentiator
¶
Bases: BaseTransformer
Numerical differentiation transformer for time series signals.
Differentiates each feature column using np.gradient, which computes the derivative using central differences in the interior and first differences at the boundaries.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
order
|
(1, 2)
|
Gradient is calculated using N-th order accurate differences at the boundaries: - 1: First-order accurate (uses 2 points at boundary) - 2: Second-order accurate (uses 3 points at boundary) |
1
|
Attributes¶
| Name | Type | Description |
|---|---|---|
interval_ |
str
|
Detected time interval string (e.g., '1d', '1h', '1s'). |
sampling_interval_ |
float
|
Sampling interval in seconds derived from interval_. |
Examples¶
>>> import polars as pl
>>> from datetime import datetime, timedelta
>>> time = [datetime(2020, 1, 1) + timedelta(seconds=i * 0.001) for i in range(100)]
>>> X = pl.DataFrame({"time": time, "signal": [float(i) for i in range(100)]})
>>> transformer = NumericalDifferentiator(order=1)
>>> transformer.fit(X)
NumericalDifferentiator(...)
>>> X_t = transformer.transform(X)
>>> "time" in X_t.columns
True
Notes¶
- Output has the same length as input
- Uses central differences in the interior (more accurate)
- Uses one-sided differences at boundaries (order controls accuracy)
- Inverse transform uses cumulative trapezoidal integration
See Also¶
NumericalIntegrator: Numerical integration transformer.numpy.gradient: NumPy gradient function.
Source Code¶
Show/Hide source
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | |
Methods¶
get_feature_names_out(input_features=None)
¶
Get output feature names for transformation.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
input_features
|
array-like of str or None
|
Column names of the input features. If |
None
|
Returns¶
| Type | Description |
|---|---|
list of str
|
Output feature names after transformation. |
Source Code¶
Show/Hide source
Tutorials¶
The following example notebooks use this component:
-
How to Apply Signal Processing Filters
Data-Features
Apply NumericalFilter (Butterworth, Chebyshev, Bessel), NumericalDifferentiator, and NumericalIntegrator for signal smoothing and rate-of-change extraction.