卡方检验提取特征来对文本分类

count_vect = CountVectorizer()  
X_train_counts = count_vect.fit_transform(corpus)     
tfidf_transformer = TfidfTransformer()  
X_train_tfidf = tfidf_transformer.fit_transform(X_train_counts)  
X_ch2 = SelectKBest(chi2, k=10)  
X_train_ch2 = X_ch2.fit_transform(X_train_counts, Y_train)  
  
classifier = LinearSVC().fit(X_train_ch2, Y_train)  

你可能感兴趣的:(数据挖掘,python)