Created
June 1, 2024 05:39
-
-
Save jgoodie/46bd67a29fe85101a0a91bd1ca2c4419 to your computer and use it in GitHub Desktop.
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
# recombine training and validation data | |
X_tv = torch.cat((X_train.cpu(), X_val.cpu())) | |
y_tv = torch.cat((y_train.cpu(), y_val.cpu())) | |
np.random.seed(101) | |
sample_weights = compute_sample_weight(class_weight='balanced',y=y_tv) | |
model = XGBClassifier() | |
model.fit(X_tv, y_tv, sample_weight=sample_weights) | |
# make predictions for test data | |
y_pred = model.predict(X_test.cpu()) | |
# evaluate predictions | |
accuracy = accuracy_score(y_test.cpu(), y_pred) | |
print("Accuracy: %.2f%%" % (accuracy * 100.0)) | |
print(confusion_matrix(y_test.cpu(), y_pred)) | |
print(classification_report(y_test.cpu(), y_pred, digits=4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment