Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import numpy as np
# Band data set
# A test data set meant to an imbalanced data set with a small positive class (4.886%)
# Randomly sample [0, 1) x [0, 1)
# Points within the annulus with
# - c = [0.5, 0.5]
# - 0.38 < r < 0.4
# Are Positive (1)
# All other points are Negative (0)
np.random.seed(seed=0)
def make_dataset(n):
x = np.random.rand(n, 2)
y = []
for i in range(0, n):
x_i = x[i]
r = np.linalg.norm(x_i - 0.5)
if r < 0.4 and r > 0.38:
y.append(1)
else:
y.append(0)
return (x, y)
def test_dataset():
avg = 0
runs = 100
n = 5000
for i in range(0, runs):
(_, y) = make_dataset(n)
run_ratio = float(np.sum(y)) / n
avg += run_ratio / runs
print(f"band test, avg positive percentage: {avg * 100}")