Skip to content

Commit

Permalink
swapped function names for percentage of reoccuring (#725)
Browse files Browse the repository at this point in the history
* swapped function names for percentage of reoccuring

* fix  comments in reoccurring_values functions

* working on reoccurring_values comments

Co-authored-by: Emanuele Fumagalli <efumagal@synamedia.com>
  • Loading branch information
emanuelef and efumagal authored Jul 1, 2020
1 parent 0d1c62e commit 6f9c795
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions tests/units/feature_extraction/test_feature_calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,19 +516,19 @@ def test_first_location_of_minimum(self):

def test_percentage_of_doubled_datapoints(self):
self.assertAlmostEqualOnAllArrayTypes(percentage_of_reoccurring_datapoints_to_all_datapoints, [1, 1, 2, 3, 4],
0.25)
0.4)
self.assertAlmostEqualOnAllArrayTypes(percentage_of_reoccurring_datapoints_to_all_datapoints, [1, 1.5, 2, 3], 0)
self.assertAlmostEqualOnAllArrayTypes(percentage_of_reoccurring_datapoints_to_all_datapoints, [1], 0)
self.assertAlmostEqualOnAllArrayTypes(percentage_of_reoccurring_datapoints_to_all_datapoints,
[1.111, -2.45, 1.111, 2.45], 1.0 / 3.0)
[1.111, -2.45, 1.111, 2.45], 0.5)
self.assertIsNanOnAllArrayTypes(percentage_of_reoccurring_datapoints_to_all_datapoints, [])

def test_ratio_of_doubled_values(self):
self.assertAlmostEqualOnAllArrayTypes(percentage_of_reoccurring_values_to_all_values, [1, 1, 2, 3, 4], 0.4)
self.assertAlmostEqualOnAllArrayTypes(percentage_of_reoccurring_values_to_all_values, [1, 1, 2, 3, 4], 0.25)
self.assertAlmostEqualOnAllArrayTypes(percentage_of_reoccurring_values_to_all_values, [1, 1.5, 2, 3], 0)
self.assertAlmostEqualOnAllArrayTypes(percentage_of_reoccurring_values_to_all_values, [1], 0)
self.assertAlmostEqualOnAllArrayTypes(percentage_of_reoccurring_values_to_all_values,
[1.111, -2.45, 1.111, 2.45], 0.5)
[1.111, -2.45, 1.111, 2.45], 1.0 / 3.0)
self.assertIsNanOnAllArrayTypes(percentage_of_reoccurring_values_to_all_values, [])

def test_sum_of_reoccurring_values(self):
Expand Down
14 changes: 7 additions & 7 deletions tsfresh/feature_extraction/feature_calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,15 +863,15 @@ def first_location_of_minimum(x):


@set_property("fctype", "simple")
def percentage_of_reoccurring_datapoints_to_all_datapoints(x):
def percentage_of_reoccurring_values_to_all_values(x):
"""
Returns the percentage of unique values, that are present in the time series
Returns the percentage of values that are present in the time series
more than once.
len(different values occurring more than once) / len(different values)
This means the percentage is normalized to the number of unique values,
in contrast to the percentage_of_reoccurring_values_to_all_values.
in contrast to the percentage_of_reoccurring_datapoints_to_all_datapoints.
:param x: the time series to calculate the feature of
:type x: numpy.ndarray
Expand All @@ -891,15 +891,15 @@ def percentage_of_reoccurring_datapoints_to_all_datapoints(x):

@set_property("fctype", "simple")
@set_property("input", "pd.Series")
def percentage_of_reoccurring_values_to_all_values(x):
def percentage_of_reoccurring_datapoints_to_all_datapoints(x):
"""
Returns the ratio of unique values, that are present in the time series
more than once.
Returns the percentage of non-unique data points. Non-unique means that they are
contained another time in the time series again.
# of data points occurring more than once / # of all data points
This means the ratio is normalized to the number of data points in the time series,
in contrast to the percentage_of_reoccurring_datapoints_to_all_datapoints.
in contrast to the percentage_of_reoccurring_values_to_all_values.
:param x: the time series to calculate the feature of
:type x: numpy.ndarray
Expand Down

0 comments on commit 6f9c795

Please sign in to comment.