#!/usr/bin/python3 # -*- coding:utf-8 -*- import csv import math import random import sys def create_polynomial_logistic_data(filename): with open(filename, 'w') as f: writer = csv.writer( f, delimiter=('\t' if filename.endswith('.tsv') else ',')) for i in range(50): x = random.uniform(-1.0, 1.0) y = random.uniform(-1.0, 1.0) p = math.sqrt(x*x + y*y) for i in range(1): p = -2 * p**3 + 3 * p**2 v = 1 if random.random() > p else 0 writer.writerow([v, x, y]) if __name__ == '__main__': create_polynomial_logistic_data(sys.argv[1])