Module: Khiva::Features

Defined in:
lib/khiva/features.rb

Class Method Summary collapse

Class Method Details

.abs_energy(arr) ⇒ Object



4
5
6
7
8
# File 'lib/khiva/features.rb', line 4

def abs_energy(arr)
  result = Utils.create_ptr
  FFI.call(:abs_energy, arr, result)
  Array.new(result)
end

.absolute_sum_of_changes(arr) ⇒ Object



10
11
12
13
14
# File 'lib/khiva/features.rb', line 10

def absolute_sum_of_changes(arr)
  result = Utils.create_ptr
  FFI.call(:absolute_sum_of_changes, arr, result)
  Array.new(result)
end

.aggregated_autocorrelation(arr, aggregation_function) ⇒ Object



16
17
18
19
20
# File 'lib/khiva/features.rb', line 16

def aggregated_autocorrelation(arr, aggregation_function)
  result = Utils.create_ptr
  FFI.call(:aggregated_autocorrelation, arr, Utils.int_ptr(aggregation_function), result)
  Array.new(result)
end

.approximate_entropy(arr, m, r) ⇒ Object

TODO aggregated_linear_trend



24
25
26
27
28
# File 'lib/khiva/features.rb', line 24

def approximate_entropy(arr, m, r)
  result = Utils.create_ptr
  FFI.call(:approximate_entropy, arr, Utils.int_ptr(m), Utils.float_ptr(r), result)
  Array.new(result)
end

.auto_correlation(arr, max_lag, unbiased) ⇒ Object



30
31
32
33
34
# File 'lib/khiva/features.rb', line 30

def auto_correlation(arr, max_lag, unbiased)
  result = Utils.create_ptr
  FFI.call(:auto_correlation, arr, Utils.long_ptr(max_lag), Utils.bool_ptr(unbiased), result)
  Array.new(result)
end

.auto_covariance(arr, unbiased: false) ⇒ Object



36
37
38
39
40
# File 'lib/khiva/features.rb', line 36

def auto_covariance(arr, unbiased: false)
  result = Utils.create_ptr
  FFI.call(:auto_covariance, arr, Utils.bool_ptr(unbiased), result)
  Array.new(result)
end

.binned_entropy(arr, max_bins) ⇒ Object



42
43
44
45
46
# File 'lib/khiva/features.rb', line 42

def binned_entropy(arr, max_bins)
  result = Utils.create_ptr
  FFI.call(:binned_entropy, arr, Utils.int_ptr(max_bins), result)
  Array.new(result)
end

.c3(arr, lag) ⇒ Object



48
49
50
51
52
# File 'lib/khiva/features.rb', line 48

def c3(arr, lag)
  result = Utils.create_ptr
  FFI.call(:c3, arr, Utils.long_ptr(lag), result)
  Array.new(result)
end

.cid_ce(arr, z_normalize) ⇒ Object



54
55
56
57
58
# File 'lib/khiva/features.rb', line 54

def cid_ce(arr, z_normalize)
  result = Utils.create_ptr
  FFI.call(:cid_ce, arr, Utils.bool_ptr(z_normalize), result)
  Array.new(result)
end

.count_above_mean(arr) ⇒ Object



60
61
62
63
64
# File 'lib/khiva/features.rb', line 60

def count_above_mean(arr)
  result = Utils.create_ptr
  FFI.call(:count_above_mean, arr, result)
  Array.new(result)
end

.count_below_mean(arr) ⇒ Object



66
67
68
69
70
# File 'lib/khiva/features.rb', line 66

def count_below_mean(arr)
  result = Utils.create_ptr
  FFI.call(:count_below_mean, arr, result)
  Array.new(result)
end

.cross_correlation(xss, yss, unbiased) ⇒ Object



72
73
74
75
76
# File 'lib/khiva/features.rb', line 72

def cross_correlation(xss, yss, unbiased)
  result = Utils.create_ptr
  FFI.call(:cross_correlation, xss, yss, Utils.bool_ptr(unbiased), result)
  Array.new(result)
end

.cross_covariance(xss, yss, unbiased) ⇒ Object



78
79
80
81
82
# File 'lib/khiva/features.rb', line 78

def cross_covariance(xss, yss, unbiased)
  result = Utils.create_ptr
  FFI.call(:cross_covariance, xss, yss, Utils.bool_ptr(unbiased), result)
  Array.new(result)
end

.energy_ratio_by_chunks(arr, num_segments, segment_focus) ⇒ Object

