Пример #1
0
    def test_model(self):
        print "Initialize KMeansModel object"
        k = ta.KMeansModel()

        print "Initialize LogisticRegressionModel object"
        l = ta.LogisticRegressionModel()

        print "Initialize NaiveBayesModel object"
        n = ta.NaiveBayesModel()
Пример #2
0
    def test_model(self):
        print "Initialize KMeansModel object with name"
        k1 = ta.KMeansModel(name='smoke_kmeans_model')
        name = k1.name

        print "Initialize KMeansModel object"
        k2 = ta.KMeansModel()

        print "Initialize LogisticRegressionModel object with name"
        l1 = ta.LogisticRegressionModel(name='myLogisticRegressionModel1')

        print "Initialize LogisticRegressionModel object"
        l2 = ta.LogisticRegressionModel()

        print "Initialize NaiveBayesModel object"
        n = ta.NaiveBayesModel()
Пример #3
0
    def test_naive_bayes(self):
        print "define csv file"
        schema = [("Class", ta.int32), ("Dim_1", ta.int32),
                  ("Dim_2", ta.int32), ("Dim_3", ta.int32)]
        train_file = ta.CsvFile("/datasets/naivebayes_spark_data.csv",
                                schema=schema)
        print "creating the frame"
        train_frame = ta.Frame(train_file)

        print "initializing the naivebayes model"
        n = ta.NaiveBayesModel()

        print "training the model on the frame"
        n.train(train_frame, 'Class', ['Dim_1', 'Dim_2', 'Dim_3'])

        print "predicting the class using the model and the frame"
        output = n.predict(train_frame)
        self.assertEqual(
            output.column_names,
            ['Class', 'Dim_1', 'Dim_2', 'Dim_3', 'predicted_class'])