qlik-py-tools
qlik-py-tools copied to clipboard
Error at getting performance metrics with multiclass classifier
Currently having an issue while trying to replicate one of the sample apps (Sample App scikit-learn - K-fold Cross Validation). Basically everything i did was loading IRIS dataset to Qlik following step by step instructions in the repo, however in the Train & test section i get the following error:
'Exception iterating responses: Target is multiclass but average='binary'. Please choose another average setting, one of [None, 'micro', 'macro', 'weighted'].'
This error comes out due to the scoring metric in GridSearchCV and when trying to compute performance scores like Precision or F1-score over a multiclass classification problem, how can i set the 'average' argument straight from Qlik?
Hi @statscol , you can specify the metric arguments when setting up the model. You will need to use the PyTools.sklearn_Setup_Adv
function which allows for additional inputs. You can input empty string, i.e. '', for unnecessary parameters like DimReductionArgs
.
// Set up a temporary table for the model parameters
[MODEL_INIT]:
LOAD
[Model Name] as Model_Name,
'' as EstimatorArgs,
'' as ScalerArgs,
'average=micro|str' as MetricArgs,
'' as DimReductionArgs,
'overwrite=true,cv=5,calculate_importances=true' as ExecutionArgs
RESIDENT Estimators
WHERE [Model Name] = '$(vModel)';
[Result-Setup]:
LOAD
model_name,
result,
timestamp
EXTENSION PyTools.sklearn_Setup_Adv(MODEL_INIT{Model_Name, EstimatorArgs, ScalerArgs, MetricArgs, DimReductionArgs, ExecutionArgs});
The input specifications for the metrics arguments are described here. If you just want to change the average parameter the argument would be average=micro|str
or average=macro|str
.
Unfortunately, there is a bit of an oversight in the code and you can't pass average=None at the moment as I thought that would always be the default. I will fix this in the next release.