Modification of getSampleRate method for all CF scripts.
parent
ab0b9227d7
commit
470993eeb0
|
@ -8,10 +8,11 @@ import sys
|
||||||
|
|
||||||
def getSampleRate(data):
|
def getSampleRate(data):
|
||||||
try:
|
try:
|
||||||
timestamps_diff = data['timestamp'].iloc[1] - data['timestamp'].iloc[0]
|
timestamps_diff = data['timestamp'].diff().dropna().mean()
|
||||||
except:
|
except:
|
||||||
raise Exception("Error occured while trying to get the sample rate from the first two sequential timestamps.")
|
raise Exception("Error occured while trying to get the mean sample rate from the data.")
|
||||||
|
|
||||||
|
print(1000/timestamps_diff)
|
||||||
return 1000/timestamps_diff
|
return 1000/timestamps_diff
|
||||||
|
|
||||||
def extractAccFeaturesFromIntradayData(acc_intraday_data, features, time_segment, filter_data_by_segment):
|
def extractAccFeaturesFromIntradayData(acc_intraday_data, features, time_segment, filter_data_by_segment):
|
||||||
|
@ -41,7 +42,7 @@ def extractAccFeaturesFromIntradayData(acc_intraday_data, features, time_segment
|
||||||
|
|
||||||
|
|
||||||
def cf_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
|
def cf_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
|
||||||
eda_intraday_data = pd.read_csv(sensor_data_files["sensor_data"])
|
acc_intraday_data = pd.read_csv(sensor_data_files["sensor_data"])
|
||||||
|
|
||||||
requested_intraday_features = provider["FEATURES"]
|
requested_intraday_features = provider["FEATURES"]
|
||||||
# name of the features this function can compute
|
# name of the features this function can compute
|
||||||
|
@ -50,8 +51,8 @@ def cf_features(sensor_data_files, time_segment, provider, filter_data_by_segmen
|
||||||
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
|
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
|
||||||
|
|
||||||
# extract features from intraday data
|
# extract features from intraday data
|
||||||
eda_intraday_features = extractAccFeaturesFromIntradayData(eda_intraday_data,
|
acc_intraday_features = extractAccFeaturesFromIntradayData(acc_intraday_data,
|
||||||
intraday_features_to_compute, time_segment,
|
intraday_features_to_compute, time_segment,
|
||||||
filter_data_by_segment)
|
filter_data_by_segment)
|
||||||
|
|
||||||
return eda_intraday_features
|
return acc_intraday_features
|
|
@ -7,10 +7,10 @@ from CalculatingFeatures.calculate_features import calculateFeatures
|
||||||
|
|
||||||
def getSampleRate(data):
|
def getSampleRate(data):
|
||||||
try:
|
try:
|
||||||
timestamps_diff = data['timestamp'].iloc[1] - data['timestamp'].iloc[0]
|
timestamps_diff = data['timestamp'].diff().dropna().mean()
|
||||||
except:
|
except:
|
||||||
raise Exception("Error occured while trying to get the sample rate from the first two sequential timestamps.")
|
raise Exception("Error occured while trying to get the mean sample rate from the data.")
|
||||||
|
|
||||||
return 1000/timestamps_diff
|
return 1000/timestamps_diff
|
||||||
|
|
||||||
def extractEDAFeaturesFromIntradayData(eda_intraday_data, features, time_segment, filter_data_by_segment):
|
def extractEDAFeaturesFromIntradayData(eda_intraday_data, features, time_segment, filter_data_by_segment):
|
||||||
|
|
|
@ -7,10 +7,10 @@ from CalculatingFeatures.calculate_features import calculateFeatures
|
||||||
|
|
||||||
def getSampleRate(data):
|
def getSampleRate(data):
|
||||||
try:
|
try:
|
||||||
timestamps_diff = data['timestamp'].iloc[1] - data['timestamp'].iloc[0]
|
timestamps_diff = data['timestamp'].diff().dropna().mean()
|
||||||
except:
|
except:
|
||||||
raise Exception("Error occured while trying to get the sample rate from the first two sequential timestamps.")
|
raise Exception("Error occured while trying to get the mean sample rate from the data.")
|
||||||
|
|
||||||
return 1000/timestamps_diff
|
return 1000/timestamps_diff
|
||||||
|
|
||||||
def extractTempFeaturesFromIntradayData(temperature_intraday_data, features, time_segment, filter_data_by_segment):
|
def extractTempFeaturesFromIntradayData(temperature_intraday_data, features, time_segment, filter_data_by_segment):
|
||||||
|
|
Loading…
Reference in New Issue