Esempio n. 1
0
 def __init__(self):
     self.pos_tagger = SequentialTagger()
     self.hp_obj = HpObj(debug=DEBUG)
     self.hp_subj = HpSubj(debug=DEBUG)
     self.lexicon = self.hp_obj.lexicon
     self.bootstrapping = Bootstrapping(self.hp_obj, self.hp_subj, self.pos_tagger, debug=DEBUG) 
     self.sentence_tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
     self.total_sentences = ["good","bad"]
     self.total_sentiments = ["positive","negative"]
Esempio n. 2
0
pp=Probcpredict(q,mu_pos,mu_neg,sigma2_pos,sigma2_neg, z)
nn=Nearestneighbor(X,y,z)
print("Predict result of probcpredict:",pp.probcpredict())
print("Predict result of nearestneighbor:",nn.nearestneighbor())

#case 4_1

np.set_printoptions(precision=4)
X = np.array([[-3, 2],
[-2, 1.5],
[-1, 1],
[0, 0.5],
[1, 0],
[2, 2],
[-0.5, -1],
[0.5, 0]])
y = np.array([[1], [-1], [1], [-1], [1], [-1], [1], [-1]])
kf=Kfoldcv(2,X,y)
print("When k equals to 2, the accuracy of kfold is:",kf.kfoldcv())
bs=Bootstrapping(5,X,y)
np.random.seed(26)
print("When B equals to 5, the accuracy of bootstrapping is:",bs.bootstrapping())

# for Hypotest
a = np.array([[0.09],[0.08],[0.15],[0.11],[0.13]])
b = np.array([[0.10],[0.12],[0.14],[0.13],[0.13]])
ht=Hypotest(a,b,0.05)
print("When alpha equals to 0.05, the result of hypotest is:",ht.hypotest())