-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
2,987 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
|
Oops, something went wrong.