sport_activities_features
¶
-
class
sport_activities_features.
BanisterTRIMP
(duration, avg_hr)¶ Bases:
object
Implementation of Banisters TRIMP
- Attributes:
float: Total duration in minutes float: Average heart rate in bpm
-
calculate_TRIMP
()¶ Calculation of TRIMP
- Reference:
Banister, E. W. “Modeling elite athletic performance.” Physiological testing of elite athletes 403 (1991): 424.
- Returns:
float: TRIMP value
-
class
sport_activities_features.
DataAnalysis
(**kwargs)¶ Bases:
object
Data analysis toolbox that uses automated machine learning to analyze extracted sport features.
- Date:
2021
- Author:
Luka Pečnik
- License:
MIT
- Attributes:
None
-
analyze_data
(src, fitness_name, population_size, number_of_evaluations, optimization_algorithm, classifiers, feature_selection_algorithms=None, feature_transform_algorithms=None, imputer=None)¶ Run AutoML process using NiaAML PipelineOptimizer class instance.
- Note:
See NiaAML’s documentation for more details on possible input parameters’ values and further usage of the returned Pipeline object.
- Arguments:
src (string): Path to a CSV file. fitness_name (str): Name of the fitness class to use as a function. population_size (uint): Number of individuals in the optimization process. number_of_evaluations (uint): Number of maximum evaluations. optimization_algorithm (str): Name of the optimization algorithm to use. classifiers (Iterable[Classifier]): Array of names of possible classifiers. feature_selection_algorithms (Optional[Iterable[str]]): Array of names of possible feature selection algorithms. feature_transform_algorithms (Optional[Iterable[str]]): Array of names of possible feature transform algorithms. imputer (Optional[str]): Name of the imputer used for features that contain missing values.
- Returns:
Pipeline: Instance of Pipeline object from the NiaAML framework.
-
static
load_pipeline
(file_name)¶ Load a NiaAML’s pipeline from a binary file.
- Note:
See NiaAML’s documentation for more details on the use of the Pipeline class.
- Arguments:
file_name (string): Path to a binary pipeline file.
-
class
sport_activities_features.
HillIdentification
(altitudes, ascent_threshold)¶ Bases:
object
Identification of Hills from TCX file.
- Attributes:
altitudes: An array of altitude values extracted from TCX file ascent_threshold (float): Parameter that defines the hill (hill >= ascent_threshold)
-
identify_hills
()¶ Algorithm for the identification of hills from data.
- Note:
:Algorithm is still in its preliminary stage.
-
return_hill
(ascent_threshold)¶ Return
- Returns:
bool:
-
return_hills
()¶ Return identified hills.
- Returns:
str: Array of identified hills.
-
class
sport_activities_features.
IntervalIdentificationByHeartrate
(distances, timestamps, altitudes, heartrates, minimum_time=30)¶ Bases:
object
-
calculate_interval_statistics
()¶
-
identify_intervals
()¶
-
return_intervals
()¶
-
-
class
sport_activities_features.
IntervalIdentificationByPower
(distances, timestamps, altitudes, mass, minimum_time=30)¶ Bases:
object
-
calculate_interval_statistics
()¶
-
identify_intervals
()¶
-
return_intervals
()¶
-
-
class
sport_activities_features.
PlotData
¶ Bases:
object
Plotting the extracted data.
-
draw_basic_map
(altitude, distance)¶ Plot the whole topographic map.
-
draw_hills_in_map
(altitude, distance, identified_hills)¶ Plot all hills identified in data on topographic map.
-
draw_intervals_in_map
(timestamp, distance, identified_intervals)¶ Plot all intervals identified in data on topographic map.
-
get_positions_of_hills
(identified_hills)¶ Return positions of identified hills.
- Returns:
str: Array
-
get_positions_of_intervals
(identified_intervals)¶ Return positions of identified intervals.
- Returns:
str: Array
-
-
class
sport_activities_features.
StoredSegments
(segment, ascent)¶ Bases:
object
-
class
sport_activities_features.
TCXFile
¶ Bases:
object
Working with TCX files
-
extract_integral_metrics
(filename)¶ Parse one TCX file and extract integral metrics.
- Returns:
dictionary:
-
read_directory
(directory_name)¶ Find all tcx files in a directory.
- Returns:
str: Array of strings
-
read_one_file
(filename)¶ Parse one TCX file.
- Returns:
dictionary:
- Note:
In the case of missing value in raw data, we assign None
-
-
class
sport_activities_features.
TopographicFeatures
(identified_hills)¶ Bases:
object
Implementation of feature extraction from topographic maps.
- Attributes:
identified_hills: Identified hills are now passed to this class.
-
ascent
(altitude_data)¶ Implementation of ascent calculation (should be improved)
- Returns:
float: total ascent
-
avg_altitude_of_hills
(alts)¶ FEATURE: The average altitude of all identified hills in sport activity.
- Returns:
float: average altitude
-
avg_ascent_of_hills
(alts)¶ FEATURE: Average ascent of all hills in sport activity.
- Returns:
float: average ascent
-
calculate_distance
(lat1, lat2, lon1, lon2)¶
-
descent
(altitude_data)¶ Implementation of descent calculation (should be improved)
- Returns:
float: total descent
-
distance_of_hills
(positions)¶ FEATURE: Total distance of all identified hills in sport activity.
- Returns:
float: distance of hills
-
num_of_hills
()¶ FEATURE: Number of identified hills in sport activity.
- Returns:
int: number of hills
FEATURE: Share of hills in sport activity (percentage)
- Returns:
float: share of hills
-
class
sport_activities_features.
Weather
(temperature: Optional[float] = None, maximum_temperature: Optional[float] = None, minimum_temperature: Optional[float] = None, wind_chill: Optional[float] = None, heat_index: Optional[float] = None, precipitation: Optional[float] = None, snow_depth: Optional[float] = None, wind_speed: Optional[float] = None, wind_gust=None, visibility: Optional[float] = None, cloud_cover: Optional[float] = None, relative_humidity: Optional[float] = None, weather_type: Optional[str] = None, conditions: Optional[str] = None, date: Optional[datetime.datetime] = None, location=None, index: Optional[int] = None)¶ Bases:
object
-
class
sport_activities_features.
WeatherIdentification
(locations, timestamps, vc_api_key, unit_group='metric')¶ Bases:
object
Identification of Weather data from TCX file.
- Attributes:
altitudes: An array of altitude values extracted from TCX file ascent_threshold (float): Parameter that defines the hill (hill >= ascent_threshold)
-
get_weather
() → [<class ‘sport_activities_features.weather_identification.Weather’>]¶ Returns: list of objects Weather from the nearest meteorological station for every 1 hour of training.
-
weather_api_call
(time: datetime.datetime, location: (<class 'float'>, <class 'float'>), index)¶