How to use the daal.algorithms.classifier.prediction function in daal

To help you get started, we’ve selected a few daal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intel / daal / examples / python / source / svm / svm_multi_class_dense_batch.py View on Github external
testData = HomogenNumericTable(nFeatures, 0, NumericTableIface.doNotAllocate)
    testGroundTruth = HomogenNumericTable(1, 0, NumericTableIface.doNotAllocate)
    mergedData = MergedNumericTable(testData, testGroundTruth)

    # Retrieve the data from input file
    testDataSource.loadDataBlock(mergedData)

    # Create an algorithm object to predict multi-class SVM values
    algorithm = multi_class_classifier.prediction.Batch(nClasses)

    algorithm.parameter.training = trainingBatch
    algorithm.parameter.prediction = predictionBatch

    # Pass a testing data set and the trained model to the algorithm
    algorithm.input.setTable(classifier.prediction.data, testData)
    algorithm.input.setModel(classifier.prediction.model,
                             trainingResult.get(classifier.training.model))

    # Predict multi-class SVM values
    # and retrieve Result class from classifier.prediction
    predictionResult = algorithm.compute()  # Retrieve the algorithm results
github intel / daal / samples / python / mpi / sources / multinomial_naive_bayes_dense_distributed_mpi.py View on Github external
def printResults():

    testGroundTruth = FileDataSource(testGroundTruthFileName,
                                     DataSourceIface.doAllocateNumericTable,
                                     DataSourceIface.doDictionaryFromContext)
    testGroundTruth.loadDataBlock()

    printNumericTables(testGroundTruth.getNumericTable(),
                       predictionResult.get(classifier.prediction.prediction),
                       "Ground truth",
                       "Classification results",
                       "NaiveBayes classification results (first 20 observations):",
                       20,
                       interval=15,
                       flt64=False)
github intel / daal / samples / python / spark / sources / spark_NaiveBayesCSR.py View on Github external
# Create algorithm objects to predict values of the Naive Bayes model with the fastCSR method
    algorithm = prediction.Batch(nClasses, method=prediction.fastCSR)

    # Pass the test data to the algorithm
    parts_list = testData.collect()
    for _, (csr, homogen) in parts_list:
        deserialized_csr = deserializeCSRNumericTable(csr)
        algorithm.input.setTable(classifier.prediction.data, deserialized_csr)

    algorithm.input.setModel(classifier.prediction.model, model)

    # Compute the prediction results
    predictionResult = algorithm.compute()

    # Retrieve the results
    return predictionResult.get(classifier.prediction.prediction)
github intel / daal / examples / python / source / svm / svm_two_class_csr_batch.py View on Github external
def testModel():
    global predictionResult

    # Create Numeric Tables for testing data
    testData = createSparseTable(testDatasetFileName)

    # Create an algorithm object to predict SVM values
    algorithm = prediction.Batch()

    algorithm.parameter.kernel = kernel

    # Pass a testing data set and the trained model to the algorithm
    algorithm.input.setTable(classifier.prediction.data, testData)

    algorithm.input.setModel(classifier.prediction.model, trainingResult.get(classifier.training.model))

    # Predict SVM values
    algorithm.compute()

    # Retrieve the algorithm results
    predictionResult = algorithm.getResult()
github intel / daal / examples / python / source / boosting / logitboost_dense_batch.py View on Github external
)

    # Create Numeric Tables for testing data and labels
    testData = HomogenNumericTable(nFeatures, 0, NumericTableIface.doNotAllocate)
    testGroundTruth = HomogenNumericTable(1, 0, NumericTableIface.doNotAllocate)
    mergedData = MergedNumericTable(testData, testGroundTruth)

    # Retrieve the data from input file
    testDataSource.loadDataBlock(mergedData)

    # Create algorithm objects for LogitBoost prediction with the default method
    algorithm = prediction.Batch(nClasses)

    # Pass the testing data set and trained model to the algorithm
    algorithm.input.setTable(classifier.prediction.data,  testData)
    algorithm.input.setModel(classifier.prediction.model, model)

    # Compute prediction results and retrieve algorithm results
    # (Result class from classifier.prediction)
    predictionResult = algorithm.compute()
