Skip to content

Commit

Permalink
Upload all files
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamLauz authored Jan 21, 2019
1 parent 8cf0992 commit ca7c168
Show file tree
Hide file tree
Showing 27 changed files with 2,987 additions and 0 deletions.
53 changes: 53 additions & 0 deletions BaselineModel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import numbers
import numpy as np
import sklearn

from sklearn.utils import check_X_y, check_array, column_or_1d
from sklearn.utils.multiclass import check_classification_targets

from sklearn.externals.joblib import Parallel, delayed #For parallel computing TODO: check if we need to be parallel or not
from sklearn.utils.validation import has_fit_parameter, check_is_fitted


class DecisionTreeBaseline():
"""Base class for ordinal meta-classifier.
"""

def __init__(self):
return self

def fit(self, X, y, sample_weight=None):
return self

def _fit(self, X, y, max_samples=None, max_depth=None, sample_weight=None):
return self

def predict(self, X):
X = check_array(X, accept_sparse=['csr', 'csc'])

# ---------------------------------------------Our CODE
n_samples = X.shape[0]
prediction = np.zeros((n_samples, 1))

for i in range(0, n_samples):
if X[i,"Scenario"] == "C":
if X[i,"VoterType"] == "LB":
prediction[i] = 2 #Q' vote
else:
prediction[i] = 1 #Q vote
else:
if X[i,"Scenario"] in ["E","F"]:
if X[i,"VoterType"] == "TRT":
prediction[i] = 1 #Q vote
else:
prediction[i] = 2 #Q' vote

else:
prediction[i] = 1 #Q vote


return prediction



53 changes: 53 additions & 0 deletions BayesRuleModel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import numbers
import numpy as np
import sklearn

from sklearn.utils import check_X_y, check_array, column_or_1d
from sklearn.utils.multiclass import check_classification_targets

from sklearn.externals.joblib import Parallel, \
delayed # For parallel computing TODO: check if we need to be parallel or not
from sklearn.utils.validation import has_fit_parameter, check_is_fitted


class BayesRuleClassifier():
"""Base class for ordinal meta-classifier.
"""

def __init__(self):
return self

def fit(self, X, y, sample_weight=None):
return self

def _fit(self, X, y, max_samples=None, max_depth=None, sample_weight=None):
return self

def predict(self, X):
X = check_array(X, accept_sparse=['csr', 'csc'])

# ---------------------------------------------Our CODE
n_samples = X.shape[0]
prediction = np.zeros((n_samples, 1))

for i in range(0, n_samples):
if X[i, "Scenario"] == "C":
if X[i, "VoterType"] == "LB":
prediction[i] = 2 # Q' vote
else:
prediction[i] = 1 # Q vote
else:
if X[i, "Scenario"] in ["E", "F"]:
if X[i, "VoterType"] == "TRT":
prediction[i] = 1 # Q vote
else:
prediction[i] = 2 # Q' vote

else:
prediction[i] = 1 # Q vote

return prediction



19 changes: 19 additions & 0 deletions Data/action_table_N3.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
scenario,action,action_name
1,1,TRT
1,2,DOM
1,3,DOM
2,1,TRT
2,2,DOM
2,3,DOM
3,1,TRT
3,2,WLB
3,3,DOM
4,1,TRT
4,2,DOM
4,3,SLB
5,1,TRT
5,2,CMP\WLB
5,3,DOM
6,1,TRT
6,2,CMP
6,3,SLB
97 changes: 97 additions & 0 deletions Data/action_table_N4.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
scenario,action,action_name
1,1,TRT
1,2,DOM
1,3,DOM
1,4,DOM
2,1,TRT
2,2,DOM
2,3,DOM
2,4,DOM
3,1,TRT
3,2,DOM
3,3,DOM
3,4,DOM
4,1,TRT
4,2,DOM
4,3,DOM
4,4,DOM
5,1,TRT
5,2,DOM
5,3,DOM
5,4,DOM
6,1,TRT
6,2,DOM
6,3,DOM
6,4,DOM
7,1,TRT
7,2,WLB
7,3,DOM
7,4,DOM
8,1,TRT
8,2,WLB
8,3,DOM
8,4,DOM
9,1,TRT
9,2,CMP\WLB
9,3,DOM
9,4,DOM
10,1,TRT
10,2,CMP\WLB
10,3,DOM
10,4,DOM
11,1,TRT
11,2,CMP\WLB
11,3,DOM
11,4,DOM
12,1,TRT
12,2,CMP\WLB
12,3,DOM
12,4,DOM
13,1,TRT
13,2,DOM
13,3,SLB
13,4,DOM
14,1,TRT
14,2,DOM
14,3,SLB
14,4,DOM
15,1,TRT
15,2,CMP
15,3,SLB
15,4,DOM
16,1,TRT
16,2,CMP
16,3,SLB
16,4,DOM
17,1,TRT
17,2,DOM
17,3,SLB
17,4,DOM
18,1,TRT
18,2,CMP
18,3,SLB
18,4,DOM
19,1,TRT
19,2,DOM
19,3,DOM
19,4,SLB
20,1,TRT
20,2,DOM
20,3,DOM
20,4,SLB
21,1,TRT
21,2,CMP
21,3,DOM
21,4,SLB
22,1,TRT
22,2,CMP
22,3,DOM
22,4,SLB
23,1,TRT
23,2,DOM
23,3,CMP
23,4,SLB
24,1,TRT
24,2,CMP
24,3,CMP
24,4,SLB
20 changes: 20 additions & 0 deletions Data/d32_folds.txt

