Created
July 27, 2020 01:26
-
-
Save foohm71/fd02a62576ce49f19d1b01e022f8ae51 to your computer and use it in GitHub Desktop.
AutoML conversion
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
# 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