TODO cwt_coefficients



86
87
88
89
90
# File 'lib/khiva/features.rb', line 86

def energy_ratio_by_chunks(arr, num_segments, segment_focus)
  result = Utils.create_ptr
  FFI.call(:energy_ratio_by_chunks, arr, Utils.long_ptr(num_segments), Utils.long_ptr(segment_focus), result)
  Array.new(result)
end

.fft_aggregated(arr) ⇒ Object



92
93
94
95
96
# File 'lib/khiva/features.rb', line 92

def fft_aggregated(arr)
  result = Utils.create_ptr
  FFI.call(:fft_aggregated, arr, result)
  Array.new(result)
end

.first_location_of_maximum(arr) ⇒ Object

TODO fft_coefficient



100
101
102
103
104
# File 'lib/khiva/features.rb', line 100

def first_location_of_maximum(arr)
  result = Utils.create_ptr
  FFI.call(:first_location_of_maximum, arr, result)
  Array.new(result)
end

.first_location_of_minimum(arr) ⇒ Object



106
107
108
109
110
# File 'lib/khiva/features.rb', line 106

def first_location_of_minimum(arr)
  result = Utils.create_ptr
  FFI.call(:first_location_of_minimum, arr, result)
  Array.new(result)
end

.has_duplicate_max(arr) ⇒ Object



112
113
114
115
116
# File 'lib/khiva/features.rb', line 112

def has_duplicate_max(arr)
  result = Utils.create_ptr
  FFI.call(:has_duplicate_max, arr, result)
  Array.new(result)
end

.has_duplicate_min(arr) ⇒ Object



118
119
120
121
122
# File 'lib/khiva/features.rb', line 118

def has_duplicate_min(arr)
  result = Utils.create_ptr
  FFI.call(:has_duplicate_min, arr, result)
  Array.new(result)
end

.has_duplicates(arr) ⇒ Object



124
125
126
127
128
# File 'lib/khiva/features.rb', line 124

def has_duplicates(arr)
  result = Utils.create_ptr
  FFI.call(:has_duplicates, arr, result)
  Array.new(result)
end

.index_mass_quantile(arr, q) ⇒ Object



130
131
132
133
134
# File 'lib/khiva/features.rb', line 130

def index_mass_quantile(arr, q)
  result = Utils.create_ptr
  FFI.call(:index_mass_quantile, arr, Utils.float_ptr(q), result)
  Array.new(result)
end

.kurtosis(arr) ⇒ Object



136
137
138
139
140
# File 'lib/khiva/features.rb', line 136

def kurtosis(arr)
  result = Utils.create_ptr
  FFI.call(:kurtosis, arr, result)
  Array.new(result)
end

.large_standard_deviation(arr, r) ⇒ Object



142
143
144
145
146
# File 'lib/khiva/features.rb', line 142

def large_standard_deviation(arr, r)
  result = Utils.create_ptr
  FFI.call(:large_standard_deviation, arr, Utils.float_ptr(r), result)
  Array.new(result)
end

.last_location_of_maximum(arr) ⇒ Object



148
149
150
151
152
# File 'lib/khiva/features.rb', line 148

def last_location_of_maximum(arr)
  result = Utils.create_ptr
  FFI.call(:last_location_of_maximum, arr, result)
  Array.new(result)
end

.last_location_of_minimum(arr) ⇒ Object



154
155
156
157
158
# File 'lib/khiva/features.rb', line 154

def last_location_of_minimum(arr)
  result = Utils.create_ptr
  FFI.call(:last_location_of_minimum, arr, result)
  Array.new(result)
end

.length(arr) ⇒ Object



160
161
162
163
164
# File 'lib/khiva/features.rb', line 160

def length(arr)
  result = Utils.create_ptr
  FFI.call(:length, arr, result)
  Array.new(result)
end

.local_maximals(arr) ⇒ Object



166
167
168
169
170
# File 'lib/khiva/features.rb', line 166

def local_maximals(arr)
  result = Utils.create_ptr
  FFI.call(:local_maximals, arr, result)
  Array.new(result)
end

.longest_strike_above_mean(arr) ⇒ Object



172
173
174
175
176
# File 'lib/khiva/features.rb', line 172

def longest_strike_above_mean(arr)
  result = Utils.create_ptr
  FFI.call(:longest_strike_above_mean, arr, result)
  Array.new(result)
end

.longest_strike_below_mean(arr) ⇒ Object



