首页 > 解决方案 > ORA-06502: PL/SQL: 数字或值错误: 字符串缓冲区太小: 构建模型时

问题描述

我正在尝试使用 oracle SQL 构建一个朴素的贝叶斯模型。我能够构建、编译和查看分类值的结果,但是,当尝试构建混淆矩阵并查看准确性时,我收到以下错误:

Error report -
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "SYS.DBMS_DATA_MINING", line 2618
ORA-06512: at line 4
06502. 00000 -  "PL/SQL: numeric or value error%s"
*Cause:    An arithmetic, numeric, string, conversion, or constraint error
           occurred. For example, this error occurs if an attempt is made to
           assign the value NULL to a variable declared NOT NULL, or if an
           attempt is made to assign an integer larger than 99 to a variable
           declared NUMBER(2).
*Action:   Change the data, how it is manipulated, or how it is declared so
           that values do not violate constraints.

我用于构建矩阵的代码如下:

DECLARE
   v_accuracy NUMBER;
BEGIN
DBMS_DATA_MINING.COMPUTE_CONFUSION_MATRIX (
   accuracy => v_accuracy,
   apply_result_table_name => 'demo_class_nb_test_results',
   target_table_name => 'BankDataTest',
   case_id_column_name => 'ID',
   target_column_name => 'Y',
   confusion_matrix_table_name => 'demo_class_nb_confusion_matrix1',
   score_column_name => 'PREDICTED_VALUE',
   score_criterion_column_name => 'PROBABILITY',
   cost_matrix_table_name => null,
   apply_result_schema_name => null,
   target_schema_name => null,
   cost_matrix_schema_name => null,
   score_criterion_type => 'PROBABILITY');
   DBMS_OUTPUT.PUT_LINE('**** MODEL ACCURACY ****: ' || ROUND(v_accuracy,4));
END;

有人可以解释为什么我会收到这样的错误吗?

标签: sqloraclemachine-learningplsql

解决方案


我找出了这个错误的原因,这是由于使用的表名的长度confusion_matrix_table_name太长了。因此,只需减少名称长度即可。

改变: confusion_matrix_table_name => 'demo_class_nb_confusion_matrix1',

至: confusion_matrix_table_name => 'nb_confusion_matrix',


推荐阅读