github intel / daal / examples / python / source / naive_bayes / mn_naive_bayes_dense_online.py View on Github external
DataSourceIface.doDictionaryFromContext
    )

    # Create Numeric Tables for testing data and labels
    testData = HomogenNumericTable(nFeatures, 0, NumericTableIface.doNotAllocate)
    testGroundTruth = HomogenNumericTable(1, 0, NumericTableIface.doNotAllocate)
    mergedData = MergedNumericTable(testData, testGroundTruth)

    # Retrieve the data from input file
    testDataSource.loadDataBlock(mergedData)

    # Create an algorithm object to predict Naive Bayes values
    algorithm = prediction.Batch(nClasses)

    # Pass a testing data set and the trained model to the algorithm
    algorithm.input.setTable(classifier.prediction.data,  testData)
    algorithm.input.setModel(classifier.prediction.model, trainingResult.get(classifier.training.model))

    # Predict Naive Bayes values (Result class from classifier.prediction)
    predictionResult = algorithm.compute()  # Retrieve the algorithm results
github intel / daal / examples / python / source / decision_tree / dt_cls_dense_batch.py View on Github external
# Create Numeric Tables for testing data and labels
    testData = HomogenNumericTable(nFeatures, 0, NumericTableIface.notAllocate)
    testGroundTruth = HomogenNumericTable(1, 0, NumericTableIface.notAllocate)
    mergedData = MergedNumericTable(testData, testGroundTruth)

    # Retrieve the data from input file
    testDataSource.loadDataBlock(mergedData)

    # Create algorithm objects for decision tree classification prediction with the default method
    algorithm = prediction.Batch()

    # Pass the testing data set and trained model to the algorithm
    #print("Number of columns: {}".format(testData.getNumberOfColumns()))
    algorithm.input.setTable(classifier.prediction.data,  testData)
    algorithm.input.setModel(classifier.prediction.model, model)

    # Compute prediction results and retrieve algorithm results
    # (Result class from classifier.prediction)
    predictionResult = algorithm.compute()
github intel / daal / examples / python / source / svm / svm_multi_class_csr_batch.py View on Github external
def testModel():
    global predictionResult

    # Create Numeric Tables for testing data
    testData = createSparseTable(testDatasetFileName)

    # Create an algorithm object to predict multi-class SVM values
    algorithm = multi_class_classifier.prediction.Batch(nClasses)

    algorithm.parameter.training = trainingAlg
    algorithm.parameter.prediction = predictionAlg

    # Pass a testing data set and the trained model to the algorithm
    algorithm.input.setTable(classifier.prediction.data, testData)
    algorithm.input.setModel(classifier.prediction.model, trainingResult.get(classifier.training.model))

    # Predict multi-class SVM values and retrieve the algorithm results
    # (Result class from classifier.prediction)
    predictionResult = algorithm.compute()
github intel / daal / samples / python / mpi / sources / multinomial_naive_bayes_csr_distributed_mpi.py View on Github external
def testModel():
    global predictionResult

    # Retrieve the input data from a .csv file
    testDataTable = createSparseTable(testDatasetFileName)

    # Create an algorithm object to predict values of the Naive Bayes model
    algorithm = prediction.Batch(nClasses, method=prediction.fastCSR)

    # Pass a testing data set and the trained model to the algorithm
    algorithm.input.setTable(classifier.prediction.data, testDataTable)
    algorithm.input.setModel(classifier.prediction.model, trainingResult.get(classifier.training.model))

    # Predict values of the Naive Bayes model
    # Result class from classifier.prediction
    predictionResult = algorithm.compute()