csci5451/assignments/01/generate_test_data.py

21 lines
624 B
Python
Raw Normal View History

2023-09-23 05:04:06 +00:00
import random
import click
def evaluate(w, p):
result = sum(map(lambda s: s[0] * s[1], zip(w, p)))
return result
@click.command()
@click.option('--dimensions', default=2, help='Number of dimensions')
@click.option('--count', default=2000, help='How many points to generate')
def generate_test_data(dimensions: int, count: int):
actual_w = [random.uniform(0.0, 1.0) for _ in range(dimensions)]
for _ in range(count):
point = [random.uniform(0.0, 1.0) for _ in range(dimensions)]
y = evaluate(actual_w, point)
print(point, y)
if __name__ == '__main__':
generate_test_data()