Ejemplo n.º 1
0
    def test_q_calculation(self):
        dataRetriever = DataRetriever("../Datasets/metadata.json")
        dataRetriever.retrieveData("breastCancer")

        naiveBayes = NaiveBayes(dataRetriever.getDataSet(),
                                dataRetriever.getDataClass())

        #seperatedByClass = naiveBayes.calculateQ()

        #print(seperatedByClass)

        self.assertEqual(
            dataRetriever.getDataMenu(),
            ["breastCancer", "glass", "iris", "soybeanSmall", "vote"],
            "should return list of data sets")
Ejemplo n.º 2
0
 def test_menu(self):
     dataRetriever = DataRetriever("../Datasets/metadata.json")
     self.assertEqual(
         dataRetriever.getDataMenu(),
         ["breastCancer", "glass", "iris", "soybeanSmall", "vote"],
         "should return list of data sets")
Ejemplo n.º 3
0
        else:
            f += 1

    print("The Percent of Correct Predictions is {t}%".format(
        t=round((t * 100 / len(answers)), 1)))
    print("The Percent of Incorrect Predictions is {f}%\n".format(
        f=round((f * 100 / len(answers)), 1)))


dataRetriever = DataRetriever("../Datasets/metadata.json")

################################################ Un-Shuffled Data ################################################

# This first for loop performs the NaiveBayes algorithm for un-shuffled data
jsonResults1 = {}
for dataSet in dataRetriever.getDataMenu():
    dataRetriever.retrieveData(dataSet)
    dataClass = dataRetriever.getDataClass()
    retrievedData = dataRetriever.getDataSet()

    numOfClassValues = len(
        retrievedData[dataRetriever.getDataClass()].unique())
    method = "macro"
    foldNum = 1

    jsonResults1[dataSet] = {}

    print(f"PRINTING RESULTS FOR THE CONTROL DATASET {dataSet}")
    for train, test in KFolds(retrievedData, 10):

        trainBin = BinDiscretizer(