This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import re | |
| import string | |
| import numpy as np | |
| from sklearn.feature_extraction.text import CountVectorizer | |
| import torch | |
| from torch import nn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import division | |
| import numpy as np | |
| def mut_info(X, y): | |
| n = X.shape[0] | |
| n_11 = np.asarray(X[y].sum(axis=0)).squeeze() | |
| n_01 = np.asarray(X[~y].sum(axis=0)).squeeze() | |
| n_10 = np.asarray(y.sum() - n_11).squeeze() | |
| n_00 = np.asarray(n - n_11 - n_01 - n_10).squeeze() |