Prioritizer class¶
-
class
pyanp.prioritizer.
Prioritizer
[source]¶ This class is the abstract representation of anything that prioritizes a list of items. Examples include
pyanp.pairwise.Pairwise
for doing group pairwise comparisons andpyanp.ahptree.AHPTree
for doing group AHP tree models.-
add_alt
(alt_name: str, ignore_existing=True) → None[source]¶ Add an alternative to the prioritizer. This should be overriden by the implementing class.
Parameters: alt_name – The name of the alternative to add. Returns: Nothing
-
add_user
(uname)[source]¶ Adds a user to this prioritizer object.
Parameters: user_name – The name of the user to add Returns: Nothing Raises: ValueError – If the user already existed.
-
data_names
(append_to=None, post_pend='') → str[source]¶ Return string of newline separated names for the data that this prioritizer needs for each user.
Parameters: - append_to – If not none, elements are appended here, otherwise a new list is created.
- post_pend – A string to post_pend to each name
Returns: List of strings of names.
-
nalts
()[source]¶ Returns: The number of alternatives (things you are pairwise comparing) in this group pairwise comparison object.
-
priority
(username=None, ptype: pyanp.prioritizer.PriorityType = None) → pandas.core.series.Series[source]¶ Calculates the alternative priorities. Should be overriden by the implementing class.
Parameters: user_name – The name/names of the users to calculate the priority of. If None, we get the priority of the group average. If it is a string, we get the priority of that user. If it is a list of users, we get the priority of the group average for that list of users.
Parameters: ptype – How should we normalize the resulting priorities (if at all). Returns: A pandas.Series whose indices are the alternative names and whose values are the priorities of those alternatives.
-
priority_df
(user_infos=None) → pandas.core.frame.DataFrame[source]¶ Returns the priority scores dataframe for all users and the group
Parameters: user_infos – A list of users to do this for, if None is a part of this list, it means group average. If None, it defaults to None plus all users. Returns: pandas.DataFrame rows are alternatives, cols are users.
-