Large diffs are not rendered by default.

Binary file added Data/d32_updated.xlsx
Binary file not shown.
20 changes: 20 additions & 0 deletions Data/d36_folds.txt

Large diffs are not rendered by default.

Binary file added Data/d36_updated.xlsx
Binary file not shown.
Binary file added Data/original/d32_updated.xlsx
Binary file not shown.
Binary file added Data/original/d36_updated.xlsx
Binary file not shown.
Binary file added Data/original/schram.xlsx
Binary file not shown.
Binary file added Data/original/tal.xlsx
Binary file not shown.
7 changes: 7 additions & 0 deletions Data/scenario_table_N3.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Pref1_pos,Pref2_pos,Pref3_pos,scenario,name
1,2,3,1,TRT
1,3,2,2,TRT
2,1,3,3,WLB
2,3,1,4,SLB
3,1,2,5,CMPLB
3,2,1,6,CMP
25 changes: 25 additions & 0 deletions Data/scenario_table_N4.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Pref1_pos,Pref2_pos,Pref3_pos,Pref4_pos,scenario,name
1,2,3,4,1,TRT
1,2,4,3,2,TRT
1,3,2,4,3,TRT
1,4,2,3,4,TRT
1,3,4,2,5,TRT
1,4,3,2,6,TRT
2,1,3,4,7,LB
2,1,4,3,8,LB
3,1,2,4,9,CMPLB
4,1,2,3,10,CMPLB
3,1,4,2,11,CMPLB
4,1,3,2,12,CMPLB
2,3,1,4,13,LB
2,4,1,3,14,LB
3,2,1,4,15,CMP
4,2,1,3,16,CMP
3,4,1,2,17,LB
4,3,1,2,18,CMPLB
2,3,4,1,19,LB
2,4,3,1,20,LB
3,2,4,1,21,CMP
4,2,3,1,22,CMP
3,4,2,1,23,CMP
4,3,2,1,24,CMP
Binary file added Data/schram.xlsx
Binary file not shown.
20 changes: 20 additions & 0 deletions Data/schram_folds.txt

Large diffs are not rendered by default.

Binary file added Data/tal.xlsx
Binary file not shown.
20 changes: 20 additions & 0 deletions Data/tal_folds.txt

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions LikelihoodModel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import numbers
import numpy as np
import sklearn

from sklearn.utils import check_X_y, check_array, column_or_1d
from sklearn.utils.multiclass import check_classification_targets

from sklearn.externals.joblib import Parallel, \
delayed # For parallel computing TODO: check if we need to be parallel or not
from sklearn.utils.validation import has_fit_parameter, check_is_fitted


class LHClassifier():
"""Base class for ordinal meta-classifier.
"""

def __init__(self):
return self

def fit(self, X, y, sample_weight=None):
return self

def _fit(self, X, y, max_samples=None, max_depth=None, sample_weight=None):
return self

def predict(self, X):
X = check_array(X, accept_sparse=['csr', 'csc'])

# ---------------------------------------------Our CODE
n_samples = X.shape[0]
prediction = np.zeros((n_samples, 1))

for i in range(0, n_samples):
if X[i, "Scenario"] == "C":
if X[i, "VoterType"] == "LB":
prediction[i] = 2 # Q' vote
else:
prediction[i] = 1 # Q vote
else:
if X[i, "Scenario"] in ["E", "F"]:
if X[i, "VoterType"] == "TRT":
prediction[i] = 1 # Q vote
else:
prediction[i] = 2 # Q' vote

else:
prediction[i] = 1 # Q vote

return prediction



53 changes: 53 additions & 0 deletions MaximumLikelihoodModel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import numbers
import numpy as np
import sklearn

from sklearn.utils import check_X_y, check_array, column_or_1d
from sklearn.utils.multiclass import check_classification_targets

from sklearn.externals.joblib import Parallel, \
delayed # For parallel computing TODO: check if we need to be parallel or not
from sklearn.utils.validation import has_fit_parameter, check_is_fitted


class MLHClassifier():
"""Base class for ordinal meta-classifier.
"""

def __init__(self):
return self

def fit(self, X, y, sample_weight=None):
return self

def _fit(self, X, y, max_samples=None, max_depth=None, sample_weight=None):
return self

def predict(self, X):
X = check_array(X, accept_sparse=['csr', 'csc'])

# ---------------------------------------------Our CODE
n_samples = X.shape[0]
prediction = np.zeros((n_samples, 1))

for i in range(0, n_samples):
if X[i, "Scenario"] == "C":
if X[i, "VoterType"] == "LB":
prediction[i] = 2 # Q' vote
else:
prediction[i] = 1 # Q vote
else:
if X[i, "Scenario"] in ["E", "F"]:
if X[i, "VoterType"] == "TRT":
prediction[i] = 1 # Q vote
else:
prediction[i] = 2 # Q' vote

else:
prediction[i] = 1 # Q vote

return prediction



Loading

0 comments on commit ca7c168

Please sign in to comment.