def __init__(self): databaseInfo = GetDatabaseInfoScholarshipsWithClassStatuses() self.actualLabels = databaseInfo.getRequirementNeededList() self.predictedLabels = databaseInfo.getEnsembleClassifierPredictions() self.actualLabels = self.convertActualLabelStringsToList() self.predictedLabels = self.convertPredictedLabelStringsToList() self.calculateExactMatchAccuracy() self.calculateNumLabelsAccuracy() print("Average Accuracy Across Labels: %.2f percent" % self.calculateAverageAccuracyWithinLists(self.actualLabels, self.predictedLabels)) self.calculateListAccuracyWithinMatchedGreaterOrLesserListLengths()
def test_CheckLabelsListFormat(self): # get the list of labels, 100 dbinfo = GetDatabaseInfoScholarshipsWithClassStatuses() listOLabels = dbinfo.getRequirementNeededList() self.assertEqual(type(listOLabels), list) self.assertEqual(type(listOLabels[1]), list) first100Labels = listOLabels[:100] self.assertEqual(len(first100Labels), 100) # get fake data X, Y = make_multilabel_classification(n_classes=10, n_labels=3, allow_unlabeled=False) # test the OVR testClassifiier = OneVsRestClassifier(LogisticRegression()) testClassifiier.fit(X, first100Labels)