{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# AI, Ethical\n### *2 years of insight into AI Ethics from the Machine Learning Community*","metadata":{}},{"cell_type":"code","source":"# The Libraries\n\n# For Data\nimport pandas as pd\nimport json\n\n# For Studying the Data\nimport nltk\nfrom nltk.tokenize import RegexpTokenizer\nfrom nltk.stem import PorterStemmer\nfrom nltk.corpus import stopwords\n\n# For Visuals\nimport plotly.express as px\n\n# To Clean Up the Notebook\nimport warnings\nwarnings.filterwarnings('ignore')","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:43:46.785975Z","iopub.execute_input":"2023-07-16T13:43:46.786798Z","iopub.status.idle":"2023-07-16T13:43:50.053744Z","shell.execute_reply.started":"2023-07-16T13:43:46.786753Z","shell.execute_reply":"2023-07-16T13:43:50.052627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Obtaining the Arxiv Metadata\narxiv_link = '/kaggle/input/2023-kaggle-ai-report/arxiv_metadata_20230510.json'\narxiv_metadata_list = []\n\nwith open(arxiv_link, 'r') as arxiv_json:\n    for line in arxiv_json:\n        arxiv_metadata_list.append(json.loads(line))\n\narxiv_metadata = pd.DataFrame(arxiv_metadata_list)\narxiv_metadata['update_date'] = pd.to_datetime(arxiv_metadata.update_date)\n\n# Eliminating some columns\nreduced_columns = ['authors', 'title', 'update_date', \n                   'abstract', 'categories', 'license']\narxiv_metadata = pd.DataFrame(arxiv_metadata, \n                               columns = reduced_columns).sort_values(by = 'update_date', \n                                                                      ascending = False)\n\n# Focusing on the relevant topic and time period. \n    # AI appeared to be the most relevant category, but additional sources were found.\narxiv_focused = arxiv_metadata.loc[(arxiv_metadata.update_date >= '2021-05-11') &\n                                   ((arxiv_metadata.categories == \"cs.AI\")|\n                                    (arxiv_metadata.categories == \"cs.CY\")|\n                                    (arxiv_metadata.categories == \"cs.HC\")|\n                                    (arxiv_metadata.categories == \"cs.RO\")|\n                                    (arxiv_metadata.categories == \"cs.LG\")|\n                                    (arxiv_metadata.categories == \"cs.SI\"))]\n\n# Focusing on research into ethics\narxiv_ethics = arxiv_focused.loc[arxiv_focused['title'].str.contains(\"ethics\")|\n                                 arxiv_focused['abstract'].str.contains(\"ethics\")|\n                                 arxiv_focused['title'].str.contains(\"ethical\")|\n                                 arxiv_focused['abstract'].str.contains(\"ethical\")|\n                                 arxiv_focused['title'].str.contains(\"ethically\")|\n                                 arxiv_focused['abstract'].str.contains(\"ethically\")|\n                                 arxiv_focused['title'].str.contains(\"fair\")|\n                                 arxiv_focused['abstract'].str.contains(\"fair\")|\n                                 arxiv_focused['title'].str.contains(\"fairness\")|\n                                 arxiv_focused['abstract'].str.contains(\"fairness\")]","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:43:50.055784Z","iopub.execute_input":"2023-07-16T13:43:50.056916Z","iopub.status.idle":"2023-07-16T13:46:33.611399Z","shell.execute_reply.started":"2023-07-16T13:43:50.056871Z","shell.execute_reply":"2023-07-16T13:46:33.609920Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Obtaining the Kaggle Writeups\nwriteups_filepath = '/kaggle/input/2023-kaggle-ai-report/kaggle_writeups_20230510.csv'\nkaggle_writeups = pd.read_csv(writeups_filepath)\n\n# Focusing on the relevant time period\nkaggle_writeups['Date of Writeup'] = pd.to_datetime(kaggle_writeups['Date of Writeup'])\nkaggle_writeups = kaggle_writeups.loc[kaggle_writeups['Date of Writeup'] >= '2021-05-11']","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:46:33.613040Z","iopub.execute_input":"2023-07-16T13:46:33.613422Z","iopub.status.idle":"2023-07-16T13:46:34.452423Z","shell.execute_reply.started":"2023-07-16T13:46:33.613390Z","shell.execute_reply":"2023-07-16T13:46:34.451057Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Obtaining Kaggle Survey Data\nkaggle_survey = pd.read_csv('/kaggle/input/kaggle-survey-2017/multipleChoiceResponses.csv', \n                            encoding = 'latin-1')\n\n# Cleaning the data: I struggle to believe infants and toddlers are coding on Kaggle.\n# A 6 year old might be brought by family to learn, \n    ## but these 2 are employed full time/retired.\nkaggle_survey = kaggle_survey.loc[kaggle_survey.Age >= 7]","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:46:34.455625Z","iopub.execute_input":"2023-07-16T13:46:34.456106Z","iopub.status.idle":"2023-07-16T13:46:35.510797Z","shell.execute_reply.started":"2023-07-16T13:46:34.456063Z","shell.execute_reply":"2023-07-16T13:46:35.509606Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Introduction\n### The Paradigm Shift\nAt this new moment, the world appears to be in the midst of a major paradigm shift, a change in our collective worldview and way of life so profound that the new life will be unimaginable to any who lived before it. This is not the first time the world would experience such a significant change: the beginning of agriculture, the invention of writing and the printing press, and the invention of the computer and internet all transformed nearly every aspect of life. Some believe that new developments in AI will lead to humans becoming irrelevant or even extinct. For the machine learning community, the perspective on these developments is more nuanced for many reasons, including but not limited to the greater control and understanding of the progress and workings of AI. At the same time, the ML (machine learning) community does recognize the large number of risks and ethical questions related to AI. These risks and questions have not been ignored, and progress is continuously made on AI ethics by the ML community at the same time as developments are being made in other areas of machine learning. ","metadata":{}},{"cell_type":"markdown","source":"# Background\nEthics is an ancient field of study, but the application to artificial intelligence is entirely new. While some areas of ethics can and have been debated for millennia, this one has been around for far less, and the ML community doesn't seem to have millennia to learn, debate, and come to an agreement. “The topic of ethics, particularly within the Western context — like other branches of philosophy — is often a speculative (rather than a practical) endeavour” (Brihane et al., 2022, p. 3). For AI, however, the practical aspects are approaching very quickly and with massive implications for the future of society. Ethics must be considered and practiced in the collection of data, the data itself, the code, the reporting of results, and more. Although comparatively new, the current ethical debate around AI has been ongoing for decades, with parts of the debate ocurring in the computer science community and parts occurring in media and pop culture. Famously, Alan Turning created the Turing Test, still explored and debated today. Through sci-fi, pop culture was introduced to and debating the development of AI alongside the ML community. One of the earliest significant looks into pop culture AI ethics occurred in Asimov's \"I, Robot\", with the three laws of robotics. *Star Trek: The Next Generation* presented another milestone in the pop culture debate with the episode \"Measure of a Man\". The machine learning community interacted with these scifi ideas while also considering and debating the reality of AI, with authors like Edelman (2023) mentioning the Three Laws of Robotics within \"On the ethics of constructing conscious AI\" (p. 1). Even ethical scandals within AI predate the 2 year focus of this essay, including the famous issues surrounding Cambridge Analytica. The latest, and perhaps most significant, explosion in news coverage and debate has occurred with the introduction and popularity of of Chat-GPT. Littman et al. (2022) noted that media exagerates both the positives and negatives of AI, although it has brought real attention to issues surrounding bias, transparency, and inequality (p. 8). With the explosion of articles and debate, even those outside of the ML community have had to grapple with AI as a reality outside of scifi and the extremely distant future.","metadata":{}},{"cell_type":"markdown","source":"Long before these past 2 years, ML Community was not only discussing AI ethics, but had a vocabulary related to it, with some of the most relevant terms being Fairness and Bias. However, like AI itself, this portion of the field needed time to develop, mature, and gain notice. Early on, the community focused more on progressing AI's capabilities than the ethical implications that would eventually (and perhaps already did) affect their work. The ML community, however, did begin to recognize that there were ethical concerns to their data, practices, and results as well as to the composition of the community itself. Although AI will likely ultimately affect every human on earth, not every human community was equally or even proportionately represented in the community for a large number of historic and current reasons. As of 2017, that biased distribution could be and was viewed through studies and surveys including the \"2017 Kaggle Machine Learning & Data Science Survey\". ","metadata":{}},{"cell_type":"code","source":"# As a matter of space, the list was reduced (aimed for 15 columns).\n# Those with smaller counts were combined into other.\nkaggle_survey['Country'] = kaggle_survey['Country'].replace([\"Chile\", \"Czech Republic\", \n                                                             \"Norway\", \"Belarus\", \n                                                             \"Kenya\", \"Romania\", \n                                                             \"Hong Kong\", \"Egypt\", \n                                                             \"Hungary\", \"Finland\", \n                                                             \"Republic of China\", \"Vietnam\", \n                                                             \"Nigeria\", \"New Zealand\", \n                                                             \"Denmark\", \"Malaysia\", \n                                                             \"Greece\", \"Philippines\", \n                                                             \"Sweden\", \"Belgium\", \n                                                             \"Argentina\", \"Portugal\", \n                                                             \"Ireland\", \"Israel\", \n                                                             \"Iran\", \"Colombia\", \n                                                             \"Mexico\", \"South Africa\", \n                                                             \"Switzerland\", \"Indonesia\", \n                                                             \"Turkey\", \"Pakistan\", \n                                                             \"Poland\", \"Singapore\", \n                                                             \"South Korea\", \"Ukraine\", \n                                                             \"Netherlands\"], \"Other\")\n\n# Exploring Country in the Survey\nfig = px.histogram(kaggle_survey, \n                   x = 'Country', \n                   title = '2017 Kaggle Survey Countries')\nfig.update_xaxes(categoryorder = 'total descending')\nfig.update_layout(xaxis_title_text = \"Country\", \n                  yaxis_title_text = \"Number of Kagglers\")\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:46:35.512082Z","iopub.execute_input":"2023-07-16T13:46:35.512424Z","iopub.status.idle":"2023-07-16T13:46:37.438134Z","shell.execute_reply.started":"2023-07-16T13:46:35.512396Z","shell.execute_reply":"2023-07-16T13:46:37.437324Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Exploring Gender in the Kaggle Survey\nfig = px.histogram(kaggle_survey, \n                   x = 'GenderSelect', \n                   title = '2017 Kaggle Survey Genders')\nfig.update_xaxes(categoryorder = 'total descending')\nfig.update_layout(xaxis_title_text = \"Gender\", \n                  yaxis_title_text = \"Number of Kagglers\")\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:46:37.439478Z","iopub.execute_input":"2023-07-16T13:46:37.440035Z","iopub.status.idle":"2023-07-16T13:46:37.597030Z","shell.execute_reply.started":"2023-07-16T13:46:37.440005Z","shell.execute_reply":"2023-07-16T13:46:37.596267Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Exploring Age in the Kaggle Survey\nfig = px.histogram(kaggle_survey, \n                   x = 'Age', \n                   title = '2017 Kaggle Survey Ages')\nfig.update_xaxes(categoryorder = 'total descending')\nfig.update_layout(xaxis_title_text = \"Age\", \n                  yaxis_title_text = \"Number of Kagglers\")\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:46:37.598429Z","iopub.execute_input":"2023-07-16T13:46:37.598994Z","iopub.status.idle":"2023-07-16T13:46:37.702175Z","shell.execute_reply.started":"2023-07-16T13:46:37.598965Z","shell.execute_reply":"2023-07-16T13:46:37.700551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Not every country was represented, but a large number were. Still, although most people arrived from outside the top 12 countries, the distribution did not represent the population distribution of this world, and some places and cultures saw a very small number present. The community also showed significantly more male representation than female. At this time, most of the Kagglers were 20 to 30. All of these measures can be contrasted to the current demographics (discussed later). The composition of the ML community becomes relevant to ethics when considering that culture and life experiences can influence perspectives on problems, data, and ethical dilemmas. ","metadata":{}},{"cell_type":"markdown","source":"# Report","metadata":{}},{"cell_type":"markdown","source":"### Privacy and Accuracy/Capabilities\nPrivacy has become the most currently relevant and discussed element of AI ethics. This is the focus of most legislation currently surrounding AI. However, concern about that privacy, its importance, and what data should and shouldn't be collected is currently up for debate.“Several cultures do not possess an equivalent term to the English’ privacy definition in their own language, e.g., Arabic, Dutch, Japanese, and Russian. Nevertheless, this does not mean that these cultures lack a sense of privacy” (Gonzalez-Pizarro et al., 2022, p. 5).  China has widely adopted AI facial recognition for everything from security to payment (Littman et al., 2022, p. 14). “In contrast to European countries, that have adopted a data protection directive from a government-imposed perspective, the USA has followed an industry self-regulation” (Gonzalez-Pizarro et al., 2022, p. 26). But the government is still involved in AI within the USA. Zhang et al. (2022) reported that facial recognition technology is used by 18 of the US government's 24 agencies (p. 62). As of about 2020, Gonzalez-Pizarro et al. (2022) said that “58% of the countries have data protection and privacy legislation, while another 10% have drafted legislation about it” (p. 1). Countries have been passing laws to protect the privacy of their citizens as those citizens have become increasingly concerned about what is being collected and what that might reveal about them. These regulations are especially necessary because even those who want their privacy protected do not always guard their data carefully. “The existence of a mismatch between privacy concerns and privacy behaviors, known as the “privacy paradox” (Gonzalez-Pizarro et al., 2022, p. 5). However, many within the ML community also see how these concerns must be balanced: as AI becomes more integral to society, accuracy becomes of increasing importance and at this moment, accuracy is best obtained with large quantities of data. Over the past 2 years, the ML community has worked to respect and understand these new laws, to collect data in ethical ways, and to move in the direction of generalizing. The past 2 years have also seen increased interest in generalizability and building AI learning skills based on human intelligence instead of vast quantities of data, but there is still a long way to go in that field of research (Littman et al., 2022, pp. 22-28).","metadata":{}},{"cell_type":"markdown","source":"### Data Sources/Testing and Measuring\nRecently, there has also been a lot of concern surrounding the sources of data themselves, even beyond issues of privacy. These concerns have increased as either the problems or consequences have scaled with the increase in AI. The present dependence on large quantities of data also inherently leads to concerns about inequal access and the way that may distort the field and market, with monopolies as a possibility and potential future obstacle (Littman et al., 2022, p. 59).  Additionally, a massive ethics concern is the potential for AI to reflect and amplify past biases since the data collected in the past may include the biases of those times. This could then restore and reinforce those biases. Richardson and Gilbert (2021), for instance, looked at past studies that found bias, such as facial recognition that was more likely to misclassify certain demographics, search engines that perpetuated stereotypes, and biased recidivism scores given to criminal offenders, all reflecting continued real-life implications to algorighmic bias beyond the 1980's discrimination case where applicants to St. George's Hospital Medical Scool were penalized for \"Non-Caucasian\" sounding names (pp. 2-3). Many have looked to refining data collection methods to ensure that the data sets are not reflective of any biases, but data sets will rarely be able to completely eliminate the culture and outlook of the present day. “The treatment of concepts such as fairness and bias in abstract terms is frequently linked to the notion of neutrality and objectivity, the idea that there exists a “purely objective” dataset or a “neutral” representation of people, groups, and the social world independent of the observer/modeller” (Brishane et al., 2022, p. 5). Instead, it may be important to start considering other solutions in addition to larger, more evenly distributed, datasets. Finally, in the past 2 years, the ML community has looked closely at the benchmarks used to measure progress. Some have quickly become too simple considering the speed of AI progress. Others, because a benchmark is always static, have not changed with the culture and time to reflect how the data would actually present and be used and are there fore no longer practically useful (Zhang et al., 2022, p. 107).  Additionally, there have been questions surrounding other practices that may reflect and then reinforce biases from the data, data scientist, and community. This includes the voices and characters given to chatbots and AI tools. ","metadata":{}},{"cell_type":"markdown","source":"### Biased Outcomes\nOne of the most visible concerns related to ethics in machine learning is producing models with severely biased outcomes. This would reflect poorly on any data scientist, but has happened numerous times. If a model is better able to recognize people of one race over another, chooses applications based on gender or background, or otherwise reflects and amplifies the stereotypes and biases of society, it is both an inaccurate model and a potentially dangerous model to trust and implement. These biased models can be additionally problematic due to the trust and ignorance some outside of the ML community may have surrounding AI. For many, answers provided by AI may seem almost magical, mathematical/factual and beyond dispute. They may not believe AI capable of bias in the way humans are. Richardson and Gilbert (2021) referred to \"the neutrality fallacy\" as a widespread belief that AI is not distorted by trends and human biases (p. 2). Greater education is needed, alongside greater caution to ensure the fairness of models through the more careful selection of data and extensive testing. However, it also makes the prevalence of black boxes into an ethical concern. In order to prevent the output from seeming mysterious and to allow for unerstanding and questioning the model's criteria, data scientists should implement tools of machine learning explainability, such as those discussed in: https://www.kaggle.com/learn/machine-learning-explainability Even the biases surrounding the design of AI, with no impact on its relayed conclusions, can have unintended outcomes. For example, a disproportionate number of AI chatbots and other voiced tools have defaulted to female voices. Abercrombie et al. (2021) cited a study that found 75% of text-based chatbots to be gendered and female presenting (p. 2). Abercrombie et al. (2021) “argue that designing conversational assistants with young, subservient female personas can perpetuate negative gender stereotypes, and lead to abusive, misogynistic behaviour in the real world” (p. 2). This concern is not without evidence. “In fact, people named Alexa report being subjected to sexist abuse and harassment simply for sharing their name with the Amazon assistant” (Abercrombie et al., 2021, p. 3). \n","metadata":{}},{"cell_type":"markdown","source":"### AI v. Human Touch\nMany are currently focused on the fairness, accuracy, and privacy of AI, creating great strides over the past two years and promising additional rapid progress. However, the question then shifts from whether AI can to whether AI should. There is an understandable amount of apprehension that the rise of AI will lead to many jobs roles becoming redundant. This is not unique to AI since advances in technology have a long history of disproportionately affecting certain jobs--computers, for example, used to refer to a career that was largely made up of women. AI will likely to have the ability to replace human labor and attain similar or better results for lower costs (Littman et al., 2022, p. 10). It is expected that many driving jobs, such as truck drivers, may soon become done by AI. People will lose their jobs, and creating something that will lead to harship for many is an issue of ethics. Additionally, some aspects of life could feel depersonalized and cold when done by AI instead of by humans, even if the AI is more accurate and customized--such as aspects of education and medical care. Finally, AI has the potential to pursue its task without the considerations that a human might automatically give, something that may potentially be seen as filter bubles and hate are spread among social media in the interest of longer engagement. “Microtargeting is the practice of using data mining and AI techniques to infer personal traits of people and use them to adjust the marketing campaign to those traits. Micro-targeting gives advertisers the ability to exploit recipients’ personal characteristics and potential vulnerabilities” (Strumke et al., 2023, p. 18). AI can make recommendations without understanding and caring about the implications and consequences of those recommendations.  Strumke et al. (2023) recommend that “To to \\[sic\\] protect vulnerable individuals and groups, three essential conditions must be met: i) understanding how vulnerable states can be exploited, ii) detecting when information about vulnerability is being used by an algorithm, iii) and creating social and financial incentives for preventing exploitation of vulnerabilities” (p. 20). The solution to all of these issues may simply be greater collaboration between humans and AI. It is important to understand that the singularity is not yet here and humans are far from obsolete. If AI is to affect human life in such profound ways, then humans must have a job in monotoring it and maintaining the humanity of society.","metadata":{}},{"cell_type":"markdown","source":"### Perspectives\n\nWhat is ethical? One reason this is a topic of study is that different people will have different answers. Diversity among the ML community has become a concern over time because (as demonstrated in the 2017 Kaggle study) the community has been dominated by certain demographics. However, over the past 2 years, it has become clear that there are significant advantages to a more diverse community and work has been done to bring more perspectives into data science. People of other ages and backgrounds may add insight and perspectives that bring them to ask new questions, to notice different trends in the data, to attend to different concerns, or to consider problems in unique ways that can lead to new solutions or insights. For example, “the individualism/collectivism dimension has been found relevant to information privacy concerns. Individualism/collectivism refers to the extent to which individuals are part of groups beyond their immediate families” (Gonzalez-Pizarro et al., 2022, p. 5). Gonzalez-Pizarro et al. (2022) reported on studies that found older participants were more concerned about privacy and controlling information about them while younger people were generally willing to share more openly (p. 5). However older individuals may also have different perspectives on how AI can be used to help the elderly with preserving their privacy and dignity in the face of health concerns and maintaining independence for as long as possible with diseases like Alzheimers (Littman, et al., 2022, p. 11). Their perspective becomes especially valuable and necessary within the ML community when looking at models that would disproportionately affect them, and the same goes for other groups (particularly more vulnerable ones) who were disproportionately affected while underrepresented. Brishane et al. (2022) wrote \"If AI Ethics is to protect the welfare and well-being of the most negatively impacted stakeholders, it needs to be guided by the lived experiences and perspective of such stakeholders” (Brishane et al., 2022, p. 13). Within the past 2 years, there has also been increasing diversity as well as increasing efforts to build the perspectives within the community. As part of this, the community is looking to build itself in many ways, such as through https://www.kaggle.com/kagglex.  Women currently make up 22% of users, but within that, they are more represented among “New Faces” than “Experts” (Ross, 2022). Ross (2022) also found that Asia, Africa, and South America had a large number of users currently developing skills. This extends into the job market as well with data scientists carefully considering AI fairness as part of their job and AI fairness being a concern while seeking and offering jobs. Quinonero-Candela et al. (2023) describe the challenges LinkedIn faces in AI fairness and the company's current framework for it--even something as simple as the proportion of male and female applications to move forward being a question of equity v equality in addition to eliminating algorithmic bias and transparency (pp.1-3). ","metadata":{}},{"cell_type":"markdown","source":"### Sentience\nJust mentioning AI sentience can cause massive debate, with topics ranging from whether it even can be done to whether it should, how it would be recognized, and how humanity should treat and coexist with a new sentient intelligence of its own creation. Although this debate is generally not focused on the type of work done by most data scientists, it is difficult to consider any exploration of AI ethics complete without at least mentioning the top-of-mind issue for most people. However, as covered by Edelman (2023), machine learning could involve both making acceptible results/correct responses rewarding and unacceptable/incorrect into something undesired by the AI--which could ultimately be considered a form of pain. With advanced enough AI, one might need to consider a future time when the work of data scientists could be construed as causing a conscious being to suffer in order to teach it. This not only calls to the ethics of creating entirely new forms of life, but of how they should be treated. While scifi and legislation focuses on imposing rules and restrictions to protect us from AI, according to Edelman (2023), most working in AI completely ignore the topic of AI needing protection from us (p. 1). The main focus of data scientists today is on the ethics of their results and the application of their AI, but there may come a day when they are dragged into the sentience conversation just as severely as those creating chatbots. At the core, this aspect of AI ethics debates which rights sentient AI would be entitled to, how humans can ethically work with sentient AI, which laws should apply beyond humans, and how to ensure its protection as well as ours. ","metadata":{}},{"cell_type":"markdown","source":"### AI for Ethical Purposes\nAn additional area of AI ethics includes the application of AI to the biggest ethical problems of today. AI can be, likely should be, and already is, applied to environmental issues and medical research. Beyond that, it can be applied to various tasks that can help individuals remain independent or live an improved life. In this area, the debate moves from how AI should be cautiously shaped to where else and how else it can be integrated and applied. DataKind uses data scientists and ML to assist charities, and Kaggle has held multiple contests that had topics related to ethical purposes (such as those seen below). In this area, AI ethics relates not only to how the community can structure AI to be as ethical as possible, but how AI can be used to advance ethical goals. ","metadata":{}},{"cell_type":"code","source":"ethical_contests_sample = ['Hotel-ID to Combat Human Trafficking 2022 - FGVC9', \n                           'Hotel-ID to Combat Human Trafficking 2021 - FGVC8', \n                           'Learning Equality - Curriculum Recommendations', \n                           'NFL Health & Safety - Helmet Assignment', \n                           'RSNA 2022 Cervical Spine Fracture Detection', \n                           'Jigsaw Rate Severity of Toxic Comments', \n                           'TensorFlow - Help Protect the Great Barrier Reef', \n                           'HuBMAP - Hacking the Kidney', \n                           'Google - Isolated Sign Language Recognition', \n                           'SIIM-FISABIO-RSNA COVID-19 Detection']\n\nethical_contests_table = kaggle_writeups[kaggle_writeups['Title of Competition'].isin(ethical_contests_sample)]","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:46:37.703639Z","iopub.execute_input":"2023-07-16T13:46:37.704001Z","iopub.status.idle":"2023-07-16T13:46:37.715066Z","shell.execute_reply.started":"2023-07-16T13:46:37.703971Z","shell.execute_reply":"2023-07-16T13:46:37.713891Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Emphasis on Ethics, Debate, and Community\nAs seen in studies like https://www.kaggle.com/code/nghihuynh/kaggle-2022-cloud-racing-ethical-ai-rising, there is an increasing emphasis on and interest in ethics among the ML community. This can also be seen in the increasing number of articles related to ethics within the Arxiv Metadata, as seen in the figure below, \"Presence of Ethics-Related Words in Arxiv Metadata\". Zhang et al. (2022) noted that within the past few years, algorithmic fairness and bias went from a topic studied in academics to mainstream research, with industry contributing 71% more publications year over year at ethics conferences (p. 105). However, as seen in the figure \"Ethics Mentioned Within AI Articles\", this remains just a small fragment of the topics covered by the ML community as it works to develop and progress machine learning as a whole. Progress in machine learning is moving fast and increasingly of interest to the world. In addition to these efforts to discuss more and to build the community, researchers have been creating tools, checklists, and toolkits to assist in building and assessing models. These include developments such as \"Fairness Indicators 2,\" the \"What-If toolkit (WIT),\" \"Aequitas,\" \"AI Fairness 360,\" and \"LiFT\" (Richardson & Gilbert, 2021, pp. 7-9). However, in spite of the ML Community's increasing interest in AI ethics, Richardson and Gilbert (2021) still found that the community was not using the fairness AI tools that were created to help them (p. 2). ","metadata":{}},{"cell_type":"code","source":"# Studying the categories containing selected ethics words\narticles_count = {}\n\nfor category in list(arxiv_ethics['categories'].unique()):\n    articles_count[category] = len(arxiv_ethics[(arxiv_ethics['categories'].str.contains(category))])\n\n    \narticles_count = pd.DataFrame.from_dict(articles_count, 'index')\narticles_count.columns = ['Count']\narticles_count = articles_count.sort_values(by = 'Count', ascending = False)\narticles_count","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:46:37.716315Z","iopub.execute_input":"2023-07-16T13:46:37.716629Z","iopub.status.idle":"2023-07-16T13:46:37.754814Z","shell.execute_reply.started":"2023-07-16T13:46:37.716603Z","shell.execute_reply":"2023-07-16T13:46:37.753429Z"},"jupyter":{"outputs_hidden":true},"_kg_hide-output":true,"collapsed":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Looking at all of Arxiv's focus on ethics for comparison\nall_arxiv_ethics = arxiv_metadata.loc[arxiv_metadata['title'].str.contains(\"ethics\")|\n                                      arxiv_metadata['abstract'].str.contains(\"ethics\")|\n                                      arxiv_metadata['title'].str.contains(\"ethical\")|\n                                      arxiv_metadata['abstract'].str.contains(\"ethical\")|\n                                      arxiv_metadata['title'].str.contains(\"ethically\")|\n                                      arxiv_metadata['abstract'].str.contains(\"ethically\")|\n                                      arxiv_metadata['title'].str.contains(\"fair\")|\n                                      arxiv_metadata['abstract'].str.contains(\"fair\")|\n                                      arxiv_metadata['title'].str.contains(\"fairness\")|\n                                      arxiv_metadata['abstract'].str.contains(\"fairness\")]\n\nall_arxiv_ethics['update_year'] = all_arxiv_ethics['update_date'].dt.year\n\n# Exploring the presence of \"ethics\" and \"ethical\" in the metadata\nfig = px.histogram(all_arxiv_ethics, \n                   x = 'update_year', \n                   title = 'Presence of Ethics-Related Words in Arxiv Metadata')\nfig.update_xaxes(categoryorder = 'total descending')\nfig.update_layout(xaxis_title_text = \"Update Year\", \n                  yaxis_title_text = \"Number of Publications\")\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:46:37.759268Z","iopub.execute_input":"2023-07-16T13:46:37.759631Z","iopub.status.idle":"2023-07-16T13:47:18.941097Z","shell.execute_reply.started":"2023-07-16T13:46:37.759599Z","shell.execute_reply":"2023-07-16T13:47:18.939889Z"},"jupyter":{"outputs_hidden":true},"collapsed":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"arxiv_metadata['update_year'] = arxiv_metadata['update_date'].dt.year\n\n# Looking at Overall Publications\nfig = px.histogram(arxiv_metadata.loc[((arxiv_metadata.categories == \"cs.AI\")|\n                                       (arxiv_metadata.categories == \"cs.CY\")|\n                                       (arxiv_metadata.categories == \"cs.HC\")|\n                                       (arxiv_metadata.categories == \"cs.RO\")|\n                                       (arxiv_metadata.categories == \"cs.LG\")|\n                                       (arxiv_metadata.categories == \"cs.SI\"))], \n                   x = 'update_year', \n                   title = 'Overall Relevant Publications')\nfig.update_xaxes(categoryorder = 'total descending')\nfig.update_layout(xaxis_title_text = \"Update Year\", \n                  yaxis_title_text = \"Number of Publications\")\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:47:18.942603Z","iopub.execute_input":"2023-07-16T13:47:18.943035Z","iopub.status.idle":"2023-07-16T13:47:22.941996Z","shell.execute_reply.started":"2023-07-16T13:47:18.943001Z","shell.execute_reply":"2023-07-16T13:47:22.940718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Searching for potentially relevant terms in the Writeups\nterms_to_search = ['ethics', 'ethical', 'ethically', 'black box', \n                   'bias', 'moral', 'immoral', 'fairness', 'fair', \n                   'trust', 'trustworthy']\n\nterms_count = {}\n\nfor term in list(terms_to_search):\n    terms_count[term] = len(kaggle_writeups[(kaggle_writeups['Writeup'].str.contains(term))])\n\n    \nwriteup_terms = pd.DataFrame.from_dict(terms_count, 'index')\nwriteup_terms.columns = ['Count']\nwriteup_terms = writeup_terms.sort_values(by = 'Count', ascending = False)\nwriteup_terms","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:47:22.943431Z","iopub.execute_input":"2023-07-16T13:47:22.943759Z","iopub.status.idle":"2023-07-16T13:47:23.076754Z","shell.execute_reply.started":"2023-07-16T13:47:22.943733Z","shell.execute_reply":"2023-07-16T13:47:23.075485Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Looking at writeups with the words searched\nfair_writeups = kaggle_writeups[kaggle_writeups['Writeup'].str.contains(\"fair\")]\nfair_writeups.head()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:47:23.078256Z","iopub.execute_input":"2023-07-16T13:47:23.079008Z","iopub.status.idle":"2023-07-16T13:47:23.102897Z","shell.execute_reply.started":"2023-07-16T13:47:23.078974Z","shell.execute_reply":"2023-07-16T13:47:23.101592Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# A little study of the literature\ncount_arxiv_recent = len(arxiv_focused)\ncount_ethics = len(arxiv_ethics)\n\n# Creating a Pie Chart to estimate how many pie charts are discussing \n    ## (or at least mentioning) ethics\nethics_and_not = pd.DataFrame.from_dict({'Other': count_arxiv_recent-count_ethics, \n                                         'Ethics': count_ethics}, orient = 'Index').reset_index()\nethics_and_not.columns = ['Topic', 'Count']\n\nfig = px.pie(ethics_and_not, values = 'Count', \n             names = 'Topic', title = 'Ethics Mentioned Within AI Articles', \n             color_discrete_sequence = ['dimGray', 'mediumBlue'])\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:47:23.104251Z","iopub.execute_input":"2023-07-16T13:47:23.104660Z","iopub.status.idle":"2023-07-16T13:47:23.197237Z","shell.execute_reply.started":"2023-07-16T13:47:23.104629Z","shell.execute_reply":"2023-07-16T13:47:23.196014Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Tokenize the abstract\narxiv_tokenizedwords = arxiv_ethics['abstract'].str.cat(sep=' ')\ntokenizedwords = RegexpTokenizer(r'\\w+').tokenize(arxiv_tokenizedwords)\n\ntokenizedwords = [PorterStemmer().stem(word) for word in tokenizedwords]\ntokenizedwords = [word.lower() for word in tokenizedwords]\n\n#Remove Meaningless Words\nalso_meaningless = [\"thi\", \"use\", \"ha\", \"howev\", \"also\"]\ntokenizedwords = [word for word in tokenizedwords if word not in stopwords.words('english')]\ntokenizedwords = [word for word in tokenizedwords if word not in also_meaningless]\n\n# Studying the most common words in the abstract\nwordfrequency = nltk.FreqDist(tokenizedwords)\nmost_common_words = pd.DataFrame({'Count': wordfrequency}).sort_values(by = 'Count', \n                                                                       ascending = False)\nmost_common_25_words = most_common_words.head(25)\n\nfig = px.bar(most_common_25_words, \n             x = most_common_25_words.index, y = 'Count', \n             title = 'Top 25 Most Common Words')\nfig.update_xaxes(categoryorder = 'total descending')\nfig.update_layout(xaxis_title_text = \"Count\", \n                  yaxis_title_text = \"Words\")\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:47:23.198479Z","iopub.execute_input":"2023-07-16T13:47:23.198824Z","iopub.status.idle":"2023-07-16T13:47:42.946924Z","shell.execute_reply.started":"2023-07-16T13:47:23.198788Z","shell.execute_reply":"2023-07-16T13:47:42.946175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Counter Argument","metadata":{}},{"cell_type":"markdown","source":"### Community is freely available to all online\nAs seen, AI ethics is a vital part of AI development, and the ML community as a whole has openly accepted that. A small minority of that community, however, may question integral parts of the latest efforts, such as the steps being taken to promote diversity within the community. Those critics do have a valid point that, through sites like Kaggle, everyone has the opportunity to contribute and join in the machine learning community. Some may acknowledge that decades of exclusion and stereotypes have a lingering impact on diversity, as do poverty, internet access issues, and language differences (some languages being significantly less represented online). Still, the argument can remain that a problem they did not create is not theirs to solve. A similar argument can be made about data sources that are not including every community. The counterargument, and perhaps the reason most of the ML community has not made this argument, is rather simple and speaks to the heart of what the ML community values--accuracy. Additional perspectives are additional data, and better data can lead to greater accuracy and more sophisticated models. The additional perspectives may also lead the community to ask questions and consider ethical implications that may otherwise be overlooked. It is therefore in the community's best interest to seek out and promote underrepresented perspectives.","metadata":{}},{"cell_type":"markdown","source":"### Job is in tech, not philosophy or ethics\nAI ethics can also meet resistance because ethics itself is its own field of study. Machine learning is a field of technology, not in the same area of study, and attempting to navigate both can feel difficult and confusing. However, as mentioned, ignoring ethics can have massive implications for the use, quality, and even legality of a model. Ethics is part of every job, and there are many resources available today to help mindful data scientists monitor, test, and improve the ethics of their work. Additionally, ethics should be a consideration of everyone in the ML community since the community already values accuracy, which can be closely connected to ethics, and since they themselves will need to live in the world created by the developed and more prominent AI, whether ethical or not.","metadata":{}},{"cell_type":"markdown","source":"# Conclusion\nOver the past 2 years, AI ethics has advanced through the machine learning community developing an improved understanding of the current pitfalls and how we might avoid them. The debate over many aspects of ethics has and will continue to exist, but hopefully this will continue to promote and create fairness and less bias within the machine learning models and their output. At this point, it is unquestionable that AI will amplify human intelligence. What remains to be seen is whether it will amplify human flaws in a way that leads it to be detrimental. AI ethics is a vital part of machine learning because it improves accuracy, provides greater questions and communication for the community's work, and will hopefully lead AI to amplify human virtues more than human flaws. ","metadata":{}},{"cell_type":"markdown","source":"# Works Cited","metadata":{}},{"cell_type":"code","source":"# Establishing works cited table\nworks_cited = ['Gathering Strength, Gathering Storms', \n              'The AI Index 2022 Annual Report', \n              'A Framework for Fairness: A Systematic', \n              'Regional Differences in Information Privacy', \n              'On the ethics of constructing', \n              'Human Vulnerabilities', \n              'Fairness and Bias in Artificial Intelligence: A Brief', \n              'The Forgotten Margins', \n              'Alexa, Google, and Siri']\n\n# Disentangling and Operationalizing must be appended. \n\nworks_cited_table = arxiv_metadata[arxiv_metadata['title'].str.contains('|'.join(works_cited))]\nworks_cited_table = works_cited_table.append({'authors':\"Joaquin Quinonero-Candela, Yuwen Wu, Brian Hsu, Sakshi Jain, Jen Ramos, Jon Adams, Robert Hallman, Kinjal Basu\", \n                                               'title': \"Disentangling and Operationalizing AI Fairness at LinkedIn\", \n                                               'update_date':\"2023-05-30\", \n                                               'abstract':\"N/A\", \n                                               'categories': \"cs.SI cs.AI\", \n                                               'license':\"https://arxiv.org/licenses/nonexclusive-distrib/1.0/license.html\" , \n                                               'update_year':\"2023\"}, ignore_index = True)\nworks_cited_table = works_cited_table.append({'authors':\"Gavin Abercrombie, Amanda Cercas Curry, Mugdha Pandya, Verena Rieser\", \n                                               'title': \"Alexa, Google, Siri: What are your pronouns? Gender and anthropomorphism in the design and perception of conversational assistants\", \n                                               'update_date':\"04-06-2021\", \n                                               'abstract':\"N/A\", \n                                               'categories': \"cs.AI\", \n                                               'license':\"https://creativecommons.org/licenses/by/4.0/\" , \n                                               'update_year':\"2021\"}, ignore_index = True)\nworks_cited_table","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:47:42.948532Z","iopub.execute_input":"2023-07-16T13:47:42.949136Z","iopub.status.idle":"2023-07-16T13:47:48.707884Z","shell.execute_reply.started":"2023-07-16T13:47:42.949093Z","shell.execute_reply":"2023-07-16T13:47:48.706825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Abercrombie, G., Cercas Curry, A., Pandya, M., & Rieser, V. (2021). Alexa, Google, Siri: What are your pronouns? Gender and anthropomorphism in the design and perception of conversational assistants. arXiv:2106.02578v1 \\[cs\\.AI\\]\n\n\nBirhane, A., Ruane, E., Laurent, T., Brown, M. S., Flowers, J., Ventresque, A., & Dancy, C. L. (2022). The forgotten margins of AI ethics. 10.1145/3531146.3533157. arXiv:2205.04221v1 \\[cs\\.CY\\]\n\nBecker, D. & Cook, A. (2018, September 12). *Machine learning explainability.* Kaggle. https://www.kaggle.com/learn/machine-learning-explainability\n\nEdelman, S. (2023). On the ethics of constructing conscious AI. arXiv:2303.07439v1 \\[cs\\.AI\\]\n\nGonzalez-Pizarro, F., Figueroa, A., Lopez, C., & Aragon, C. (2022). Regional differences in information privacy concerns after the  Facebook-Cambridge Analytica data scandal. arXiv:2202.07075v2 \\[cs\\.SI\\]. doi: 10.1007/s10606-021-09422-3.\n\nHuynh, N. (2022, November 26). *Kaggle 2022: Cloud racing, ethical AI rising.* Kaggle. https://www.kaggle.com/code/nghihuynh/kaggle-2022-cloud-racing-ethical-ai-rising\n\nKaggle. (2021). *KaggleX BIPOC Mentorship Program.* Kaggle. https://www.kaggle.com/kagglex\n\nLittman, M., Ajunwa, I., Berger, G., Boutilier, C., Currie, M., Doshi-Velez, F., Hadfield, G., Horowitz, M. C., Isbell, C., Kitano, H., Levy, K., Lyons, T., Mitchell, M., Shah, J., Sloman, S., Vallor, S., & Walsh, T. (2022). Gathering strength, gathering storms: The one hundred year study on  artificial intelligence (AI100) 2021 study panel report. arXiv:2210.15767 \\[cs\\.AI\\]\n\nQuinonero-Candela, J., Wu, Y., Hsu, B., Jain, S., Ramos, J., Adams, J., Hallman, R., & Basu, K. (2023). Disentangling and operationalizing AI fairness at LinkedIn. arXiv:2306.00025v1 \\[cs\\.SI\\]\n\nRichardson, B. & Gilbert, J. E. (2021). A framework for fairness: A systematic review of existing fair AI  solutions. arXiv:2112.05700v1 \\[cs\\.AI\\]\n\nRoss. (2022). *Classifying users and learning from experts.* Kaggle. https://www.kaggle.com/code/rosspmcdonald/classifying-users-and-learning-from-experts/notebook\n\nStrumke, I., Slavkovik, M., & Stachl, C. (2023). Against algorithmic exploitation of human vulnerabilities. arXiv:2301.04993v1 \\[cs\\.AI\\]\n\nZhang, D., Maslej, N., Brynjolfsson, E., Etchemendy, J., Lyons, T., Manyika, J., Ngo, H., Niebles, J. C., Sellitto, M., Sakhaee, E., Shoham, Y., Clark, J., & Perrault, R. (2022). The AI index 2022 annual report. arXiv:2205.03468 \\[cs\\.AI\\]","metadata":{}},{"cell_type":"markdown","source":"# Submission","metadata":{}},{"cell_type":"code","source":"# Creating the Submission\nsubmission = [\"type, value\", \"essay_category, 'AI ethics'\", \n              \"essay_url, 'https://www.kaggle.com/code/jennifersantiago/ai-ethical'\", \n              \"feedback1_url, 'https://www.kaggle.com/code/sayantanis11/understanding-ethical-ai/comments#2343741'\",\n              \"feedback2_url, 'https://www.kaggle.com/code/sircausticmail/kaggle-aireport-ai-ethics/comments#2343868'\",\n              \"feedback3_url, 'https://www.kaggle.com/code/pandoraalias/charting-the-ethical-landscape-ai-ethics/comments#2344981'\"]\n\nwith open ('submission.csv', 'w') as submitted_file:\n    for line in submission:\n        submitted_file.write(line)\n        submitted_file.write('\\n')","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-16T13:47:48.709765Z","iopub.execute_input":"2023-07-16T13:47:48.710468Z","iopub.status.idle":"2023-07-16T13:47:48.717426Z","shell.execute_reply.started":"2023-07-16T13:47:48.710417Z","shell.execute_reply":"2023-07-16T13:47:48.716103Z"},"trusted":true},"execution_count":null,"outputs":[]}]}