178
179
180
181
182
# File 'lib/khiva/features.rb', line 178

def longest_strike_below_mean(arr)
  result = Utils.create_ptr
  FFI.call(:longest_strike_below_mean, arr, result)
  Array.new(result)
end

.maximum(arr) ⇒ Object



184
185
186
187
188
# File 'lib/khiva/features.rb', line 184

def maximum(arr)
  result = Utils.create_ptr
  FFI.call(:maximum, arr, result)
  Array.new(result)
end

.mean(arr) ⇒ Object



190
191
192
193
194
# File 'lib/khiva/features.rb', line 190

def mean(arr)
  result = Utils.create_ptr
  FFI.call(:mean, arr, result)
  Array.new(result)
end

.mean_absolute_change(arr) ⇒ Object



196
197
198
199
200
# File 'lib/khiva/features.rb', line 196

def mean_absolute_change(arr)
  result = Utils.create_ptr
  FFI.call(:mean_absolute_change, arr, result)
  Array.new(result)
end

.mean_change(arr) ⇒ Object



202
203
204
205
206
# File 'lib/khiva/features.rb', line 202

def mean_change(arr)
  result = Utils.create_ptr
  FFI.call(:mean_change, arr, result)
  Array.new(result)
end

.mean_second_derivative_central(arr) ⇒ Object



208
209
210
211
212
# File 'lib/khiva/features.rb', line 208

def mean_second_derivative_central(arr)
  result = Utils.create_ptr
  FFI.call(:mean_second_derivative_central, arr, result)
  Array.new(result)
end

.median(arr) ⇒ Object



214
215
216
217
218
# File 'lib/khiva/features.rb', line 214

def median(arr)
  result = Utils.create_ptr
  FFI.call(:median, arr, result)
  Array.new(result)
end

.minimum(arr) ⇒ Object



220
221
222
223
224
# File 'lib/khiva/features.rb', line 220

def minimum(arr)
  result = Utils.create_ptr
  FFI.call(:minimum, arr, result)
  Array.new(result)
end

.number_crossing_m(arr, m) ⇒ Object



226
227
228
229
230
# File 'lib/khiva/features.rb', line 226

def number_crossing_m(arr, m)
  result = Utils.create_ptr
  FFI.call(:number_crossing_m, arr, Utils.int_ptr(m), result)
  Array.new(result)
end

.number_peaks(arr, n) ⇒ Object

TODO number_cwt_peaks



234
235
236
237
238
# File 'lib/khiva/features.rb', line 234

def number_peaks(arr, n)
  result = Utils.create_ptr
  FFI.call(:number_peaks, arr, Utils.int_ptr(n), result)
  Array.new(result)
end

.partial_autocorrelation(arr, lags) ⇒ Object



240
241
242
243
244
# File 'lib/khiva/features.rb', line 240

def partial_autocorrelation(arr, lags)
  result = Utils.create_ptr
  FFI.call(:partial_autocorrelation, arr, lags, result)
  Array.new(result)
end

.percentage_of_reoccurring_datapoints_to_all_datapoints(arr, sorted) ⇒ Object



246
247
248
249
250
# File 'lib/khiva/features.rb', line 246

def percentage_of_reoccurring_datapoints_to_all_datapoints(arr, sorted)
  result = Utils.create_ptr
  FFI.call(:percentage_of_reoccurring_datapoints_to_all_datapoints, arr, Utils.bool_ptr(sorted), result)
  Array.new(result)
end

.percentage_of_reoccurring_values_to_all_values(arr, sorted) ⇒ Object



252
253
254
255
256
# File 'lib/khiva/features.rb', line 252

def percentage_of_reoccurring_values_to_all_values(arr, sorted)
  result = Utils.create_ptr
  FFI.call(:percentage_of_reoccurring_values_to_all_values, arr, Utils.bool_ptr(sorted), result)
  Array.new(result)
end

.quantile(arr, q, precision: 100000000) ⇒ Object



258
259
260
261
262
# File 'lib/khiva/features.rb', line 258

def quantile(arr, q, precision: 100000000)
  result = Utils.create_ptr
  FFI.call(:quantile, arr, q, Utils.float_ptr(precision), result)
  Array.new(result)
end

.range_count(arr, min, max) ⇒ Object



264
265
266
267
268
# File 'lib/khiva/features.rb', line 264

def range_count(arr, min, max)
  result = Utils.create_ptr
  FFI.call(:range_count, arr, Utils.float_ptr(min), Utils.float_ptr(max), result)
  Array.new(result)
