Skip to content

Commit

Permalink
no more panels
Browse files Browse the repository at this point in the history
  • Loading branch information
jlherzberg committed Jul 18, 2018
1 parent 9e58d7a commit 107e5b1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/tagnews/crimetype/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ def get_contributions(self, text):
and -0.316201
. -0.853208
"""
p = {}
vec = self.vectorizer.transform([text])
vec_inv = self.vectorizer.inverse_transform(vec)
for i, tag in enumerate(TAGS):
p[tag] = pd.DataFrame(
index=vec_inv,
data={'weight': self.clf.coef_[i, vec.nonzero()[1]]}
)
return pd.Panel(p)
vec_inv = self.vectorizer.inverse_transform(vec)[1]

df = pd.DataFrame(columns=vec_inv, index=TAGS)

for j, word in enumerate(vec_inv):
for i, tag in enumerate(TAGS):
df.loc[tag][word] = mod.clf.coef_[i, vec.nonzero()[1][j]]
return df

0 comments on commit 107e5b1

Please sign in to comment.