Commit c46592cac8c3c0f672971ca6c7ae8f8eb23c5c56
1 parent
9e86b051b4
Exists in
master
Deleted nbi snippet file
Showing
1 changed file
with
0 additions
and
79 deletions
Show diff stats
RepTB_NBI_Algorithm_Snippet.ipynb
... | ... | @@ -1,79 +0,0 @@ |
1 | -{ | |
2 | - "cells": [ | |
3 | - { | |
4 | - "cell_type": "code", | |
5 | - "execution_count": null, | |
6 | - "metadata": { | |
7 | - "collapsed": true | |
8 | - }, | |
9 | - "outputs": [], | |
10 | - "source": [ | |
11 | - "import numpy as np\n", | |
12 | - "import csv\n", | |
13 | - "import numpy.matlib\n", | |
14 | - "from operator import itemgetter, attrgetter\n", | |
15 | - "from sklearn.model_selection import KFold\n", | |
16 | - "from sklearn.metrics import roc_curve, auc\n", | |
17 | - "import matplotlib.pyplot as plt" | |
18 | - ] | |
19 | - }, | |
20 | - { | |
21 | - "cell_type": "code", | |
22 | - "execution_count": null, | |
23 | - "metadata": { | |
24 | - "collapsed": true | |
25 | - }, | |
26 | - "outputs": [], | |
27 | - "source": [ | |
28 | - "#NBI calculation for A (adjacent matrix)\n", | |
29 | - "\n", | |
30 | - "K = np.diag((1/sum(A))) # Create a diagonal matrix \n", | |
31 | - "n = A.shape[0] # Number of rows of adjacent martix A\n", | |
32 | - "m = A.shape[1] # Number of columns in adjacent matrix A\n", | |
33 | - "#print n, m, Ky.shape\n", | |
34 | - "K[np.isinf(K) | np.isnan(K)] = 0\n", | |
35 | - "kk = np.transpose(np.sum(A,1))\n", | |
36 | - "#print kx.shape\n", | |
37 | - "N = np.matlib.repmat(1/kk,n,1)\n", | |
38 | - "N[np.isinf(N) | np.isnan(N)] = 0\n", | |
39 | - "#kx[np.isinf(kx) | np.isnan(kx)] = 0\n", | |
40 | - "W = np.transpose(np.dot(A, K)) # Create the weight matrix \n", | |
41 | - "W1 = np.dot(A, W)\n", | |
42 | - "W2 = np.multiply(N, W1) # Create the scaled up weight matrix\n", | |
43 | - "print W2.shape\n", | |
44 | - "NBIscore = np.dot(W2, A) # Create the Final Resource matrix in accordance with (R = W.A)\n", | |
45 | - "print NBIscore.shape" | |
46 | - ] | |
47 | - }, | |
48 | - { | |
49 | - "cell_type": "code", | |
50 | - "execution_count": null, | |
51 | - "metadata": { | |
52 | - "collapsed": true | |
53 | - }, | |
54 | - "outputs": [], | |
55 | - "source": [] | |
56 | - } | |
57 | - ], | |
58 | - "metadata": { | |
59 | - "kernelspec": { | |
60 | - "display_name": "Python 2", | |
61 | - "language": "python", | |
62 | - "name": "python2" | |
63 | - }, | |
64 | - "language_info": { | |
65 | - "codemirror_mode": { | |
66 | - "name": "ipython", | |
67 | - "version": 2 | |
68 | - }, | |
69 | - "file_extension": ".py", | |
70 | - "mimetype": "text/x-python", | |
71 | - "name": "python", | |
72 | - "nbconvert_exporter": "python", | |
73 | - "pygments_lexer": "ipython2", | |
74 | - "version": "2.7.6" | |
75 | - } | |
76 | - }, | |
77 | - "nbformat": 4, | |
78 | - "nbformat_minor": 2 | |
79 | -} |