end

.ratio_beyond_r_sigma(arr, r) ⇒ Object



270
271
272
273
274
# File 'lib/khiva/features.rb', line 270

def ratio_beyond_r_sigma(arr, r)
  result = Utils.create_ptr
  FFI.call(:ratio_beyond_r_sigma, arr, Utils.float_ptr(r), result)
  Array.new(result)
end

.ratio_value_number_to_time_series_length(arr) ⇒ Object



276
277
278
279
280
# File 'lib/khiva/features.rb', line 276

def ratio_value_number_to_time_series_length(arr)
  result = Utils.create_ptr
  FFI.call(:ratio_value_number_to_time_series_length, arr, result)
  Array.new(result)
end

.sample_entropy(arr) ⇒ Object



282
283
284
285
286
# File 'lib/khiva/features.rb', line 282

def sample_entropy(arr)
  result = Utils.create_ptr
  FFI.call(:sample_entropy, arr, result)
  Array.new(result)
end

.skewness(arr) ⇒ Object



288
289
290
291
292
# File 'lib/khiva/features.rb', line 288

def skewness(arr)
  result = Utils.create_ptr
  FFI.call(:skewness, arr, result)
  Array.new(result)
end

.spkt_welch_density(arr, coeff) ⇒ Object



294
295
296
297
298
# File 'lib/khiva/features.rb', line 294

def spkt_welch_density(arr, coeff)
  result = Utils.create_ptr
  FFI.call(:spkt_welch_density, arr, Utils.int_ptr(coeff), result)
  Array.new(result)
end

.standard_deviation(arr) ⇒ Object



300
301
302
303
304
# File 'lib/khiva/features.rb', line 300

def standard_deviation(arr)
  result = Utils.create_ptr
  FFI.call(:standard_deviation, arr, result)
  Array.new(result)
end

.sum_of_reoccurring_datapoints(arr, sorted: false) ⇒ Object



306
307
308
309
310
# File 'lib/khiva/features.rb', line 306

def sum_of_reoccurring_datapoints(arr, sorted: false)
  result = Utils.create_ptr
  FFI.call(:sum_of_reoccurring_datapoints, arr, Utils.bool_ptr(sorted), result)
  Array.new(result)
end

.sum_of_reoccurring_values(arr, sorted: false) ⇒ Object



312
313
314
315
316
# File 'lib/khiva/features.rb', line 312

def sum_of_reoccurring_values(arr, sorted: false)
  result = Utils.create_ptr
  FFI.call(:sum_of_reoccurring_values, arr, Utils.bool_ptr(sorted), result)
  Array.new(result)
end

.sum_values(arr) ⇒ Object



318
319
320
321
322
# File 'lib/khiva/features.rb', line 318

def sum_values(arr)
  result = Utils.create_ptr
  FFI.call(:sum_values, arr, result)
  Array.new(result)
end

.symmetry_looking(arr, r) ⇒ Object



324
325
326
327
328
# File 'lib/khiva/features.rb', line 324

def symmetry_looking(arr, r)
  result = Utils.create_ptr
  FFI.call(:symmetry_looking, arr, Utils.float_ptr(r), result)
  Array.new(result)
end

.time_reversal_asymmetry_statistic(arr, lag) ⇒ Object



330
331
332
333
334
# File 'lib/khiva/features.rb', line 330

def time_reversal_asymmetry_statistic(arr, lag)
  result = Utils.create_ptr
  FFI.call(:time_reversal_asymmetry_statistic, arr, Utils.int_ptr(lag), result)
  Array.new(result)
end

.value_count(arr, v) ⇒ Object



336
337
338
339
340
# File 'lib/khiva/features.rb', line 336

def value_count(arr, v)
  result = Utils.create_ptr
  FFI.call(:value_count, arr, Utils.float_ptr(v), result)
  Array.new(result)
end

.variance(arr) ⇒ Object



342
343
344
345
346
# File 'lib/khiva/features.rb', line 342

def variance(arr)
  result = Utils.create_ptr
  FFI.call(:variance, arr, result)
  Array.new(result)
end

.variance_larger_than_standard_deviation(arr) ⇒ Object



348
349
350
351
352
# File 'lib/khiva/features.rb', line 348

def variance_larger_than_standard_deviation(arr)
  result = Utils.create_ptr
  FFI.call(:variance_larger_than_standard_deviation, arr, result)
  Array.new(result)
end