MCPcopy Create free account
hub / github.com/Persper/code-analytics / tfbns

Function tfbns

persper/classifier.py:93–106  ·  view source on GitHub ↗

Args: tfs: A sparse matrix of shape (num_samples, num_features) in csr format bns: A numpy array of shape (num_features,)

(tfs, bns)

Source from the content-addressed store, hash-verified

91 return bns
92
93def tfbns(tfs, bns):
94 """
95 Args:
96 tfs: A sparse matrix of shape (num_samples, num_features)
97 in csr format
98 bns: A numpy array of shape (num_features,)
99 """
100 cx = tfs.tocoo()
101 data, rows, cols = [], [], []
102 for i, j, v in zip(cx.row, cx.col, cx.data):
103 data.append(v * bns[j])
104 rows.append(i)
105 cols.append(j)
106 return csr_matrix((data, (rows, cols)), shape=tfs.shape)
107
108# Text Preprocessing using tfidf or bns
109class TextTransformer(BaseEstimator, TransformerMixin):

Callers 1

transformMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected