def use_dtw(dataset_path): dataset=seq_dataset(path) test,train=split.person_dataset(dataset) y_pred=wrap(train,test) print(utils.data.find_errors(y_pred,test)) seq.check_prediction(y_pred,test['y'])
y_i=y[i] mask_i=mask[i] loss_i=model.train(x_i,y_i,mask_i) cost.append(loss_i) sum_j=sum(cost)/float(len(cost)) print(str(j) + ' ' + str(sum_j)) return model def check_prediction(y_pred,y_true): print(classification_report(y_true, y_pred)) print(confusion_matrix(y_true,y_pred)) def get_batches(x,batch_size=6): n_batches=len(x)/batch_size if((len(x) % batch_size)!=0): n_batches+=1 return [x[i*batch_size:(i+1)*batch_size] for i in range(n_batches)] if __name__ == "__main__": path='../dane5/seq/' nn_path='../dane5/lstm_' dataset=to_dataset.seq_dataset(path) new_dataset=to_dataset.masked_dataset(dataset) test,train=split.person_dataset(new_dataset) print(train.keys()) model=make_model(train,False) model.get_model().save(nn_path) check_model(model,test)