DylComp module¶
-
class
DylComp.
Comparator
(objects: list = None, level: int = 3, rand: bool = False, seed: int = None)[source]¶ Bases:
object
A class for comparing 2 values.
Controlled with the optimizaiton level and if you want random decisions or not Either provide objects in init or call .genLookup before you do any comparing Optimization levels: will not optimize, store result, do abc association, do recursive association Rand: defaults to False. If True will create data from random distributions with seed parameter
-
empiricROC
() → dict[source]¶ Generates and stores the empiric ROC if it needs to.
Returns the stored ROC curve.
-
genRand
(n0: int, n1: int, sep: float, dist: str)[source]¶ Generates the random data. If a seed has not previously been provided, it will be assigned here.
This new seeding may not work on Windows, so Windows users should assign the seed on their own.
-
genSeps
() → list[source]¶ Goes through the stored records and returns a list of the minimum separations.
If there is no minimum separation (the image has not been seen more than once), uses 2*(n0+n1) as a palceholder
-
getLatentScore
(imgID: int) → float[source]¶ gets the latent score of a given imgID or array of imgIDs.
If only one index is provided, also returns if the image is from the disease negative distribution.
-
kendalltau
(predicted: list) → float[source]¶ Returns the kendalltau statistic between the predicted image ID ordering and the true ordering of the image IDs with respect to latent score.
This method filters image IDs by what’s in predicted, so only the ids in predicted are used.
-
learn
(arr: list, img: int = None, maxi: bool = False)[source]¶ Learn the order of the array provided.
assuming the current optimization level allows it: if img is provided, learns the arr w.r.t. the img and if it is max or min. arr can also be a filename, in whichcase it will read the file to learn
-
max
(arr, tryingAgain=False) → Tuple[int, int][source]¶ Gets the maximum of the array with respect to the latent scores.
tryingAgain should always be False unless a network comparator is used. Returns the undex of the maximum ID and the maximum ID.
-
min
(arr) → Tuple[int, int][source]¶ Gets the minimum of the array with respect to the latent scores.
Returns the undex of the minimum ID and the minimum ID.
-
static
optimize
(objects: list, lookup: dict, res: bool, a, b) → int[source]¶ Recursive optimization algorithm for adding a node to a fully connected graph.
Returns the number of optimizations it did.
-
record
(vals: list)[source]¶ Record that these values were seen.
This is automatically called by min and max.
-
-
class
DylComp.
NetComparator
(ip: str, port: int, recorder=None, objects: list = None, level: int = 3)[source]¶ Bases:
DylComp.Comparator
A class for doing comparisons over a network.