Intel® oneAPI Data Analytics Library
Learn from community members on how to build compute-intensive applications that run efficiently on Intel® architecture.
224 Discussions

SVM: SystemError: Model is not full initialized

Ryo_A_
Beginner
579 Views

Hello,

I am trying to use the pyDAAL SVM to do binary classification, but I keep running into an system error at the prediction compute().

I wrote a small reproducer for the issue I was seeing on my original code:

import numpy as np                                                                                                                        
from daal.data_management import HomogenNumericTable                                                                                      
from daal.algorithms.svm import training, prediction                                                                                      
from daal.algorithms import kernel_function, classifier                                                                                   
import daal.algorithms.kernel_function.rbf                                                                                                
import daal.algorithms.classifier.training                                                                                                
import daal.algorithms.classifier.prediction                                                                                              
                                                                                                                                          
trn_X = HomogenNumericTable(np.random.randn(3000,10))                                                                                     
trn_Y = HomogenNumericTable(np.random.randn(3000,1))                                                                                      
tst_X = HomogenNumericTable(np.random.randn(1000,10))                                                                                     
                                                                                                                                          
kernel = kernel_function.rbf.Batch()                                                                                                      
                                                                                                                                          
trainer = training.Batch()                                                                                                                
trainer.parameter.kernel =  kernel                                                                                                        
trainer.parameter.C =  1.0                                                                                                                
trainer.parameter.gamma = 0.001                                                                                                           
trainer.input.set(classifier.training.data,   trn_X)                                                                                      
trainer.input.set(classifier.training.labels, trn_Y)                                                                                      
trn_res = trainer.compute()                                                                                                               
                                                                                                                                          
predictor = prediction.Batch()                                                                                                            
predictor.parameter.kernel = kernel                                                                                                       
predictor.input.setTable(classifier.prediction.data,  tst_X)                                                                              
predictor.input.setModel(classifier.prediction.model, trn_res.get(classifier.training.model))                                             
predictor.compute()                      

And running this reproducer gives me this error:

Traceback (most recent call last):                                                                                                        
  File "svm-reproducer.py", line 27, in <module>                                                                                          
    predictor.compute()                                                                                                                   
  File "/opt/intel/intelpython_update_3/intelpython2/lib/python2.7/site-packages/daal/algorithms/svm/prediction.py", line 185, in compute 
    return _prediction12.Batch_Float64DefaultDense_compute(self)                                                                          
SystemError: Model is not full initialized                                                                                                
Details:                                                                                                                                  
Argument name: supportVectors

Is there something else that I am missing? I took a look at the example directory, and the online github examples, but I could not figure out what the step I am missing is. As shown in the error, I am using 2017 update 3 pyDAAL.

Thanks in advance,
Ryo Asai

0 Kudos
2 Replies
VictoriyaS_F_Intel
579 Views

Hello Ryo,

In your example SVM model is not trained due to incorrect values of the class labels.

trn_Y numeric table should contain values {-1, 1} as specified in the DAAL Developer Guide, "Support Vector Machine Classifier > Details":

“Given n feature vectors x 1= (x 11,…,x 1p ), ..., x n = (x n1,…,x np ) of size p and a vector of class labels y = (y 1,…,y n ), where y i ∈ {-1,1} describes the class to which the feature vector x i belongs”.

The library does not check the content input data for validity as scanning the whole numeric tables will affect the performance of the computations.The library’s documentation such as Intel DAAL Developer Guide specifies the requirements to the parameters of the algorithms and their representation.

0 Kudos
Ryo_A_
Beginner
579 Views

Ah I see. I was able to train the model for both the code snippet and the original code.

Thank you so much for your help!

Ryo

0 Kudos
Reply