这是恶性的数据。
第一列为性别,第二列为年龄,第三列为黑色素瘤的位置,第四列为诊断这是数据集
的图像%male = 1; female = 2
% head/neck = 1 upper extremity = 2 lower extremity = 3 torso = 4
% unknown = 1 nevus = 2 melanoma = 3
d = [1 45 1 1;
2 45 2 1;
2 50 3 2;
2 55 2 3;
2 50 2 3;
1 55 4 3];
c = {'benign';
'benign';
'benign';
'malignant';
'malignant';
'malignant';};
Mdl = fitcnb(d,c,'CategoricalPredictors',[1 2])
这是输出
A normal distribution cannot be fit for the combination of class malignant and predictor x4. The data has zero variance.
您必须使响应向量成为分类向量并在数据中创建一些方差:
clear;
d = [1 45 1 1;
2 45 2 1;
2 50 3 2;
2 55 2 3;
2 50 2 3;
1 55 4 4]; % Change 3 -> 4 to create variance
c = {'benign';
'benign';
'benign';
'malignant';
'malignant';
'malignant'};
X = d;
Y = [0; 0; 0; 1; 1; 1];
Y = categorical(Y, [0; 1], {'benign', 'malignant'});
Mdl = fitcnb(X, Y, 'CategoricalPredictors', [1, 2])