I want to generate a .csv two-dimensional flat distribution artificial dataset file. I want to output the values generated in the code to the .csv file. Each line is separated by a comma. There are two columns, such as:
1
the first column represents the value of x, and the second column represents the value of y. The
code is as follows:
from sklearn.datasets import make_blobs
from matplotlib import pyplot
data,target=make_blobs
pyplot.scatter (data [:, 0], data [:, 1], c=target);
pyplot.show ()
the above code can only show the generated picture. I want to output the data, but it"s not right. The code I changed is as follows:
from sklearn.datasets import make_blobs
from matplotlib import pyplot
import sys
data,target=make_blobs
pyplot.scatter (data [:, 0], data [:, 1], c=target);
output=sys.stdout
outputfile=open
sys.stdout=outputfile
pyplot.show ()
outputfile.close ()
sys.stdout=output
after modification, the syntheticdataset.csv file can be generated, but there is no data I want in it. How can I modify it?