ludusc commited on
Commit
2a71f28
1 Parent(s): 428f50e

revert to orig

Browse files
Files changed (1) hide show
  1. backend/disentangle_concepts.py +2 -2
backend/disentangle_concepts.py CHANGED
@@ -35,7 +35,7 @@ def get_separation_space(type_bin, annotations, df, samples=100, method='LR', C=
35
  print('Val performance SVM', svc.score(x_val, y_val))
36
  imp_features = (np.abs(svc.coef_) > 0.2).sum()
37
  imp_nodes = np.where(np.abs(svc.coef_) > 0.2)[1]
38
- return svc.coef_, imp_features, imp_nodes, np.round(clf.score(x_val, y_val),2)
39
  elif method == 'LR':
40
  clf = LogisticRegression(random_state=0, C=C)
41
  clf.fit(x_train, y_train)
@@ -145,6 +145,6 @@ def get_concepts_vectors(concepts, annotations, df, samples=100, method='LR', C=
145
  # )
146
 
147
  # projection = reducer.fit_transform(vectors)
148
- nodes_in_common = imp_nodes.intersection(*important_nodes)
149
  return vectors, nodes_in_common, performances
150
 
 
35
  print('Val performance SVM', svc.score(x_val, y_val))
36
  imp_features = (np.abs(svc.coef_) > 0.2).sum()
37
  imp_nodes = np.where(np.abs(svc.coef_) > 0.2)[1]
38
+ return svc.coef_ / np.linalg.norm(clf.coef_), imp_features, imp_nodes, np.round(clf.score(x_val, y_val),2)
39
  elif method == 'LR':
40
  clf = LogisticRegression(random_state=0, C=C)
41
  clf.fit(x_train, y_train)
 
145
  # )
146
 
147
  # projection = reducer.fit_transform(vectors)
148
+ nodes_in_common = set.intersection(*important_nodes)
149
  return vectors, nodes_in_common, performances
150