# #!/usr/bin/env python
# # -*- coding: utf-8 -*-
#
# '''
# Created on 26 Jul 2019
#
# @author: Ajay
# '''
#
from pp_final import preprocessor
from sklearn.naive_bayes import MultinomialNB
#GOAL=0.74

pp = preprocessor("sentiment", "mysentiment")

clf = MultinomialNB(alpha=1.1)
model = clf.fit(pp.X_train, pp.y_train)

predicted_y = model.predict(pp.X_test)
i = pp.divider
for y in predicted_y:
    print(pp.instance_array[i], y)
    i = i + 1
# i = 0
# for sentence in test_array:
#     test = count.transform([sentence]).toarray()
#     print(instance_array[i], model.predict(test))
#     i = i + 1

# text_data = np.array(test_array)
# bag_of_words = count.fit_transform(text_data)
# #!/usr/bin/env python
# # -*- coding: utf-8 -*-
#
# '''
# Created on 26 Jul 2019
#
# @author: Ajay
# '''
#
from pp_final import preprocessor
from sklearn.naive_bayes import MultinomialNB
#
pp = preprocessor("topic", "mnb")
clf = MultinomialNB()
model = clf.fit(pp.X_train, pp.y_train)

predicted_y = model.predict(pp.X_test)
i = pp.divider
for y in predicted_y:
    print(pp.instance_array[i], y)
    i = i + 1
# #!/usr/bin/env python
# # -*- coding: utf-8 -*-
#
# '''
# Created on 26 Jul 2019
#
# @author: Ajay
# '''
#
from pp_final import preprocessor
from sklearn import tree

pp = preprocessor("sentiment", "dt")
clf = tree.DecisionTreeClassifier(criterion='entropy',
                                  random_state=0,
                                  min_samples_leaf=20)
model = clf.fit(pp.X_train, pp.y_train)

predicted_y = model.predict(pp.X_test)
i = pp.divider
for y in predicted_y:
    print(pp.instance_array[i], y)
    i = i + 1
#
Esempio n. 4
0
# #!/usr/bin/env python
# # -*- coding: utf-8 -*-
#
# '''
# Created on 26 Jul 2019
#
# @author: Ajay
# '''
#
from pp_final import preprocessor
from sklearn.naive_bayes import MultinomialNB
#GOAL=0.74

pp = preprocessor("topic", "mytopic")

clf = MultinomialNB(alpha=.77)
model = clf.fit(pp.X_train, pp.y_train)

predicted_y = model.predict(pp.X_test)
i = pp.divider
for y in predicted_y:
    print(pp.instance_array[i], y)
    i = i + 1
#
# #!/usr/bin/env python
# # -*- coding: utf-8 -*-
# 
# '''
# Created on 26 Jul 2019
# 
# @author: Ajay
# '''
# 
from pp_final import preprocessor
from sklearn.naive_bayes import BernoulliNB

pp = preprocessor("sentiment", "bnb")
clf = BernoulliNB()
model = clf.fit(pp.X_train, pp.y_train)

predicted_y = model.predict(pp.X_test)
i = pp.divider
for y in predicted_y:
    print(pp.instance_array[i], y)
    i = i + 1
#
# #!/usr/bin/env python
# # -*- coding: utf-8 -*-
#
# '''
# Created on 26 Jul 2019
#
# @author: Ajay
# '''
#
from pp_final import preprocessor
from sklearn import tree

pp = preprocessor("topic", "dt")
clf = tree.DecisionTreeClassifier(criterion='entropy',
                                  random_state=0,
                                  min_samples_leaf=20)
model = clf.fit(pp.X_train, pp.y_train)

predicted_y = model.predict(pp.X_test)
i = pp.divider
for y in predicted_y:
    print(pp.instance_array[i], y)
    i = i + 1
#