Created
October 8, 2020 20:11
-
-
Save 3catz/a98e45e719cf4957c659387d49a24292 to your computer and use it in GitHub Desktop.
repeated_SMOTE
This file contains hidden or 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
| oversampler = MulticlassOversampling(sv.TRIM_SMOTE(proportion = 0.1)) | |
| warnings.filterwarnings("ignore") | |
| Scores1 = [] | |
| cmatrices1 = [] | |
| cmatrices2 = [] | |
| Scores2 = [] | |
| for i in range(50): | |
| print("Trial {}".format(i)) | |
| print("-----------------------------") | |
| scores1 = [] | |
| scores2 = [] | |
| trainx, valx, trainy, valy = train_test_split(X.values, Y.values, test_size = 0.25, | |
| shuffle = True, | |
| stratify = Y.values, | |
| random_state = i) | |
| reg = LogisticRegression() | |
| reg.fit(trainx, trainy) | |
| s = matthews_corrcoef(valy, reg.predict(valx)) | |
| Scores1.append(s) | |
| cmatrices1.append(confusion_matrix(valy, reg.predict(valx))) | |
| trainx2, trainy2 = oversampler.sample(trainx, trainy) | |
| reg2 = LogisticRegression() | |
| reg2.fit(trainx2, trainy2) | |
| s = matthews_corrcoef(valy, reg2.predict(valx)) | |
| Scores2.append(s) | |
| cmatrices2.append(confusion_matrix(valy, reg2.predict(valx))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment