Skip to content

Commit fa4fbf3

Browse files
Merge pull request #3 from biomedbigdata/dscript
Dscript, early stopping, code clean up
2 parents f03a731 + aa0ecd8 commit fa4fbf3

File tree

1,420 files changed

+4922708
-934673
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,420 files changed

+4922708
-934673
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.DS_Store
22
.idea
3+
visualizations/.Rhistory
34
algorithms/DeepPPI/data/double
45
algorithms/DeepPPI/data/scripts
56
algorithms/DeepPPI/data/unique

algorithms/Custom/learn_models.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,24 @@ def learn_rf(train_features, train_labels, test_features, test_labels):
3737
# Use the forest's predict method on the test data
3838
print("Predicting ...")
3939
y_pred = rf.predict(test_features)
40-
#y_pred = np.array(np.where(y_pred > 0.5, 1, 0), dtype=int)
4140
return calculate_scores(y_true=test_labels, y_pred=y_pred)
4241

4342

4443
def learn_SVM(train_features, train_labels, test_features, test_labels):
4544
import numpy as np
4645
from sklearn.svm import SVC
47-
clf = SVC(random_state=42)
46+
from sklearn.preprocessing import StandardScaler
47+
clf = SVC(random_state=42, max_iter=1000)
48+
scaler = StandardScaler()
49+
print("Scaling feature matrix ...")
50+
train_features = scaler.fit_transform(train_features)
51+
print(f'Scaler mean for first 10 features: {scaler.mean_[:10]}')
4852
print("Fitting SVM ...")
4953
clf.fit(train_features, train_labels)
5054
print("Predicting ...")
55+
test_features = scaler.transform(test_features)
56+
print(f'Scaler mean for first 10 features: {scaler.mean_[:10]}')
5157
y_pred = clf.predict(test_features)
52-
y_pred = np.array(np.where(y_pred > 0.5, 1, 0), dtype=int)
5358
return calculate_scores(y_true=test_labels, y_pred=y_pred)
5459

5560

@@ -101,4 +106,4 @@ def _shuffle_labels(node_labels):
101106
np.random.shuffle(labels)
102107
for i in range(len(node_labels)):
103108
node_labels[node_ids[i]] = labels[i]
104-
return node_labels
109+
return node_labels
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Accuracy,0.5041115893021826
2-
Precision,0.5140162431228714
3-
Sensitivity,0.15078389179219182
4-
Specificity,0.8574392868121734
5-
F1,0.23316893457721793
6-
MCC,0.011621916515770901
1+
Accuracy,0.5074738702735936
2+
Precision,0.5237920489296636
3+
Sensitivity,0.16454042422379342
4+
Specificity,0.8504073163233938
5+
F1,0.25041667885025876
6+
MCC,0.020540312875378653
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Accuracy,0.5076467875806947
2-
Precision,0.5119533877943296
3-
Sensitivity,0.3275053796495543
4-
Specificity,0.6877881955118352
5-
F1,0.3994656917885265
6-
MCC,0.016394584234175634
1+
Accuracy,0.5045342760528743
2+
Precision,0.5046610838995101
3+
Sensitivity,0.49093144789425147
4+
Specificity,0.5181371042114971
5+
F1,0.4977015971951695
6+
MCC,0.009071910004022512
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Accuracy,0.5161197356286504
2-
Precision,0.537009263343626
3-
Sensitivity,0.23389947740547187
4-
Specificity,0.7983399938518291
5-
F1,0.32586525335260574
6-
MCC,0.03905571977237689
1+
Accuracy,0.5200776206578542
2+
Precision,0.5460149713782475
3+
Sensitivity,0.23824162311712266
4+
Specificity,0.801913618198586
5+
F1,0.33173707161775334
6+
MCC,0.04861416906086555
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Accuracy,0.5070319704887796
2-
Precision,0.5046251832381338
3-
Sensitivity,0.7672148785736244
4-
Specificity,0.24684906240393484
5-
F1,0.6088123189510597
6-
MCC,0.016469405512128284
1+
Accuracy,0.5134106978173993
2+
Precision,0.5131688174477398
3+
Sensitivity,0.522594528127882
4+
Specificity,0.5042268675069167
5+
F1,0.5178387846019115
6+
MCC,0.026825921159868885
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Accuracy,0.5092183899066443
2-
Precision,0.5226574500768049
3-
Sensitivity,0.21264794343970939
4-
Specificity,0.8057888363735791
5-
F1,0.30230169086820113
6-
MCC,0.02290002495316295
1+
Accuracy,0.5065036522010858
2+
Precision,0.5154209502639622
3+
Sensitivity,0.2173743213155736
4+
Specificity,0.7956329830865981
5+
F1,0.3057860321995714
6+
MCC,0.015943186531481014
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Accuracy,0.5441779617983673
2-
Precision,0.5326935306700584
3-
Sensitivity,0.7198156322018671
4-
Specificity,0.3685402913948674
5-
F1,0.6122767671733532
6-
MCC,0.09436991023909418
1+
Accuracy,0.5170110542556932
2+
Precision,0.5138065497891767
3+
Sensitivity,0.6330612085465411
4+
Specificity,0.40096089996484513
5+
F1,0.5672336553268935
6+
MCC,0.03497727291641971
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Accuracy,0.9546618689808445
2-
Precision,0.9097830224590788
3-
Sensitivity,0.5564610011641443
4-
Specificity,0.9944819557625145
5-
F1,0.6905518636232303
6-
MCC,0.6911697426297371
1+
Accuracy,0.9540057148904646
2+
Precision,0.8909358879882093
3+
Sensitivity,0.5629802095459837
4+
Specificity,0.9931082654249127
5+
F1,0.6899700385219004
6+
MCC,0.6870224311326519
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Accuracy,0.9490316435601651
2-
Precision,0.9107531562908141
3-
Sensitivity,0.4870779976717113
4-
Specificity,0.9952270081490104
5-
F1,0.6347087378640777
6-
MCC,0.6446875063647417
1+
Accuracy,0.7454333791935654
2+
Precision,0.16678158938114118
3+
Sensitivity,0.45052386495925495
4+
Specificity,0.7749243306169965
5+
F1,0.24344215889790524
6+
MCC,0.15057621493293957

0 commit comments

Comments
 (0)