本文整理匯總了Python中PE.processEmail方法的典型用法代碼示例。如果您正苦於以下問題:Python PE.processEmail方法的具體用法?Python PE.processEmail怎麽用?Python PE.processEmail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PE
的用法示例。
在下文中一共展示了PE.processEmail方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: email
# 需要導入模塊: import PE [as 別名]
# 或者: from PE import processEmail [as 別名]
import PE
import EF
import scipy.io as sio
import STSpam
import numpy as np
#Part One: Email Preprocessing
print 'One: =============Email Preprocessing ...'
fileContent=open('emailSample1.txt','r').read()
wordIndices=PE.processEmail(fileContent)
print wordIndices
print ' '
#Part Two: Feature Extration
print 'Two:==================Extracting features from sample email (emailSample1.txt)...'
features=EF.emailFeatures(wordIndices)
print 'Length of features vector: ',len(features)
print 'Number of non-zero entries: ',sum(features>0)
#Part Three: Train Linear SVM for Spam Classification
print 'Three: ===============Train Linear SVM for Spam Classification...'
data=sio.loadmat('spamTrain')
X=data['X']
y=data['y']
C=0.1
model=STSpam.svmTrain(X,y,C,'linear')
p=model.predict(X)
print 'Training Accuracy: %6.3f%%' % (np.mean(p == y.flatten())*100)
print ''