face2face.statistics.average_degree.avg_degree_attr

face2face.statistics.average_degree.avg_degree_attr(df)

Calculates the average degree

Calculates the average degree for every subgroup and for the whole group for every attribute.

Parameters

df (Data) – Data Object that contains Tij- and Metadata for a data set.

Returns

attr_degree_list – A list that contains the average degree for every subgroup and for the whole group for every attribute.

Return type

list

Examples

The first string in a list, for example “Age”, tells you which attribute’s average degrees are in this list. The following first list entries for example 0.0, 1.0 or 2.0 are the different attribute values and the second entry in the list is the average degree for this attribute value. The ‘GlobalAvG’ list entry tells you the average degree for the whole attribute (for example “Age”).

>>> attr_list = ["ID", "Age", "Sex"]
>>> test_df = Data(path_tij="face2face/data/Test/tij_test.dat", separator_tij=" ",
>>>               path_meta="face2face/data/Test/meta_test.dat", separator_meta="       ",
>>>               meta_attr_list=attr_list)
>>> avg_degree_list = avg_degree_attr(test_df)
>>> print(avg_degree_list)
[['Age', [[0.0, 1.6666666666666667], [1.0, 2.5], [2.0, 2.0], ['GlobalAvG', 2.055555555555556]]],
 ['Sex', [['F', 1.8], ['M', 2.0], ['GlobalAvG', 1.9]]]]

See also

face2face.group_list_degree(), face2face.global_avg_var_std()