-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.py
More file actions
39 lines (28 loc) · 1.09 KB
/
Copy pathdebug.py
File metadata and controls
39 lines (28 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 9 13:26:08 2018
@author: Darcane
"""
import numpy as np
from sklearn import ensemble
from loader import load_data, prepare_data
np.random.seed(42)
print("Loading data")
X_train, y_train, X_test, test_id = load_data('data/glove.twitter.27B/glove.twitter.27B.25d.txt',
'data/train_pos.txt', 'data/train_neg.txt', 'data/test_data.txt')
print("Preparing data")
X_train, y_train, X_test, test_id = prepare_data(X_train, y_train, X_test, test_id)
# let's create a SVM with fixed hyperparameters (we must tune that later on)
# clf = svm.SVC(kernel='linear', C=10)
# -> SVM are a bad choice because we have too much data
clf = ensemble.RandomForestClassifier(n_estimators=100)
# clf = LogisticRegression(C=1)
# clf = RidgeClassifier()
print("Training")
clf.fit(X_train, y_train)
print("Predicting")
prediction = clf.predict(X_test)
# np.savetxt("prediction.csv.gz", np.c_[test_id, prediction], header="Id,Prediction", comments='', delimiter=",",
# fmt="%d")
print(np.c_[test_id, prediction])