Python sklearn.metrics.hamming_loss() Examples
The following are 30
code examples of sklearn.metrics.hamming_loss().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sklearn.metrics
, or try the search function
.
Example #1
Source File: multi_class_classification.py From edge2vec with BSD 3-Clause "New" or "Revised" License | 11 votes |
def multi_class_classification(data_X,data_Y): ''' calculate multi-class classification and return related evaluation metrics ''' svc = svm.SVC(C=1, kernel='linear') # X_train, X_test, y_train, y_test = train_test_split( data_X, data_Y, test_size=0.4, random_state=0) clf = svc.fit(data_X, data_Y) #svm # array = svc.coef_ # print array predicted = cross_val_predict(clf, data_X, data_Y, cv=2) print "accuracy",metrics.accuracy_score(data_Y, predicted) print "f1 score macro",metrics.f1_score(data_Y, predicted, average='macro') print "f1 score micro",metrics.f1_score(data_Y, predicted, average='micro') print "precision score",metrics.precision_score(data_Y, predicted, average='macro') print "recall score",metrics.recall_score(data_Y, predicted, average='macro') print "hamming_loss",metrics.hamming_loss(data_Y, predicted) print "classification_report", metrics.classification_report(data_Y, predicted) print "jaccard_similarity_score", metrics.jaccard_similarity_score(data_Y, predicted) # print "log_loss", metrics.log_loss(data_Y, predicted) print "zero_one_loss", metrics.zero_one_loss(data_Y, predicted) # print "AUC&ROC",metrics.roc_auc_score(data_Y, predicted) # print "matthews_corrcoef", metrics.matthews_corrcoef(data_Y, predicted)
Example #2
Source File: link_prediction.py From edge2vec with BSD 3-Clause "New" or "Revised" License | 7 votes |
def evaluation_analysis(true_label,predicted): ''' return all metrics results ''' print "accuracy",metrics.accuracy_score(true_label, predicted) print "f1 score macro",metrics.f1_score(true_label, predicted, average='macro') print "f1 score micro",metrics.f1_score(true_label, predicted, average='micro') print "precision score",metrics.precision_score(true_label, predicted, average='macro') print "recall score",metrics.recall_score(true_label, predicted, average='macro') print "hamming_loss",metrics.hamming_loss(true_label, predicted) print "classification_report", metrics.classification_report(true_label, predicted) print "jaccard_similarity_score", metrics.jaccard_similarity_score(true_label, predicted) print "log_loss", metrics.log_loss(true_label, predicted) print "zero_one_loss", metrics.zero_one_loss(true_label, predicted) print "AUC&ROC",metrics.roc_auc_score(true_label, predicted) print "matthews_corrcoef", metrics.matthews_corrcoef(true_label, predicted)
Example #3
Source File: test_classification.py From Mastering-Elasticsearch-7.0 with MIT License | 7 votes |
def test_multilabel_hamming_loss(): # Dense label indicator matrix format y1 = np.array([[0, 1, 1], [1, 0, 1]]) y2 = np.array([[0, 0, 1], [1, 0, 1]]) w = np.array([1, 3]) assert_equal(hamming_loss(y1, y2), 1 / 6) assert_equal(hamming_loss(y1, y1), 0) assert_equal(hamming_loss(y2, y2), 0) assert_equal(hamming_loss(y2, 1 - y2), 1) assert_equal(hamming_loss(y1, 1 - y1), 1) assert_equal(hamming_loss(y1, np.zeros(y1.shape)), 4 / 6) assert_equal(hamming_loss(y2, np.zeros(y1.shape)), 0.5) assert_equal(hamming_loss(y1, y2, sample_weight=w), 1. / 12) assert_equal(hamming_loss(y1, 1-y2, sample_weight=w), 11. / 12) assert_equal(hamming_loss(y1, np.zeros_like(y1), sample_weight=w), 2. / 3) # sp_hamming only works with 1-D arrays assert_equal(hamming_loss(y1[0], y2[0]), sp_hamming(y1[0], y2[0])) assert_warns_message(DeprecationWarning, "The labels parameter is unused. It was" " deprecated in version 0.21 and" " will be removed in version 0.23", hamming_loss, y1, y2, labels=[0, 1])
Example #4
Source File: deep_conv_classification_alt48_luad10_skcm10_v0.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (10000, classn), dtype = np.int32); Or = np.empty(shape = (10000, classn), dtype = np.float32); Tr = np.empty(shape = (10000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #5
Source File: deep_conv_classification_alt39.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #6
Source File: deep_conv_classification_alt29.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, batchsize = 100, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #7
Source File: deep_conv_classification_alt48_heatmap_only_melanoma.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (1000000, classn), dtype = np.int32); Or = np.empty(shape = (1000000, classn), dtype = np.float32); Tr = np.empty(shape = (1000000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #8
Source File: deep_conv_classification_alt48_luad10_luad10in20_brca10x1_heatmap.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (1000000, classn), dtype = np.int32); Or = np.empty(shape = (1000000, classn), dtype = np.float32); Tr = np.empty(shape = (1000000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #9
Source File: deep_conv_classification_lpatch_alt3.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (10000, classn), dtype = np.int32); Or = np.empty(shape = (10000, classn), dtype = np.float32); Tr = np.empty(shape = (10000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #10
Source File: deep_conv_classification_alt36-sp-cnn.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #11
Source File: deep_conv_classification_alt51_luad10_luad10in20_brca10x2.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, y_val, BatchSize, shuffle = False): inputs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #12
Source File: deep_conv_classification_alt48_adeno_t0.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (10000, classn), dtype = np.int32); Or = np.empty(shape = (10000, classn), dtype = np.float32); Tr = np.empty(shape = (10000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #13
Source File: deep_conv_classification_alt28.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, batchsize = 100, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #14
Source File: deep_conv_classification_alt53.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #15
Source File: deep_conv_classification_alt34.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, batchsize = 100, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #16
Source File: deep_conv_classification_alt35_deploy.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #17
Source File: deep_conv_classification_alt48maxp_luad10_luad10in20_brca10x1.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #18
Source File: deep_conv_classification_alt36.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #19
Source File: deep_conv_classification_alt52.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #20
Source File: deep_conv_classification_alt48maxp_luad10_luad10in20_brca10x2.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #21
Source File: deep_conv_classification_alt48_only_skcm_t0.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (10000, classn), dtype = np.int32); Or = np.empty(shape = (10000, classn), dtype = np.float32); Tr = np.empty(shape = (10000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #22
Source File: deep_conv_classification_alt51_heatmap.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, y_val): val_err = 0; Pr = np.empty(shape = (1000000, classn), dtype = np.int32); Or = np.empty(shape = (1000000, classn), dtype = np.float32); Tr = np.empty(shape = (1000000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, y_val, BatchSize, shuffle = False): inputs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #23
Source File: deep_conv_classification_alt48_adeno_prad_t1_heatmap.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (1000000, classn), dtype = np.int32); Or = np.empty(shape = (1000000, classn), dtype = np.float32); Tr = np.empty(shape = (1000000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #24
Source File: deep_conv_classification_alt48_luad10in20_brca10.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #25
Source File: deep_conv_classification_alt62.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #26
Source File: deep_conv_classification_alt41.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #27
Source File: deep_conv_classification_alt48_adeno_prad_t1.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (10000, classn), dtype = np.int32); Or = np.empty(shape = (10000, classn), dtype = np.float32); Tr = np.empty(shape = (10000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #28
Source File: deep_conv_classification_alt54.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #29
Source File: deep_conv_classification_alt48_luad10_luad10in20_brca10x2.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;
Example #30
Source File: deep_conv_classification_alt38.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
def val_fn_epoch(classn, val_fn, X_val, a_val, y_val): val_err = 0; Pr = np.empty(shape = (100000, classn), dtype = np.int32); Or = np.empty(shape = (100000, classn), dtype = np.float32); Tr = np.empty(shape = (100000, classn), dtype = np.int32); val_batches = 0; nline = 0; for batch in iterate_minibatches(X_val, a_val, y_val, BatchSize, shuffle = False): inputs, augs, targets = batch; err, output = multi_win_during_val(val_fn, inputs, augs, targets); pred = from_output_to_pred(output); val_err += err; Pr[nline:nline+len(output)] = pred; Or[nline:nline+len(output)] = output; Tr[nline:nline+len(output)] = targets; val_batches += 1; nline += len(output); Pr = Pr[:nline]; Or = Or[:nline]; Tr = Tr[:nline]; val_err = val_err / val_batches; val_ham = (1 - hamming_loss(Tr, Pr)); val_acc = accuracy_score(Tr, Pr); return val_err, val_ham, val_acc, Pr, Or, Tr;