def normalize(counts): transformer = TfidfTransformer(smooth_idf=1) return transformer.fit_transform(counts).toarray()