Extraction
ChangesDetector
Bases: TransformerStep
Compute how many changes there are in a categorical variable
['a', 'a', 'b', 'c] -> [0, 0, 1, 1]
Source code in ceruleo/transformation/features/extraction.py
transform(X)
Appply the transformation to the input life
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A DataFrame with boolean values representing weather changes were applied to the input variable or not |
Source code in ceruleo/transformation/features/extraction.py
ColumnWiseSum
Bases: TransformerStep
Compute the column-wise sum each column
Parameters:
Name | Type | Description | Default |
---|---|---|---|
column_name |
str
|
Name of the unique column which is returned |
required |
Source code in ceruleo/transformation/features/extraction.py
transform(X)
Apply the transformation to the input life
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A single-column DataFrame containing the column-wise sum for each input sample |
Source code in ceruleo/transformation/features/extraction.py
Difference
Bases: TransformerStep
Compute the difference between two set of features
Example:
X[features1] - X[features2]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feature_set1 |
List[str]
|
Feature list of the first group to substract |
required |
feature_set2 |
List[str]
|
Feature list of the second group to substract |
required |
name |
Optional[str]
|
Name of the step, by default None |
None
|
Source code in ceruleo/transformation/features/extraction.py
transform(X)
Apply the transformation to the input life
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A DataFrame with two columns containing the result of the differences between the two sets of input features |
Source code in ceruleo/transformation/features/extraction.py
EMD
Bases: TransformerStep
Compute the empirical mode decomposition of each feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
Number of modes to compute |
required |
name |
Optional[str]
|
Name of the step, by default None |
'EMD'
|
Source code in ceruleo/transformation/features/extraction.py
transform(X)
Apply transformation to the input life
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A DataFrame where the number of columns is n times the one of the input life, since each features is substituted by the n modes of its EMD |
Source code in ceruleo/transformation/features/extraction.py
EMDFilter
Bases: TransformerStep
Filter the signals using Empirical Mode decomposition
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
Number of modes |
required |
min_imf |
int
|
Min Intrinsic Mode Function |
required |
max_imf |
int
|
Max Intrinsic Mode Function |
required |
Source code in ceruleo/transformation/features/extraction.py
transform(X)
Apply the transformation to the input life
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A DataFrame with the same shape of the input life and with the result of the EMD Filter application |
Source code in ceruleo/transformation/features/extraction.py
ExpandingStatistics
Bases: TransformerStep
Compute diverse number of features using an expandign window
For each feature present in the life a number of feature will be computed for each time stamp
The possible features are:
- Kurtosis
- Skewness
- Max
- Min
- Std
- Peak
- Impulse
- Clearance
- RMS
- Shape
- Crest
- Hurst
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_points |
int
|
The minimun number of points of the expanding window, by default 2 |
2
|
to_compute |
List[str]
|
List of the features to compute, by default None. Valid values are: 'kurtosis', 'skewness', 'max', 'min', 'std', 'peak', 'impulse','clearance', 'rms', 'shape', 'crest', 'hurst' |
None
|
name |
Optional[str]
|
Name of the step, by default None |
None
|
Source code in ceruleo/transformation/features/extraction.py
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 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 |
|
transform(X)
Compute features from the given life
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A new DataFrame with one row and with n columns. Let m be the number of features of the life and f the len(to_compute), then n = m x f, |
Source code in ceruleo/transformation/features/extraction.py
HashingEncodingCategorical
Bases: TransformerStep
Compute a simple numerical encoding for a given feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nbins |
int
|
Number of bins after the hash |
required |
feature |
Optional[str]
|
Feature name from which compute the simple encoding |
None
|
name |
Optional[str]
|
Step name |
None
|
Source code in ceruleo/transformation/features/extraction.py
transform(X, y=None)
Return a new DataFrame with the feature encoded with integer numbers
Parameters; X: The input life y: [type], optional
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A new dataframe with the same index as the input with 1 column containing the encoding of the input feature. |
Source code in ceruleo/transformation/features/extraction.py
Interactions
Bases: TransformerStep
Compute pairwise interactions between the features
Source code in ceruleo/transformation/features/extraction.py
transform(X)
Apply the transformation to one life
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
DataFrame containing the pairwise interaction values |
Source code in ceruleo/transformation/features/extraction.py
LifeStatistics
Bases: TransformerStep
Compute diverse number of features for each life.
Returns a 1 row with the statistics computed for every feature
The possible features are:
- Kurtosis
- Skewness
- Max
- Min
- Std
- Peak
- Impulse
- Clearance
- RMS
- Shape
- Crest
- Hurst
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to_compute |
Optional[List[str]]
|
List of the features to compute, by default None. Valid values are:'kurtosis', 'skewness', 'max', 'min', 'std', 'peak', 'impulse','clearance', 'rms', 'shape', 'crest', 'hurst' |
None
|
name |
Optional[str]
|
Name of the step, by default None |
None
|
Source code in ceruleo/transformation/features/extraction.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
|
transform(X)
Compute features from the given life
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A new DataFrame with one row and with n columns. Let m be the number of features of the life and f the len(to_compute), then n = m x f, |
Source code in ceruleo/transformation/features/extraction.py
OneHotCategorical
Bases: TransformerStep
Compute a one-hot encoding for a given feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feature |
Optional[str]
|
Feature name from which compute the one-hot encoding |
None
|
name |
Optional[str]
|
Step name, by default None |
None
|
Source code in ceruleo/transformation/features/extraction.py
transform(X, y=None)
Apply the transformation to the input life
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A DataFrame with shape equal to (X.shape[0],n_unique(feature)) containin the One Hot Encoding for the input feature |
Source code in ceruleo/transformation/features/extraction.py
RollingStatistics
Bases: TransformerStep
Compute diverse number of features using an rolling window.
For each feature present in the life a number of feature will be computed for each time stamp
The possible features are:
Time domain:
- Kurtosis
- Skewness
- Max
- Min
- Std
- Peak
- Impulse
- Clearance
- RMS
- Shape
- Crest
Parameters:
Name | Type | Description | Default |
---|---|---|---|
window |
int
|
Size of the rolling window, by default 15 |
15
|
min_points |
The minimun number of points of the expanding window |
2
|
|
to_compute |
Optional[List[str]]
|
Name of features to compute. Possible values are: 'kurtosis', 'skewness', 'max', 'min', 'std', 'peak', 'impulse', 'clearance', 'rms', 'shape', 'crest' |
None
|
name |
Optional[str]
|
Name of the step, by default None |
None
|
Source code in ceruleo/transformation/features/extraction.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 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 |
|
transform(X)
Compute features from the given life
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A new DataFrame with one row and with n columns. Let m be the number of features of the life and f the len(to_compute), then n = m x f |
Source code in ceruleo/transformation/features/extraction.py
SampleNumber
Bases: TransformerStep
Return a column with increasing number
Source code in ceruleo/transformation/features/extraction.py
transform(X)
Apply the transformation to the input life
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A DataFrame with increasing sample indexes. |
Source code in ceruleo/transformation/features/extraction.py
SimpleEncodingCategorical
Bases: TransformerStep
Compute a simple numerical encoding for a given feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feature |
Optional[str]
|
Feature name from which compute the simple encoding |
None
|
name |
Optional[str]
|
Step name, by default None |
None
|
Source code in ceruleo/transformation/features/extraction.py
fit(X, y=None)
Compute the set of possible categories
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
SimpleEncodingCategorical
|
Instance of class SimpleEncodingCategorical |
Source code in ceruleo/transformation/features/extraction.py
partial_fit(X, y=None)
Compute incrementally the set of possible categories
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
SimpleEncodingCategorical
|
Instance of class SimpleEncodingCategorical |
Source code in ceruleo/transformation/features/extraction.py
transform(X, y=None)
Return a new DataFrame with the feature encoded with integer numbers
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A new dataframe with the same index as the input with 1 column with the Simple Encoding of the input feature. |
Source code in ceruleo/transformation/features/extraction.py
SlidingNonOverlappingWaveletDecomposition
Bases: TransformerStep
TODO TEST
X = signal coeffs = pywt.wavedec(X, 'db1', level=level) A4 = wrcoef(X, 'a', coeffs, 'db1', level) D4 = wrcoef(X, 'd', coeffs, 'db1', level) D3 = wrcoef(X, 'd', coeffs, 'db1', 3) D2 = wrcoef(X, 'd', coeffs, 'db1', 2) D1 = wrcoef(X, 'd', coeffs, 'db1', 1) r = A4 + D4 + D3 + D2 + D1 assert(np.mean(r-X) < 0.00000)
Parameters
TransformerStep : [type] [description]
Source code in ceruleo/transformation/features/extraction.py
TimeToPreviousBinaryValue
Bases: TransformerStep
Return a column with increasing number