data_transforms package

The data transforms package takes data structured in complex nested JSON format and flattens it into un-nested structures ready for analysis.

Submodules

Utility functions for calculating angle-based metrics

data_transforms.angle_metric.angle_distance(a, b)

A function that takes in two angles and returns the absolute values of the interior angle between them.

Parameters:
  • a (float) – The first angle in degrees

  • b (float) – The second angle in degrees

Returns:

d – The absolute value of the interior angle between a and b in degrees

Return type:

float

Does stuff.

Usage:

python extract.py –fname <abs_path_to_file>

data_transforms.extract.T0(shared_df, annotations_df)

Extract answer to the question “What is the cat doing?” for task 0.

Parameters:
  • shared_df (pandas.Dataframe) – pandas.Dataframe that contains quantities that will be shared across all .csv files.

  • annotations_df (pandas.Dataframe) – ps.Series with ``annotations for each classification.

Returns:

pandas.Dataframe with shared_df

quantities and answer to “What is the cat doing?”.

Return type:

new_df (pandas.Dataframe)

data_transforms.extract.T1(shared_df, annotations_df)
Extract answer to the question “How many cats are in the image?” for task 1.
Args:
shared_df (pandas.Dataframe): pandas.Dataframe that contains quantities that will

be shared across all .csv files.

annotations_df (pandas.Dataframe): ps.Series with annotations for

each classification.

Returns:
new_df (pandas.Dataframe): pandas.Dataframe with shared_df

quantities and answer to “How many cats are in the image?”. Answers which cannot be converted to integers are stored as numpy nan values instead.

data_transforms.extract.T2(shared_df, annotations_df)

Extract the required variables for task 2. i.e the x and y coordinates of the eye locations. :param shared_df: DataFrame containing only ‘classification_id’, ‘user_id’, and ‘subject_ids’. :type shared_df: DataFrame :param annotations_df: DataFrame containing relevent data. :type annotations_df: DataFrame

Returns:

DataFrame containing the ‘classification_id’, ‘user_id’, and ‘subject_ids’ and lists of tuples of x and y coordinates of the eye locations.

Return type:

DataFrame

data_transforms.extract.T3(shared_df, annotations_df)

Extract the required variables for task 3. i.e the radius of the nose x and y coordinates of the nose. :param shared_df: DataFrame containing only ‘classification_id’, ‘user_id’, and ‘subject_ids’. :type shared_df: DataFrame :param annotations_df: DataFrame containing relevent data. :type annotations_df: DataFrame

Returns:

DataFrame containing the ‘classification_id’, ‘user_id’, and ‘subject_ids’ and radius, x, y coordinates of nose.

Return type:

DataFrame

data_transforms.extract.T4(shared_df, annotations_df)

Extract required variables for task 4.

data_transforms.extract.extract(fname)

Extract all desired information from the zooniverse data file.

Parameters:

fname (str) – Absolute path to zooniverse .csv file.