2023年华为杯研究生数学建模竞赛E题脑卒中临床智能分析
文章目录
- 论文
- 部分Matlab代码
- 完整Word文章+源代码
论文
部分Matlab代码
#数据预处理 Matlab 代码
clc
clear all
[num,txt,raw] = xlsread('time.xlsx');
[n,m]=size(raw);
a=ones(160,1);
for i=1:160
time_vecs=datevec(string(raw(i,2)));
start_date=datenum(time_vecs);
for j=3:14
hours=-100000;
if string(raw(i,j))=="NaT'"
break ;
else
time_vec = datevec(string(raw(i,j)));
serial_date = datenum(time_vec);
hours = (serial_date - start_date) * 24;%获得日期对应时
end
if hours ~= -100000&&hours+num(i,1)<=48.00%提取 48 小时内水肿
a(i)=j-1;
else
break;
end
end
end
a
#正态分布:
clc;
clear all;
[numm,txt,raw]=xlsread('归一化后的 160 个特征数据.xlsx');
c=numm;
for k=2:32
b=numm(1:160,k)
b=b';
aa=mean(b);
sig=std(b); %算出 x 的标准偏差。
m=zeros(1,length(b));
i=1;
for t=1:length(b)
41. if m(t)>3*sig
42. n(t)=aa;%异常值使用均值代替
43. num(i)=b(t);
44. i=i+1;
45. else
46. n(t)=b(t);
47. end
48. end
49. bb=0:1:length(n)-1;
50. subplot(2,1,1);
51. plot(bb,b)
52. title('原特征数据分布')
53. subplot(2,1,2);
54. plot(bb,n);
55. c(1:100,k)=n(1:100);
56. title('拉依达准则均值处理异常点后特征数据分布')
57. xlabel('特征索引');
58. ylabel('特征数值')
59. end
60. c
61. #箱型图:
62. clc
63. clear all
64. close all
65. [num,txt,raw] = xlsread('归一化后的 160 个特征数据.xlsx');
66. x = num(1:160,2:32);
67. for i=1:31
68. y(i)='特征'+string(i);
69. end
70. figure
71. subplot(2,1,1)
72. boxplot(x, 'Labels', y,'LabelOrientation', 'inline')
73. subplot(2,1,2)
74. boxplot(x,'Labels',y,'PlotStyle','compact')
75. x1=quantile(x,.25);
76. x3=quantile(x,.75);
77. x1;
78. x3;
79. a=zeros(160,32);
80. a(1:160,1)=num(1:160,1);
81. for i=1:160
82. for j=1:31
2. clear
3. close all
4. clc
5. [num,txt,raw] = xlsread('特征数据.xlsx');
6. input=num(1:130,1:17); %载入输入数据
7. output=num(1:130,18); %载入输出数据
8. input_train = input(1:80,:)';
9. output_train =output(1:80,:)';
10. input_test = input(1:130,:)';
11. output_test =output(1:130,:)';训练预测数据
12. inputnum=2;
13. hiddennum=5;
14. outputnum=1; %节点个数
15. [inputn,inputps]=mapminmax(input_train);%归一化到[-1,1]之间,inputps
用来作下一次同样的归一化
16. [outputn,outputps]=mapminmax(output_train);
17. net=newff(inputn,outputn,hiddennum,{'tansig','purelin'},'trainlm');
% 模型建立
18. W1= net. iw{1, 1};
19. B1 = net.b{1};
20. W2 = net.lw{2,1};
21. B2 = net. b{2};各层阈值设置
22. net.trainParam.epochs=1000;
#K-means 三维聚类 Matlab 代码
clc;
clear all;
[num,txt,raw] = xlsread('聚类 1.xlsx');
x = num(1:160,1);
y = num(1:160,2);
z = num(1:160,3);
x=x';
y=y';
z=z';
k = 5;
[resX resY resZ record] = Kmean3D(x,y,z,k);%聚类
for i = 1:length(record)
14. scatter3(resX(i,1:record(i)),resY(i,1:record(i)),resZ(i,1:rec ord(i)),'*','LineWidth',1);
hold on
end
xlabel('年龄');
ylabel('收缩压/mmHg');
zlabel('舒张压/mmHg');
set(gca,'FontSize',18);
for i = 1:length(record)
22. scatter3(mean(resX(i,1:record(i)),2)',mean(resY(i,1:record(i)
,2)',mean(resZ(i,1:record(i)),2)','Marker','square','MarkerEdgeColor','k','
MarkerFaceColor','k')
end
legend('聚类 1','聚类 2','聚类 3','聚类 4','聚类 5','聚类中心点')
完整Word文章+源代码
关注下方名片