-
Notifications
You must be signed in to change notification settings - Fork 0
/
Analysis_Script.Rmd
994 lines (836 loc) · 31.5 KB
/
Analysis_Script.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
---
title: "Analysis Script - Bias in AI"
author: "Vorisek_CN"
date: "30 12 2021"
output:
html_document: default
pdf_document: default
word_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Prepare Analysis
*Load relevant libraries*
```{r}
library(readxl)
library(tidyverse)
library(writexl)
library(knitr)
library(arsenal)
library(data.table)
library(ggplot2)
library(dplyr)
library(ggplot2)
library(ggpubr)
```
*Bar theme*
colors: https://www.datanovia.com/en/blog/ggplot-colors-best-tricks-you-will-love/
```{r}
# define theme and colors for barplots
bar_theme <- theme(rect = element_blank(),
axis.ticks.y = element_line(color = "grey40"),
panel.grid.major.x = element_line(color = "grey90"))
bar_color <- "#C4961A"
bar_width <- 0.6
```
*Read in file created in "Data_Preparation.Rmd" and "Data Cleaning.Rmd"*
```{r}
analysis <- read_excel("AnalysisFile_Bias_AI.xlsx")
View(analysis)
```
# Demographics
**Prepare Data**
```{r}
analysis$arbeitsland = as.factor(analysis$arbeitsland)
analysis$geschlecht = as.factor(analysis$geschlecht)
analysis$sektor = as.factor(analysis$sektor)
analysis$quelle = as.factor(analysis$quelle)
analysis$alter = as.numeric(analysis$alter)
```
# Age group
```{r}
setDT(analysis)
```
### create category age group
```{r}
analysis[,agegroup4:= cut(alter,4,include.lowest=TRUE,
labels=c("<30","30-40","40-50",">50"))]
analysis[,table(agegroup4)]
```
***
## How did this questionnaire reach you?
```{r}
source <- analysis %>%
group_by(quelle) %>%
summarize(N = n()) %>%
mutate(Percent = N / sum(N) * 100,
Percent = round(Percent, 1)) %>%
arrange(desc(N))
source$quelle <- factor(source$quelle,levels = c(1,2,3,4,5,6), labels = c("Twitter","Linkedin","Email distribution\nlist of my institution", "Personal contact", "Other", "Not specified"))
knitr::kable(source)
```
```{r}
source_plot <- ggplot(source) + geom_col(aes(reorder(quelle, N, sum), N),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Number of Participants", title = "How did this questionnaire reach you?") +
scale_y_continuous(breaks = seq(0,100,10)) +
coord_flip() +
bar_theme
source_plot
```
## Which country do you work in?
```{r}
country <- analysis %>%
group_by(arbeitsland) %>%
summarize(N = n()) %>%
mutate(Percent = N / sum(N) * 100,
Percent = round(Percent, 1)) %>%
arrange(desc(N))
knitr::kable(country)
```
```{r}
country_plot <- ggplot(country) + geom_col(aes(reorder(arbeitsland, N, sum), N),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Number of Participants", title = "Which country do you work in?") +
scale_y_continuous(breaks = seq(0,150,25)) +
coord_flip() +
bar_theme
country_plot
```
## What is your gender?
```{r}
gender <- analysis %>%
group_by(geschlecht) %>%
summarize(N = n()) %>%
mutate(Percent = N / sum(N) * 100,
Percent = round(Percent, 1)) %>%
arrange(desc(N))
gender$geschlecht <- factor(gender$geschlecht,levels = c(1,2,3,4,5), labels = c("Female","Male","Diverse", "Undefined", "Not specified"))
knitr::kable(gender)
```
```{r}
gender_plot <- ggplot(gender) + geom_col(aes(reorder(geschlecht, N, sum), N),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Number of Participants", title = "What is your gender?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
gender_plot
```
## What is your age?
*check for normality*
```{r}
hist(analysis$alter)
summary.default(analysis$alter)
```
## Age Group
```{r}
ageGroup <- analysis %>%
group_by(agegroup4) %>%
summarize(N = n()) %>%
mutate(Percent = N / sum(N) * 100,
Percent = round(Percent, 1)) %>%
arrange(desc(N))
knitr::kable(ageGroup)
```
group by median
```{r}
analysis$agegroup2 <- as.factor(ifelse(analysis$alter <30, 1, 0))
```
```{r}
ageGroup_2 <- analysis %>%
group_by(agegroup2) %>%
summarize(N = n()) %>%
mutate(Percent = N / sum(N) * 100,
Percent = round(Percent, 1)) %>%
arrange(desc(N))
knitr::kable(ageGroup_2)
```
## In which area do you work in?
```{r}
section <- analysis %>%
group_by(sektor) %>%
summarize(N = n()) %>%
mutate(Percent = N / sum(N) * 100,
Percent = round(Percent, 1)) %>%
arrange(desc(N))
section$sektor <- factor(section$sektor,levels = c(1,2,3,4,5), labels = c("Science","Clinical Work","Industry", "Other", "Not specified"))
knitr::kable(section)
```
```{r}
ggplot(section) + geom_col(aes(reorder(sektor, N, sum), N),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Number of Participants", title = "In which area do you work in?") +
scale_y_continuous(breaks = seq(0,200,50)) +
coord_flip() +
bar_theme
```
## At what stage are you or have you been developing AI-projects?
```{r}
which(colnames(analysis) == "ki_entwicklungsphase___1")
which(colnames(analysis) == "ki_entwicklungsphase___8")
```
*create dataset*
```{r}
kiphase<-analysis %>% select(19:26)
view(kiphase)
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
kiphase_analysis <-data.frame(Freq = colSums(kiphase),
Pct.of.Resp = (colSums(kiphase)/sum(kiphase))*100,
Pct.of.Cases = (colSums(kiphase)/nrow(kiphase))*100)
rownames(kiphase_analysis) <- c("Project planning","Data acquisition/\ndata preprocessing","Data annotation","Identification\nof AI algorithms", "Training and\noptimization", "Practical testing\nof AI algorithms", "Other", "Not specified")
knitr::kable(kiphase_analysis)
```
*create bar graph*
*rownames as column*
```{r}
kiphase_analysis1 <- kiphase_analysis
kiphase_analysis1$row_names <- row.names(kiphase_analysis1)
kiphase_analysis1
```
*graph*
```{r}
ggplot(kiphase_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of participants", title = "At what stage are you or have you been\ndeveloping AI-projects??") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## In which medical specialty are you developing AI solutions?
```{r}
which(colnames(analysis) == "med_fachbereich___1")
which(colnames(analysis) == "med_fachbereich___37")
```
*create dataset*
```{r}
specialty<-analysis %>% select(28:64)
view(specialty)
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
specialty_analysis <-data.frame(Freq = colSums(specialty),
Pct.of.Resp = (colSums(specialty)/sum(specialty))*100,
Pct.of.Cases = (colSums(specialty)/nrow(specialty))*100)
knitr::kable(specialty_analysis)
```
*create bar graph*
*rownames as column*
```{r}
specialty_analysis1 <- specialty_analysis
specialty_analysis1$row_names <- row.names(specialty_analysis1)
specialty_analysis1
```
*graph*
```{r}
ggplot(specialty_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of participants", title = "In which medical specialty are you developing AI solutions?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## In which of the following areas of AI are you developing?
```{r}
which(colnames(analysis) == "ki_art___1")
which(colnames(analysis) == "ki_art___4")
```
*create dataset*
```{r}
areas<-analysis %>% select( 66:69)
view(areas)
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
areas_analysis <-data.frame(Freq = colSums(areas),
Pct.of.Resp = (colSums(areas)/sum(areas))*100,
Pct.of.Cases = (colSums(areas)/nrow(areas))*100)
```
```{r}
rownames(areas_analysis) <- c("Machine Learning","Deep Learning","Other type of AI", "Not specified")
knitr::kable(areas_analysis)
```
*create bar graph*
*rownames as column*
```{r}
areas_analysis1 <- areas_analysis
areas_analysis1$row_names <- row.names(areas_analysis1)
areas_analysis1
```
*graph*
```{r}
ggplot(areas_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of participants", title = "In which of the following areas of AI are you developing?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## Please specify the type of Machine Learning (ML) you aredeveloping:
```{r}
which(colnames(analysis) == "ki_art_ml___1")
which(colnames(analysis) == "ki_art_ml___6")
```
```{r}
ml <-analysis %>% select( 70:75)
view(ml)
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
ml_analysis <-data.frame(Freq = colSums(ml),
Pct.of.Resp = (colSums(ml)/sum(ml))*100,
Pct.of.Cases = (colSums(ml)/nrow(ml))*100)
rownames(ml_analysis) <- c("Supervised ML","Semi-supervised ML","Unsupervised ML", "Reinforcement learning", "Other", "Not specified")
knitr::kable(ml_analysis)
```
*create bar graph*
*rownames as column*
```{r}
ml_analysis1 <- ml_analysis
ml_analysis1$row_names <- row.names(ml_analysis1)
ml_analysis1
```
*graph*
```{r}
ggplot(ml_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of participants", title = "Please specify the type of Machine Learning you aredeveloping") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## Please specify the type of Deep Learning you are developing:
```{r}
which(colnames(analysis) == "ki_art_dl___1")
which(colnames(analysis) == "ki_art_dl___5")
```
```{r}
dl <-analysis %>% select( 76:80)
view(dl)
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
dl_analysis <-data.frame(Freq = colSums(dl),
Pct.of.Resp = (colSums(dl)/sum(dl))*100,
Pct.of.Cases = (colSums(dl)/nrow(dl))*100)
rownames(dl_analysis) <- c("Convolutional Networks","Recurrent neural Networks","Autoencoders", "Other", "Not specified")
knitr::kable(dl_analysis)
```
*create bar graph*
*rownames as column*
```{r}
dl_analysis1 <- dl_analysis
dl_analysis1$row_names <- row.names(dl_analysis1)
dl_analysis1
```
*graph*
```{r}
ggplot(dl_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of participants", title = "Please specify the type of Deep Learning you are developing") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## In which of the following areas of AI are you developing?
```{r}
which(colnames(analysis) == "ki_bereich___1")
which(colnames(analysis) == "ki_bereich___7")
```
```{r}
areas_2 <-analysis %>% select(81:87)
view(areas_2)
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
areas_2_analysis <-data.frame(Freq = colSums(areas_2),
Pct.of.Resp = (colSums(areas_2)/sum(areas_2))*100,
Pct.of.Cases = (colSums(areas_2)/nrow(areas_2))*100)
```
```{r}
rownames(areas_2_analysis) <- c("Natural Language Processing","Clinical Decision Support","Image processing", "Computer vision", "Robotics", "Other", "Not specified")
knitr::kable(areas_2_analysis)
```
*create bar graph*
*rownames as column*
```{r}
areas_2_analysis1 <- areas_2_analysis
areas_2_analysis1$row_names <- row.names(areas_2_analysis1)
areas_2_analysis1
```
*graph*
```{r}
ggplot(areas_2_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of participants", title = " In which of the following areas of AI are you developing?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
# Main Outcomes
## How familiar are you with biases in AI?
```{r}
familiar <- analysis %>%
group_by(bias_ki) %>%
summarize(N = n()) %>%
mutate(Percent = N / sum(N) * 100,
Percent = round(Percent, 1)) %>%
arrange(desc(N))
familiar$bias_ki <- factor(familiar$bias_ki,levels = c(1,2,3), labels = c("I have never heard of biases in AI","I have heard of biases in AI but I can not think ofconcrete examples","I have heard of biases in AI and I do know specifi cuse cases"))
knitr::kable(familiar)
```
```{r}
ggplot(familiar) + geom_col(aes(reorder(bias_ki, N, sum), N),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Number of Participants", title = "How familiar are you with biases in AI?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## Where do you think biases in AI can occur?
```{r}
which(colnames(analysis) == "bias_feld___1")
which(colnames(analysis) == "bias_feld___6")
```
```{r}
occur <-analysis %>% select(90:95)
view(occur)
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
occur_2_analysis <-data.frame(Freq = colSums(occur),
Pct.of.Resp = (colSums(occur)/sum(occur))*100,
Pct.of.Cases = (colSums(occur)/nrow(occur))*100)
```
```{r}
rownames(occur_2_analysis) <- c("Methodology \nof algorithms","Societal factors","Bias due to data\nvalidation or \ndata security", "Not specified", "Other", "None of the above")
knitr::kable(occur_2_analysis)
```
*create bar graph*
*rownames as column*
```{r}
occur_2_analysis1 <- occur_2_analysis
occur_2_analysis1$row_names <- row.names(occur_2_analysis1)
occur_2_analysis1
```
*graph*
```{r}
ggplot(occur_2_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of participants", title = "Where do you think biases in AI can occur?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## What data do you use to train AI algorithms?
```{r}
which(colnames(analysis) == "ki_trainingsdaten___1")
which(colnames(analysis) == "ki_trainingsdaten___4")
```
```{r}
train <-analysis %>% select(97:100)
view(train)
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
train_2_analysis <-data.frame(Freq = colSums(train),
Pct.of.Resp = (colSums(train)/sum(train))*100,
Pct.of.Cases = (colSums(train)/nrow(train))*100)
```
```{r}
rownames(train_2_analysis) <- c("Image data","Audio data","Text data", "Not specified")
knitr::kable(train_2_analysis)
```
*create bar graph*
*rownames as column*
```{r}
train_2_analysis1 <- train_2_analysis
train_2_analysis1$row_names <- row.names(train_2_analysis1)
train_2_analysis1
```
*graph*
```{r}
ggplot(train_2_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of respondents", title = "What data do you use to train AI algorithms?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## What is the origin of your data?
```{r}
which(colnames(analysis) == "ki_daten_quelle___1")
which(colnames(analysis) == "ki_daten_quelle___6")
```
```{r}
origin <-analysis %>% select( 101:106)
view(origin)
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
origin_2_analysis <-data.frame(Freq = colSums(origin),
Pct.of.Resp = (colSums(origin)/sum(origin))*100,
Pct.of.Cases = (colSums(origin)/nrow(origin))*100)
```
```{r}
rownames(origin_2_analysis) <- c("Wearables","Registries","Database from\none center", "Multi-center\ndatabase", "Other", "Not specified")
knitr::kable(origin_2_analysis)
```
*create bar graph*
*rownames as column*
```{r}
origin_2_analysis1 <- origin_2_analysis
origin_2_analysis1$row_names <- row.names(origin_2_analysis1)
origin_2_analysis1
```
*graph*
```{r}
ggplot(origin_2_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of respondents", title = "What is the origin of your data?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## Do you work with national or international data?
```{r}
national <- analysis %>%
group_by(nat_internat_daten) %>%
summarize(N = n()) %>%
mutate(Percent = N / sum(N) * 100,
Percent = round(Percent, 1)) %>%
arrange(desc(N))
national$nat_internat_daten <- factor(national$nat_internat_daten,levels = c(1,2,3, 4), labels = c("National data","International data","National and international data", "Not specified"))
knitr::kable(national)
```
```{r}
ggplot(national) + geom_col(aes(reorder(nat_internat_daten, N, sum), N),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Number of Participants", title = "Do you work with national or international data?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## Do you think that using standardized data (internationalsemantic and syntactic standards such as HL7 FHIR, SNOMEDCT) when training AI algorithms can prevent bias? (radio)
```{r}
standard <- analysis %>%
group_by(standard_daten) %>%
summarize(N = n()) %>%
mutate(Percent = N / sum(N) * 100,
Percent = round(Percent, 1)) %>%
arrange(desc(N))
standard$standard_daten <- factor(standard$standard_daten,levels = c(1,2,3), labels = c("Yes","No","Not specified"))
knitr::kable(standard)
```
```{r}
ggplot(standard) + geom_col(aes(reorder(standard_daten, Percent, sum), Percent),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of Participants", title = "Do you think that using standardized data\nwhen training AI algorithms can prevent bias?") +
scale_y_continuous(breaks = seq(0,100,10)) +
coord_flip() +
bar_theme
```
## Do you know any of the following preventive measures to avoid bias in AI applications?
```{r}
which(colnames(analysis) == "massnahmen_bias___1")
which(colnames(analysis) == "massnahmen_bias___6")
```
```{r}
measures <-analysis %>% select( 110:115)
view(measures)
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
measures_analysis <-data.frame(Freq = colSums(measures),
Pct.of.Resp = (colSums(measures)/sum(measures))*100,
Pct.of.Cases = (colSums(measures)/nrow(measures))*100)
```
```{r}
rownames(measures_analysis) <- c("Employ Explainable\nArtificial Intelligence (XAI)","Collecting sociodemographic\ndata points", "Statistical analysis", "Software evaluating\nfairness in AI", "I do not know\nany of them", "Other")
knitr::kable(measures_analysis)
```
*create bar graph*
*rownames as column*
```{r}
measures_analysis1 <- measures_analysis
measures_analysis1$row_names <- row.names(measures_analysis1)
measures_analysis1
```
*graph*
```{r}
ggplot(measures_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of participants", title = "Do you know any of the following preventive\nmeasures to avoid bias in AI?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## What sociodemographic data would you collect to prevent biases in AI?
```{r}
which(colnames(analysis) == "soziodem_daten___1")
which(colnames(analysis) == "soziodem_daten___7")
```
```{r}
soziodem <-analysis %>% select( 117:123)
view(soziodem)
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
soziodem_analysis <-data.frame(Freq = colSums(soziodem),
Pct.of.Resp = (colSums(soziodem)/sum(soziodem))*100,
Pct.of.Cases = (colSums(soziodem)/nrow(soziodem))*100)
```
```{r}
rownames(soziodem_analysis) <- c("Biological gender","Social gender","Age", "Origin", "Other", "None", "Not specified")
knitr::kable(soziodem_analysis)
```
*create bar graph*
*rownames as column*
```{r}
soziodem_analysis1 <- soziodem_analysis
soziodem_analysis1$row_names <- row.names(soziodem_analysis1)
soziodem_analysis1
```
*graph*
```{r}
ggplot(soziodem_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of participants", title = "What sociodemographic data would you collect to prevent biases in AI?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## What would you use the collected sociodemographic data for?
```{r}
which(colnames(analysis) == "soziodem_verwendung___1")
which(colnames(analysis) == "soziodem_verwendung___4")
```
```{r}
collect <-analysis %>% select(125:128)
view(collect)
nrow(collect)
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
collect_analysis <-data.frame(Freq = colSums(collect),
Pct.of.Resp = (colSums(collect)/sum(collect))*100,
Pct.of.Cases = (colSums(collect)/nrow(collect))*100)
```
```{r}
rownames(collect_analysis) <- c("AI modelling","Analysis","Data acquisition", "Not specified")
knitr::kable(collect_analysis)
```
*create bar graph*
*rownames as column*
```{r}
collect_analysis1 <- collect_analysis
collect_analysis1$row_names <- row.names(collect_analysis1)
collect_analysis1
```
*graph*
```{r}
ggplot(collect_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of Participants", title = "What would you use the collected sociodemographic data for?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## How would you rate the level of fairness of AI in your AI development? (radio)
```{r}
levelfair <- analysis %>%
group_by(fairness_ki) %>%
summarize(N = n()) %>%
mutate(Percent = N / sum(N) * 100,
Percent = round(Percent, 1)) %>%
arrange(desc(N))
levelfair$fairness_ki <- factor(levelfair$fairness_ki,levels = c(1,2,3,4,5,6), labels = c("Not fair at all","Barely fair","Moderately fair", "Fair", "Very fair", "Not specifi ed"))
knitr::kable(levelfair)
```
```{r}
ggplot(levelfair) + geom_col(aes(reorder(fairness_ki, Percent, sum), Percent),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Number of Participants", title = "How would you rate the level of fairness of AI in your AI development?") +
scale_y_continuous(breaks = seq(0,200,25)) +
coord_flip() +
bar_theme
```
## What do you think is preventing fair AI in your use case?
```{r}
which(colnames(analysis) == "fairness_ki_block___1")
which(colnames(analysis) == "fairness_ki_block___7")
which(colnames(analysis) == "fairness_ki")
```
```{r}
prevent <-analysis %>% select(130:136, 129)
view(prevent)
nrow(prevent)
```
*Show the fi eld ONLY if:*
*[fairness_ki_1] = '1' or [fairness_ki_1] = '2' or [fairness_ki_1] ='3' or [fairness_ki_1] = '4' or [fairness_ki_1] = '6'*
```{r}
prevent <- prevent[(prevent$fairness_ki==1 | prevent$fairness_ki==2 | prevent$fairness_ki==3 | prevent$fairness_ki==4| prevent$fairness_ki==6),]
nrow(prevent)
```
*drop column*
```{r}
prevent <- subset(prevent, select = -c(fairness_ki))
```
**Multi-response analysis**
*Pct.of.cases is the percentage of respondents who selected that particular option. You'll notice that these don't add up to 100% because people could choose more than one option.Pct.of.resp. is the percentage of responses (so not like I said in the video respondents, but responses). These do add up to 100%. *
```{r}
prevent_analysis <-data.frame(Freq = colSums(prevent),
Pct.of.Resp = (colSums(prevent)/sum(prevent))*100,
Pct.of.Cases = (colSums(prevent)/nrow(prevent))*100)
```
*Create table*
```{r}
rownames(prevent_analysis) <- c("Lack of resources","Lack of support from \nsuperiors/institution","Lack of knowledge", "Lack of fair data", "Lack of guidelines/\nrecommendations", "Other", "Not specified")
knitr::kable(prevent_analysis)
```
*create bar graph*
*rownames as column*
```{r}
prevent_analysis1 <- prevent_analysis
prevent_analysis1$row_names <- row.names(prevent_analysis1)
prevent_analysis1
```
```{r}
ggplot(prevent_analysis1) + geom_col(aes(reorder(row_names, Pct.of.Cases, sum), Pct.of.Cases),
fill = bar_color,
width = bar_width) +
labs(x = "", y = "Percentage of Participants", title = "What is preventing fair AI in your use case?") +
scale_y_continuous(breaks = seq(0,100,10)) +
coord_flip() +
bar_theme
```
***
# Subanalysis
```{r}
library(arsenal)
```
## create dataset for subanalysis
```{r}
subanalysis <-analysis %>% select(fairness_ki, geschlecht, alter, sektor, agegroup2, agegroup4)
view(subanalysis)
nrow(subanalysis)
```
```{r}
is.factor(subanalysis$geschlecht)
is.factor(subanalysis$fairness_ki)
is.factor(subanalysis$sektor)
is.factor(subanalysis$agegroup2)
is.factor(subanalysis$agegroup4)
is.numeric(subanalysis$alter)
```
```{r}
subanalysis$fairness_ki = as.factor(subanalysis$fairness_ki)
subanalysis$fairness_ki <- factor(subanalysis$fairness_ki,levels = c(1,2,3,4,5,6), labels = c("Not fair at all","Barely fair","Moderately fair", "Fair", "Very fair", "Not specified"))
subanalysis$geschlecht <- factor(subanalysis$geschlecht,levels = c(1,2,3,4), labels = c("Female","Male","Diverse", "Undefined"))
```
```{r}
library(data.table)
```
### convert to data table
```{r}
is.data.table(subanalysis) == TRUE
```
# Write File for Analysis
```{r}
write_xlsx(subanalysis, 'subanalysis.xlsx')
```
## Age Group 4
```{r}
table(subanalysis$fairness_ki, subanalysis$agegroup4)
table2 = table(subanalysis$fairness_ki, subanalysis$agegroup4)
chisq.test(table2)
chisq.test(table2)$expected
```
```{r}
round(prop.table(table2,2),2)
```
Age Group 2
```{r}
table(subanalysis$fairness_ki, subanalysis$agegroup2)
table2 = table(subanalysis$fairness_ki, subanalysis$agegroup2)
chisq.test(table2)
chisq.test(table2)$expected
```
```{r}
round(prop.table(table2,2),2)
```
## gender
```{r}
subanalysis <- subanalysis %>% drop_na(geschlecht)
nrow(subanalysis)
```
## Chi Square
```{r}
table(subanalysis$fairness_ki, subanalysis$geschlecht)
table1 = table(subanalysis$fairness_ki, subanalysis$geschlecht)
chisq.test(table1)
chisq.test(table1)$expected
```
```{r}
fisher.test(table1,conf.int = T,conf.level = 0.99)
```
###column%
```{r}
round(prop.table(table1,2),2)
```
## Sektor
subanalysis$sektor <- factor(subanalysis$sektor,levels = c(1,2,3,4,5), labels = c("Science","Clinical Work","Industry", "Other", "Not specified"))
```{r}
subanalysis_2 <- subset(subanalysis, subanalysis$sektor != 4 & subanalysis$sektor != 5)
```
```{r}
subanalysis_2$sektor <- factor(subanalysis_2$sektor,levels = c(1,2,3), labels = c("Science","Clinical Work","Industry"))
```
```{r}
table(subanalysis_2$fairness_ki, subanalysis_2$sektor)
table1 = table(subanalysis_2$fairness_ki, subanalysis_2$sektor)
chisq.test(table1)
chisq.test(table1)$expected
```
###column%
```{r}
round(prop.table(table1,2),2)
```
https://jakec007.github.io/2021-06-23-R-likert/
http://reganmian.net/blog/2013/10/02/likert-graphs-in-r-embedding-metadata-for-easier-plotting/
https://github.com/jbryer/likert/blob/master/R/likert-package.R