MCPcopy Create free account
hub / github.com/Mew233/pairwise / evaluator_graph

Function evaluator_graph

pairwise/dataloader.py:1412–1466  ·  view source on GitHub ↗
(model,model_weights,temp_loader_test,args)

Source from the content-addressed store, hash-verified

1410 return actuals, predictions, shap_df, features_df, expected_value
1411
1412def evaluator_graph(model,model_weights,temp_loader_test,args):
1413# For graph, the dataloader should be imported from torch geometric
1414
1415 test_dataset_drug = temp_loader_test[0]
1416 test_dataset_drug2 = temp_loader_test[1]
1417 test_dataset_cell = temp_loader_test[2].tolist()
1418 test_dataset_target = temp_loader_test[3].tolist()
1419 test_dataset_index = temp_loader_test[4].tolist()
1420
1421 test_df = [test_dataset_drug,test_dataset_drug2,test_dataset_cell,test_dataset_target,test_dataset_index]
1422 test_df = pd.DataFrame(test_df).T
1423
1424 Dataset = MyDataset
1425 test_df = Dataset(test_df)
1426
1427 test_loader = torch_geometric.data.DataLoader(test_df, batch_size=256,shuffle = False)
1428
1429 predictions, actuals = list(), list()
1430
1431 for i, data in enumerate(test_loader):
1432
1433 data1 = data[0]
1434 data2 = data[1]
1435 data_cell = data[2]
1436 data_target = data[3]
1437
1438 x1, edge_index1, x2, edge_index2, cell, batch1, batch2 \
1439 = data1.x, data1.edge_index, data2.x, data2.edge_index, data_cell, data1.batch, data2.batch
1440
1441 model.load_state_dict(torch.load(model_weights))
1442
1443 y_pred = model(x1, edge_index1, x2, edge_index2, cell, batch1, batch2)
1444 y_pred = y_pred.detach().numpy()
1445 # pick the index of the highest values
1446 #res = np.argmax(y_pred, axis = 1)
1447
1448 # actual output
1449 actual = data_target.numpy()
1450 actual = actual.reshape(len(actual), 1)
1451 # store the values in respective lists
1452 predictions.append(list(y_pred))
1453 actuals.append(list(actual))
1454
1455 actuals = [val for sublist in np.vstack(list(chain(*actuals))) for val in sublist]
1456 predictions = [val for sublist in np.vstack(list(chain(*predictions))) for val in sublist]
1457
1458
1459 if args.SHAP_analysis == True:
1460 #unimplemented
1461 pass
1462 else:
1463 shap_df = None
1464 features_df = None
1465 expected_value = None
1466 return actuals, predictions, shap_df, features_df, expected_value
1467
1468
1469def evaluator_graph_TGSynergy(model,model_weights,train_val_dataset, temp_loader_test,args):

Callers 1

evaluateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected