1) write number to file(file_name)
2) write array to file(file_name)
1)
def write_answer_(num,file_name):
with open(file_name,”w”) as fout:
fout.write(str(num))
2)
def write_answer_arr(scores_,file_name):
with open(file_name, “w”) as fout:
fout.write(“ “.join([str(num) for num in scores_]))
map preds array of (0, 1, 2)s into mapped_preds array of (2, 0, 1)s
mapping = {0 : 2, 1: 0, 2: 1}
mapped_preds = [mapping[pred] for pred in preds]count number of lines in file
1) num_lines = sum(1 for line in open(‘myfile.txt’))
2) num_lines = len(list(open(‘myfile.txt’)))
change package in conda
conda install scikit-learn=0.17
Create bootstrap sample
def get_bootstrap_samples(data, n_samples):
indices = np.random.randint(0, len(data), (n_samples, len(data)))
samples = data[indices]
return samples