UPDRS

class updrs.UPDRS(data_frame=None, data_frame_file_path=None)

This class calculates the UPDRS score Part 3 for a given testResultSet. UPDRS performs k-means on a set of observation vectors forming k clusters.

The abbreviation for the observations are as follows:

“OT-RH” > One Target - Right Hand “OT-LH” > One Target - Left Hand “TT-RH” > Two Targets - Right Hand “TT-LH” > Two Targets - Left Hand “PS-RH” > Pronation Supination - Right Hand “PS-LH” > Pronation Supination - Left Hand “LA-RL” > Leg Agility - Right Leg “LA-LL” > Leg Agility - Left Leg “PTOTH-RH” > Postural Tremor Of The Hands - Right Hand “PTOTH-LH” > Postural Tremor Of The Hands - Left Hand “KTOH-RH” > Kinetic Tremor Of Hands - Right Hand “KTOH-LH” > Kinetic Tremor Of Hands - Left Hand “RTA-RH” > Rest Tremor Amplitude - Right Hand “RTA-LH” > Rest Tremor Amplitude - Left Hand “RTA-RL” > Rest Tremor Amplitude - Right Leg “RTA-LL” > Rest Tremor Amplitude - Left Leg

Example:

>>> import pdkit
>>> updrs = pdkit.UPDRS(data_frame)

The UPDRS scores can be written to a file. You can pass the name of a filename and the output_format

>>> updrs.write_model(filename='scores', output_format='csv')

To score a new measurement against the trained knn clusters.

>>> updrs.score(measurement)

To read the testResultSet data from a file. See TestResultSet class for more details.

>>> updrs = pdkit.UPDRS(data_frame_file_path=file_path_to_testResultSet_file)
Parameters:
  • data_frame (pandas.DataFrame) – testResultSet

  • data_frame_file_path (string) – the path to read the data frame from

get_single_score(point, centroids=None, sd=None)

Get a single score is a wrapper around the result of classifying a Point against a group of centroids. Attributes:

observation_score (dict): Original received point and normalised point.

Example:

>>> { "original": [0.40369016, 0.65217912], "normalised": [1.65915104, 3.03896181]}

nearest_cluster (int): Index of the nearest cluster. If distances match, then lowest numbered cluster wins.

distances (list (float)): List of distances from the Point to each cluster centroid. E.g:

>>> [2.38086238, 0.12382605, 2.0362993, 1.43195021]

centroids (list (list (float))): A list of the current centroidswhen queried. E.g:

>>> [ [0.23944831, 1.12769265], [1.75621978, 3.11584191], [2.65884563, 1.26494783],             [0.39421099, 2.36783733] ]
Parameters:
  • point (pandas.DataFrame) – the point to classify

  • centroids (np.array) – the centroids

  • sd (np.array) – the standard deviation

Return score:

the score for a given observation

Rtype score:

int

score(measurement, output_format='array')

Method to score/classify a measurement against the trained knn clusters

Parameters:
  • measurement (pandas.DataFrame) – the point to classify

  • output_format (string) – the format to return the scores (‘array’ or ‘str’)

Return scores:

the scores for a given test/point

Rtype scores:

np.array

write_model(filename='scores', filepath='', output_format='csv')

This method calculates the scores and writes them to a file the data frame received. If the output format is other than ‘csv’ it will print the scores.

Parameters:
  • filename (string) – the name to give to the file

  • filepath (string) – the path to save the file

  • output_format (string) – the format of the file to write (‘csv’)