Skip to content

Commit

Permalink
fixed logic iss
Browse files Browse the repository at this point in the history
  • Loading branch information
Injiri committed Mar 22, 2019
1 parent 15ebe50 commit 90da7ef
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion logic/feature_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def word_overlap_features(headlines, bodies):
X.append(featurez)


def reguting_features(headlines, bodies):
def refuting_features(headlines, bodies):
_refuting_words = [
'fake',
'not',
Expand Down
30 changes: 28 additions & 2 deletions logic/n_kfold.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np

from sklearn.ensemble import GradientBoostingClassifier
from logic.feature_modeling import reguting_features,polarity_feature,generate_or_load_feats,hand_features
from logic.feature_modeling import refuting_features,polarity_feature,generate_or_load_feats,hand_features
from logic.feature_modeling import word_overlap_features
from util_files.datasets import Datasets
from util_files.generate_splits import kfold_split,get_stances_4_folds
Expand All @@ -18,7 +18,12 @@ def generate_features(stances, dataset, name ):
h.append(stance['Headline'])
b.append(dataset.articles[stance['Body id']])

x_overlap = generate_or_load_feats(word_overlap_features, h, b, "feaures/refuting."+name+".npy")
x_refuting = generate_or_load_feats(refuting_features, h, b, "features/refuting."+name+".npy")
x_polarity = generate_or_load_feats()

X = np.c_
return X,y

#Generate folds
if __name__ == "__main__":
Expand Down Expand Up @@ -48,9 +53,30 @@ def generate_features(stances, dataset, name ):
del ids[fold]

X_train = np.vstack(tuple([Xs[i] for i in ids]))
Y_train = np.stack(tuple(Ys[i] for i in ids))
Y_train = np.hstack(tuple([Ys[i] for i in ids]))

x_demo = Xs[fold]
Y_demo = Ys[fold]

classifier = GradientBoostingClassifier(n_estimaters=200, random_state=14128, verbose=True)
classifier.fit(X_train, Y_train)

predicted_result = [LABELS[int(n)] for n in classifier.predict(X_demo)]
actual_result = [LABELS[int(n)] for n in Y_demo ]

fold_score, _ = submit_score(actual_result, predicted_result)
max_fold_score, _ =submit_score(actual_result, actual_result);

weigthted_score = fold_score/max_fold_score

print(str(fold) + "is Fold score initialy was" + str(weigthted_score))
if weigthted_score > best_score:
best_score = weigthted_score
best_score = classifier


#report the final best_score
predicted = [LABELS[int (n)] for n in best_fold.predict(X_holdout)]
actual_result = [LABELS(int (n)) for n in Y_demo]

report_score(actual_result, predicted)

0 comments on commit 90da7ef

Please sign in to comment.