These methods are mostly utility methods written in python in pyscan.py.
pyscan.
close_region
(region)[source]¶Ensures that this region starts and ends at the same point. This is useful for using trajectory methods for regions. :param region: List of points :return: list of points
pyscan.
evaluate_range
(range, mp, bp, disc_f)[source]¶Evaluates this range to compute the total discrepancy over a set of points.
Parameters: |
|
---|---|
Returns: | Discrepancy function value. |
pyscan.
evaluate_range_trajectory
(range, mp, bp, disc_f)[source]¶Evaluates this range to compute the total discrepancy over a set of trajectories.
Parameters: |
|
---|---|
Returns: | Discrepancy function value. |
pyscan.
max_disk_region
(net, red_sample, red_weight, blue_sample, blue_weight, min_disk_r, max_disk_r, alpha, disc, fast_disk=True)[source]¶Computes the highest discrepancy disk over a set of trajectories. Executes at multiple scales using the grid directional compression method and internally compresses the trajectories if fast_disk is enabled.
Parameters: |
|
---|---|
Returns: |
pyscan.
max_disk_trajectory
(net, red_sample, blue_sample, min_disk_r, max_disk_r, alpha, disc, fast_disk=True)[source]¶Computes the highest discrepancy disk over a set of trajectories. Executes at multiple scales using the grid directional compression method and internally compresses the trajectories if fast_disk is enabled.
Parameters: |
|
---|---|
Returns: |
pyscan.
max_disk_trajectory_fixed
(net, m_sample, b_sample, min_disk_r, max_disk_r, disc, fast_disk=True)[source]¶Computes the highest discrepancy disk over a set of trajectories. Executes at multiple scales, but uses whatever set of points the trajectories have been compressed with.
Parameters: |
|
---|---|
Returns: | A tuple of the maximum disk and the corresponding maximum value. |
pyscan.
paired_plant_region
(traj_start, traj_end, r, q, region_plant_f)[source]¶This plants a region where every trajectory completely outside or inside of the region has an endpoint chosen at random. Every trajectory with one endpoint inside the region has an endpoint chosen inside with probability q (exactly q fraction have one endpoint in the region) traj_start and traj_end should be the same length.
Parameters: |
|
---|---|
Returns: | Red planted set, blue planted set, and the planted region. |
pyscan.
plant_disk
(pts, r, p, q)[source]¶Create a set of red and blue points with a random disk planted containing r fraction of the points with q fraction of the points in the region being red and p fraction of the points outside of the region being red.
Parameters: |
|
---|---|
Returns: | red set, blue set, planted region. |
pyscan.
plant_full_disk
(trajectories, r, p, q)[source]¶Choose a point at random from a trajectory and then expand outward from there until we find a disk contains r fraction of the trajectories.
Parameters: |
|
---|---|
Returns: | red set, blue set, planted disk, maximum discrepancy. |
pyscan.
plant_full_disk_region
(region_set, r, p, q)[source]¶Choose a point at random from a region and then expand a disk out from this point till this disk contains r fraction of all the regions. :param region_set: List of list of points. This argument is modified by adding a point at the end in some cases. :param r: double between 0 and 1 :param p: double between 0 and 1 :param q: double between 0 and 1 :return: red set of regions, blue set of regions, the planted region
pyscan.
plant_full_halfplane
(trajectories, r, p, q)[source]¶Choose a random direction and then finds a halfplane with this normal containing r fraction of the total trajectories.
Parameters: |
|
---|---|
Returns: | red set of trajectories, blue set of trajectories, planted region, discrepancy function value. |
pyscan.
plant_full_square
(trajectories, r, p, q, max_count=32)[source]¶Choose a point at random from a trajectory and then expand a square out from this point till this region contains r fraction of all the trajectories.
Parameters: |
|
---|---|
Returns: | red set of trajectories, blue set of trajectories, the planted region, and the exact partial discrepancy. |
pyscan.
plant_full_square_region
(regions, r, p, q, max_count=32)[source]¶Choose a point at random from a region and then expand a square out from this point till this region contains r fraction of all the regions.
Parameters: |
|
---|---|
Returns: | red set of regions, blue set of regions, the planted region |
pyscan.
plant_halfplane
(pts, r, p, q)[source]¶Create a set of red and blue points with a random halfplane planted containing r fraction of the points with q fraction of the points in the region being red and p fraction of the points outside of the region being red.
Parameters: |
|
---|---|
Returns: | red set, blue set, planted region. |
pyscan.
plant_partial_disk
(trajectories, r, p, q, eps)[source]¶Choose a point at random from a trajectory and then expand outward from there. Computes the fraction of length inside the disk for each segment and then does bisection on this amount since it is a monotonic function to compute within eps fraction.
Parameters: |
|
---|---|
Returns: | red set of trajectories, blue set of trajectories, the planted region, and the exact partial discrepancy. |
pyscan.
plant_partial_halfplane
(trajectories, r, p, q, eps)[source]¶Choose a random direction and expand the region along this direction till we contain r fraction of the total trajectory arc length.
Parameters: |
|
---|---|
Returns: | red set of trajectories, blue set of trajectories, the planted region, and the exact partial discrepancy. |
pyscan.
plant_partial_rectangle
(trajectories, r, p, q, eps)[source]¶This plants a region containing r fraction of the total arc length of all trajectories. q fraction of the trajectories crossing this region are assigned to be anomalous and p fraction of trajectories not crossing this region are assigned to be anomalous.
Parameters: |
|
---|---|
Returns: | red set of trajectories, blue set of trajectories, the planted region. |
pyscan.
plant_rectangle
(pts, r, p, q)[source]¶Create a set of red and blue points with a random rectangle planted containing r fraction of the points with q fraction of the points in the region being red and p fraction of the points outside of the region being red.
Parameters: |
|
---|---|
Returns: | red set, blue set, planted region. |
pyscan.
plant_region
(points, r, p, q, eps, scan_f)[source]¶This takes a scanning function and two point sets and then computes a planted region that contains some fraction r of the points with some tolerance. This then computes a red and blue set of points based on the planted region.
Inside the region q fraction of points are red. Outside the region p fraction of points are red
Parameters: |
|
---|---|
Returns: | red set, blue set, region planted. |
pyscan.
random_rect
(points, r)[source]¶Plants a random rectangle containing r fraction of the points.
Parameters: |
|
---|---|
Returns: | The planted region. |
pyscan.
evaluate_halfplane
(reg, mpts, bpts, disc_f)¶pyscan.
evaluate_halfplane_labeled
(reg, lmpts, lbpts, disc_f)¶pyscan.
evaluate_halfplane_trajectory
(reg, mtrajs, btrajs, disc_f)¶pyscan.
evaluate_disk
(reg, mpts, bpts, disc_f)¶pyscan.
evaluate_disk_alt
(reg, mpts, bpts, disc_f)¶pyscan.
evaluate_disk_labeled
(reg, lmpts, lbpts, disc_f)¶pyscan.
evaluate_disk_trajectory
(reg, mtrajs, btrajs, disc_f)¶pyscan.
evaluate_rectangle
(reg, mpts, bpts, disc_f)¶pyscan.
evaluate_rectangle_labeled
(reg, lmpts, lbpts, disc_f)¶pyscan.
evaluate_rectangle_trajectory
(reg, mtrajs, btrajs, disc_f)¶These functions can be used to evaluate different regions on different kinds of data sets.
pyscan.
size_region
(fraction)¶Creates a discrepancy function that can be used to find a region containing a certain fraction of the points.
Parameters: | fraction – A double between 0 and 1. |
---|---|
Return type: | A discrepancy function. |
pyscan.
evaluate
(disc_f, m, m_total, b, b_total)¶A utility function for explicitly evaluating a discrepancy function object.
Parameters: |
|
---|---|
Return type: | A double returned by the discrepancy function. |