Permalink
Cannot retrieve contributors at this time
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?
cse5819-FinalProject/band.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
33 lines (30 sloc)
835 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") |