Skip to content

Instantly share code, notes, and snippets.

@foohm71
Created July 27, 2020 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foohm71/fd02a62576ce49f19d1b01e022f8ae51 to your computer and use it in GitHub Desktop.
Save foohm71/fd02a62576ce49f19d1b01e022f8ae51 to your computer and use it in GitHub Desktop.
AutoML conversion
# write training data function
def write_training_data_to_zipfile(path, Xdata, Ydata):
os.chdir(path)
count = {}
num_rows = Xdata.shape[0]
for i in range(1,num_rows):
label = Ydata.iloc[i]
feature = Xdata.iloc[i]
folder = path + "/" + label
if not os.path.exists(folder):
os.mkdir(folder)
if not (label in count.keys()):
count[label] = 1
else:
count[label] += 1
file = folder + "/" + "sample" + str(count[label]) + ".txt"
with open(file, 'wb') as fp:
fp.write(feature.encode("utf-8"))
fp.write("\n".encode('utf-8'))
fp.close()
! zip -r documents.zip *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment