Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old version test merge #10

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions code/classification/run_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

import argparse, pickle
from sklearn.dummy import DummyClassifier

from sklearn.metrics import accuracy_score, cohen_kappa_score
from sklearn.preprocessing import StandardScaler
from sklearn.neighbors import KNeighborsClassifier
from sklearn.pipeline import make_pipeline
from mlflow import log_metric, log_param, set_tracking_uri


# setting up CLI
parser = argparse.ArgumentParser(description = "Classifier")
parser.add_argument("input_file", help = "path to the input pickle file")
Expand All @@ -26,8 +28,12 @@
parser.add_argument("-f", "--frequency", action = "store_true", help = "label frequency classifier")
parser.add_argument("--knn", type = int, help = "k nearest neighbor classifier with the specified value of k", default = None)
parser.add_argument("-a", "--accuracy", action = "store_true", help = "evaluate using accuracy")



parser.add_argument("-k", "--kappa", action = "store_true", help = "evaluate using Cohen's kappa")
parser.add_argument("--log_folder", help = "where to log the mlflow results", default = "data/classification/mlflow")

args = parser.parse_args()

# load data
Expand Down Expand Up @@ -83,9 +89,17 @@
evaluation_metrics = []
if args.accuracy:
evaluation_metrics.append(("accuracy", accuracy_score))

if args.area:
evaluation_metrics.append(("area_under_curve", roc_auc_score))

if args.cohen:
evaluation_metrics.append(("cohen", cohen_kappa_score))
=======
if args.kappa:
evaluation_metrics.append(("Cohen_kappa", cohen_kappa_score))


# compute and print them
for metric_name, metric in evaluation_metrics:
metric_value = metric(data["labels"], prediction)
Expand Down