def main():
	f = open("me.stdout", "r").read()

	print f
	
	(confusionMatrix, labels, ytrue, ypred, trueCount) = readConfusionMatrix.readText(f)
	for row in confusionMatrix:
		print row

	precisionMicro = np.float(metrics.precision_score(ytrue, ypred, average="micro"))
	recallMicro = np.float(metrics.recall_score(ytrue, ypred, average="micro"))
	f1Micro = np.float(metrics.f1_score(ytrue, ypred, average="micro"))
	f1Macro = np.float(metrics.f1_score(ytrue, ypred, pos_label=1, average="macro"))
	precisionMacro = np.float(metrics.precision_score(ytrue, ypred, average="macro"))
	recallMacro = np.float(metrics.recall_score(ytrue, ypred, average="macro"))

	mConf = metrics.confusion_matrix(ytrue, ypred)
	print mConf

	print labels
	print len(ytrue)
	print len(ypred)
	print trueCount

	print metrics.accuracy_score(ytrue, ypred)

	print precisionMicro
	print recallMicro
	print f1Micro
	print f1Macro
	print precisionMacro
	print recallMacro
def readAndUploadClassifierOutput(featureSet, diseaseFolder, disease, connection, source):
	text = open(diseaseFolder + "/me.stdout", "r").read()

	(confusionMatrix, confusionLabelDict, y_truth, y_pred, trueCount) = readConfusionMatrix.readText(text)

	precisionMicro = np.float(metrics.precision_score(y_truth, y_pred, average="micro"))
	recallMicro = np.float(metrics.recall_score(y_truth, y_pred, average="micro"))
	f1Micro = np.float(metrics.f1_score(y_truth, y_pred, average="micro"))
	f1Macro = np.float(metrics.f1_score(y_truth, y_pred, average="macro"))
	precisionMacro = np.float(metrics.precision_score(y_truth, y_pred, average="macro"))
	recallMacro = np.float(metrics.recall_score(y_truth, y_pred, average="macro"))
	accuracy = np.float(metrics.accuracy_score(y_truth, y_pred))

	insertResult.insertClassifierResults(connection, (featureSet, "maxent", trueCount, disease, precisionMicro, recallMicro, f1Micro, recallMacro, precisionMacro, f1Macro, source, accuracy))
def readAndUploadClassifierOutput(featureSet, diseaseFolder, disease,
                                  connection, source):
    text = open(diseaseFolder + "/me.stdout", "r").read()

    (confusionMatrix, confusionLabelDict, y_truth, y_pred,
     trueCount) = readConfusionMatrix.readText(text)

    precisionMicro = np.float(
        metrics.precision_score(y_truth, y_pred, average="micro"))
    recallMicro = np.float(
        metrics.recall_score(y_truth, y_pred, average="micro"))
    f1Micro = np.float(metrics.f1_score(y_truth, y_pred, average="micro"))
    f1Macro = np.float(metrics.f1_score(y_truth, y_pred, average="macro"))
    precisionMacro = np.float(
        metrics.precision_score(y_truth, y_pred, average="macro"))
    recallMacro = np.float(
        metrics.recall_score(y_truth, y_pred, average="macro"))
    accuracy = np.float(metrics.accuracy_score(y_truth, y_pred))

    insertResult.insertClassifierResults(
        connection,
        (featureSet, "maxent", trueCount, disease, precisionMicro, recallMicro,
         f1Micro, recallMacro, precisionMacro, f1Macro, source, accuracy))
Ejemplo n.º 4
0
def main():
    f = open("me.stdout", "r").read()

    print f

    (confusionMatrix, labels, ytrue, ypred,
     trueCount) = readConfusionMatrix.readText(f)
    for row in confusionMatrix:
        print row

    precisionMicro = np.float(
        metrics.precision_score(ytrue, ypred, average="micro"))
    recallMicro = np.float(metrics.recall_score(ytrue, ypred, average="micro"))
    f1Micro = np.float(metrics.f1_score(ytrue, ypred, average="micro"))
    f1Macro = np.float(
        metrics.f1_score(ytrue, ypred, pos_label=1, average="macro"))
    precisionMacro = np.float(
        metrics.precision_score(ytrue, ypred, average="macro"))
    recallMacro = np.float(metrics.recall_score(ytrue, ypred, average="macro"))

    mConf = metrics.confusion_matrix(ytrue, ypred)
    print mConf

    print labels
    print len(ytrue)
    print len(ypred)
    print trueCount

    print metrics.accuracy_score(ytrue, ypred)

    print precisionMicro
    print recallMicro
    print f1Micro
    print f1Macro
    print precisionMacro
    print recallMacro