def feature_selection(documents=[], top=None, method=CHISQUARED, threshold=0.0):
 a = []
 for d in documents:
  if (not isinstance(d, Document)):
   d = Document(d[0], type=d[1], stopwords=True)
  a.append(d)
 m = Model(a, weight=None)
 p = m.posterior_probability
 c = m.classes
 for (w, f) in m.feature_selection(top, method, threshold, weighted=True):
  (yield (f, w, max([(p(f, type), type) for type in c])))

def feature_selection ( documents = [ ] , top = None , method = CHISQUARED , threshold = 0.0 ) : a = [ ] for d in documents : if ( not isinstance ( d , Document ) ) : d = Document ( d [ 0 ] , type = d [ 1 ] , stopwords = True ) a . append ( d ) m = Model ( a , weight = None ) p = m . posterior_probability c = m . classes for ( w , f ) in m . feature_selection ( top , method , threshold , weighted = True ) : ( yield ( f , w , max ( [ ( p ( f , type ) , type ) for type in c ] ) ) )
returns an iterator of (feature .