<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Koorosh Aslansefat on Medium]]></title>
        <description><![CDATA[Stories by Koorosh Aslansefat on Medium]]></description>
        <link>https://medium.com/@koo.ec2008?source=rss-41e7b477247e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Ds7rcMVMJoFwPtpkz6u7pA.jpeg</url>
            <title>Stories by Koorosh Aslansefat on Medium</title>
            <link>https://medium.com/@koo.ec2008?source=rss-41e7b477247e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 21:54:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@koo.ec2008/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Make Your Classifier Safe?]]></title>
            <link>https://medium.com/data-science/how-to-make-your-classifier-safe-46d55f39f1ad?source=rss-41e7b477247e------2</link>
            <guid isPermaLink="false">https://medium.com/p/46d55f39f1ad</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[statistical-analysis]]></category>
            <category><![CDATA[safeml-project]]></category>
            <dc:creator><![CDATA[Koorosh Aslansefat]]></dc:creator>
            <pubDate>Fri, 05 Jun 2020 15:29:56 GMT</pubDate>
            <atom:updated>2020-06-10T16:49:12.086Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Make Your Classifier Safe</h3><h4>A story about the accuracy estimation of Machine Learning/Deep Learning classifiers based on statistical distance measures (SafeML, and SafeDL) — Part I.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*H0lN2Q9lmSRgfaGj9VqqGA.png" /><figcaption>SafeML logo from [<a href="https://github.com/ISorokos/SafeML">https://github.com/ISorokos/SafeML</a>]</figcaption></figure><h3>Table of contents</h3><ol><li><strong>Introduction</strong></li><li><strong>SafeML Idea</strong></li><li><strong>Statistical Distances</strong></li><li><strong>Conclusion</strong></li><li><strong>References</strong></li><li><strong>Related GitHub Projects</strong></li><li><strong>Related Medium Posts</strong></li></ol><h3>1. Introduction</h3><p>Nowadays, artificial intelligence (AI) is growing rapidly and its applications dominating many different subjects. In parallel with this rapid growth, the concerns about AI safety is also raising. For safety-critical systems where human life, environment, money and privacy is under risk, the AI safety cannot be ignored. (Amodei et al., 2016) have discussed different existing issues of certifying the modern machine learning systems operating in the field. As shown in the following figure, safety issues can be categorised into five categories including A) Safe exploration, B) Robustness to distributional shift, C) Avoiding negative side effects, D) Avoiding “reward hacking” and “wire heading”, E) Scalable oversight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*ZvPJNCKd4cEajc3SYZaaMg.png" /><figcaption>Five main categories of AI Safety</figcaption></figure><p>The topic of this story can be considered as “robustness to distributional shift” issue in AI safety. Based on the following figure, the SafeML approach that we are going to explain includes Safe Machine Learning (SafeML) and Safe Deep Learning (SafeDL).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*PxdhSo2acWe0wn_XgFlWzA.png" /><figcaption>Left: Artificial Intelligence (AI) vs. Machine Learning (ML) vs. Deep Learning (DL). Right: Safe Artificial Intelligence (SafeAI) vs. Safe Machine Learning (SafeML) vs. Deep Learning (SafeDL).</figcaption></figure><p>There are different existing approaches for increasing the safety and robustness of ML algorithms. Some papers investigate the uncertainty evaluation of results in a classifier while others focus on the improvement of robustness against uncertainties. As an example, the following figure shows the ETH Robustness Analyzer for Neural Networks (ERAN) that uses possible perturbations for input “8” and tries to create a shape that abstracts all possible outputs. If the created shape violates the defined boundary and the results cannot be certified. Otherwise, the outputs will be guaranteed. For more details please check (Gehr, T., et al. 2018 and Balunovic, M., et al. 2019).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eMUbL2a2Xb3iD7kNLIkFYw.png" /><figcaption>ETH Robustness Analyzer for Neural Networks (ERAN) [<a href="https://github.com/eth-sri/eran">https://github.com/eth-sri/eran</a>]</figcaption></figure><p>In section 2, the idea of SafeML is discussed briefly, and section three addresses the application of statistical difference measures with some python example. A short conclusion is provided in section 5. Some of the related medium posts and Github projects are suggested at the end of the story.</p><h3>2. SafeML Idea</h3><p>SafeML idea has been proposed by (Aslansefat et al., 2020-b), and the goal was to somehow monitor the decisions of the classifiers when there is no available label.</p><p>The following figure demonstrates the flowchart of the SafeML idea. In this flowchart, there are two main sections including training phase and application phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*iIpJOHOL1GWrp234jfYW0g.png" /><figcaption>Flowchart of SafeML (Aslansefat et al. 2020-b)</figcaption></figure><p>A) The <strong>training phase</strong> is an offline procedure in which a trusted or certified dataset will be used to train the intelligent algorithm that can be a machine learning or deep learning algorithm. Thus, using a trusted dataset the classifier will be trained and its performance will be measured with existing KPIs (e.g. ROC, Accuracy and Kappa). Meanwhile, the statistical parameters and distributions of each class will be estimated and stored to be used for comparison (e.g. Mean values, Variance Values, and the Empirical Cumulative Distribution Functions (ECDFs)).</p><p>B) The <strong>application phase</strong> is an online procedure in which real-time and unlabelled data is going to be feed to the system. For example, consider a security attack detector that has been trained to detect different security attacks and it should filter the attacker IPs. Therefore, in the application phase, the trained classifier should distinguish between the normal network traffic and the security attacks (classification task). One important and critical issue in the application phase is that the data does not have any label. So, it cannot be assured that the classifier can operate as accurate as of the training phase.</p><p>In the application phase, the buffered data will be separated based on classifier decision (that is not certified) and the statistical parameters of each class will be stored to be compared with the one in trained phased. Using the statistical distance measures that will be explained in the next section, the distance between features for each class in the trained phase and application phase will be compared. If the calculated distance and expected confidence (defined by an expert) difference was very low, the classifier results and its accuracy can be trusted (the system is acting autonomously), if the difference was low, the system can ask for more data and re-evaluation to make sure about the distance. In case of larger difference, the classifier results and accuracy are no longer valid, and the system should use an alternative approach or notify a human agent (In this example, the system will ask the responsible security agent to check the network traffic manually and make a decision).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qBLu6THDIyIJueq5BBKjng.png" /><figcaption>Application of SafeML in security intrusion detection (e.g. datasets like CICIDS2017)</figcaption></figure><p>There are countless applications of Machine Learning and Deep Learning for early detection or diagnosis in various kinds of disease. For example, (Scudellari, S. (2020)) wrote about “Hospitals Deploy AI Tools to Detect COVID-19 on Chest Scans”. Can this AI tools be fully autonomous in detection or diagnosis? Are they Safe? What is our definition of their safety? It is believed that SafeML or similar approaches can be a possible answer for those questions. The following figure illustrates the application of SafeML in medical diagnosis (e.g. COVID-19 diagnosis using lung scans).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3kWKBUjjfUMZ8CdBPPYKVw.png" /><figcaption>Application of SafeML in medical diagnosis (e.g. COVID-19 Diagnosis using <a href="https://spectrum.ieee.org/the-human-os/biomedical/imaging/hospitals-deploy-ai-tools-detect-covid19-chest-scans">Lung Scans</a>)</figcaption></figure><p>Another example can be a traffic sign detector in an autonomous car or self-driving vehicle that uses Machine Learning or Deep Learning to detect the traffic sign and generate the required action(s). The following block diagram shows how SafeML can be used in this case study. This can be used also for autonomous platoon systems (Kabir, S., et al. (2020)).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gX5xxr3kgM43c8O552vJGg.png" /><figcaption>Application of SafeML in self-driving cars (e.g. Traffic Sign Detection) [Car vector created by freepik — <a href="http://www.freepik.com/">www.freepik.com</a>]</figcaption></figure><p>Each of the above-mentioned applications will be implemented using SafeML with some well-known case studies in our next stories (Part II, Part III and Part IV).</p><h3>3. Statistical Distances and their Potential Applications in Accuracy Estimation</h3><p>A threshold line can be considered as the simplest version of a classifier. Consider the following figure; in this simple classifier any point bellow the threshold line (Xtp) will be considered as class 1 and any point above the threshold line will be counted as class 2. Assume that we know that the points between time 0 to 20 are class 1 and other points are class 2. As can be seen in this simple example, x and v points are misclassified.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*K_ZVaVXRN8XawL6jWOmUfg.png" /><figcaption>A hypothetical signal and a simple threshold of Xtp (Aslansefat et al., 2020-a)</figcaption></figure><p>If we estimate the probability density function of each class (the following figure), then the probability of error can be calculated as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*CpJg35J-y_I-_vG_Ftyu-w.png" /></figure><p>The classifier accuracy can be easily obtained using 1-P(error). In this simple classifier, the area that two probability density function merge causes the error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*0CHUkdkKothRBKKP7M7-XQ.png" /><figcaption>Probability density functions of class 1 and class 2</figcaption></figure><p><a href="https://www.google.com/search?rlz=1C1CHBD_en-GBGB877GB877&amp;sxsrf=ALeKk03ALt8gLtDnn4rboINnHhj6V0MSMw:1591081899154&amp;q=Keinosuke+Fukunaga&amp;stick=H4sIAAAAAAAAAOPgE-LVT9c3NMwwTKuMN6_MVYJw03JMzCtys3O0ZLKTrfST8vOz9cuLMktKUvPiy_OLsq0SS0sy8osWsQp5p2bm5ReXZqcquJVml-YlpifuYGUEAG9AE8xWAAAA&amp;sa=X&amp;ved=2ahUKEwjoh6H7yeLpAhVTu3EKHT2QAHkQmxMoATARegQIEhAD">Fukunaga</a>, K. (1990) showed that the upper bound error can be calculated using probability density function (PDF)-based distances like Bhattacharyya distance. The PDF-based distance measures usually rely on mean and variance distance as shown in the following figure. However, some exiting advanced methods can also compare the shape of different PDFs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q_2Hhg5yJ-n6I8FWThhDog.png" /><figcaption>Distance measures based on probability density functions (PDFs)</figcaption></figure><p>The following figure shows four well-known PDF-based distance measure methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*bE1k03PA2dfl7N_IIWzONg.png" /><figcaption>Some of the well-known PDF-based distance measures</figcaption></figure><h4>3.1 Chernoff and Bhattacharyya based Upper Bound Error</h4><p>The following python example of upper bound error probability estimation based on Chernoff method is provided. In this code, if one considers “s = 0.5”, then it will be the Bhattacharyya upper bound error estimation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/958ce59d5d91b73ab225bd8f7cb47f53/href">https://medium.com/media/958ce59d5d91b73ab225bd8f7cb47f53/href</a></iframe><p>It can be proved that the probability of error is correlated with the distance between the cumulative distribution functions (CDFs) (Aslansefat, K. et al. 2020-b). Some of the well-known CDF-based distance measures can be listed as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*dKycNPEDOQUNDSuR4YRG9Q.png" /><figcaption>Some of the well-known CDF-based distance measures</figcaption></figure><p>Sometimes it can be easier to use the empirical cumulative distribution function (ECDF) of features. Python examples of ECDF-based distance measures are provided as follows.</p><h4>3.2 Kolmogorov-Smirnov Distance</h4><p>Consider we have a dataset with two classes and one feature. The following figure shows the ECDF of the feature for class 1 (blue) and class 2 (red). The Kolmogorov-Smirnov simply finds the maximum exiting distance between two ECDFs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*UZf7od5wagCkfO2egPPMVQ.png" /><figcaption>Kolmogorov-Smirnov distance measure Illustration</figcaption></figure><p>As an example, you can check the following python code for Kolmogorov-Smirnov distance measure:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8837a79a661218ae1a8e283a8f3c090a/href">https://medium.com/media/8837a79a661218ae1a8e283a8f3c090a/href</a></iframe><h4>3.3 Kuiper Distance</h4><p>The Kuiper distance has similar functionality to the Kolmogorov-Smirnov distance. However, this method considers two maximum distance as shown below; a) when blue ECDF has a larger value than red ECDF and b) when red ECDF has a larger value than blue ECDF. The Kuiper distance can be obtained by adding two maximum values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*BQFEZR1hA9Ll_OVq-jPGcQ.png" /><figcaption>Kuiper distance measure illustration</figcaption></figure><p>An example of Kuiper distance measure in python is provided as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0350b183bf0e0824d49a95b50d01c93c/href">https://medium.com/media/0350b183bf0e0824d49a95b50d01c93c/href</a></iframe><h4>3.4 Cramer-Von Mises Distance</h4><p>ECDF is formed by many small steps. Consider the absolute difference of two steps in the same interval as height. If we calculate the summation of all calculated height values for all steps, then we have the Cramer-Von Mises Distance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*8h6_9ePE7PSvzqFuuUAgNg.png" /><figcaption>Cramer-Von Mises distance measure illustration</figcaption></figure><p>You can check the sample python code for Cramer-Von Mises Distance as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/727c3b9bfa17eb342630007aece6196d/href">https://medium.com/media/727c3b9bfa17eb342630007aece6196d/href</a></iframe><h4>3.5 Anderson-Darling Distance</h4><p>The Anderson-Darling distance is similar to the Cramer-Von Mises Distance. The only difference is that Anderson-Darling normalizes height values by their standard deviation (SD). Please check the following python example for Anderson-Darling distance.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/94de9b5c363d9bc8f76ef5e2f3129507/href">https://medium.com/media/94de9b5c363d9bc8f76ef5e2f3129507/href</a></iframe><h4>3.6 Wasserstein Distance</h4><p>Wasserstein distance has been used in many applications. For example, it has been used as a loss function in generative adversarial neural networks (GANs) (Gulrajani, I. 2017). The Wasserstein distance we consider both height values and width values for all steps. This method somehow measures the area between two ECDFs when we consider power equal to one. When the power factor is one, Wasserstein distance is equal to Earth Mover Distance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*o6TdftuIWMgmYbbRVecHWw.png" /><figcaption>Wasserstein distance measure illustration</figcaption></figure><p>You can check the following python example of Wasserstein distance.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/313c12531bbcc06cf02e2264df41fd05/href">https://medium.com/media/313c12531bbcc06cf02e2264df41fd05/href</a></iframe><p>The above python codes are also available on <a href="https://colab.research.google.com/drive/1pfATDDr98PJg8S-nRpnF85nJxYaijeMF?usp=sharing">Google Colab</a>. If one uses R for Programming the <a href="https://github.com/cdowd/twosamples">twosamples library</a> is suggested. The above Python codes have been rewritten from this library. For MATLAB users, a set of <a href="https://uk.mathworks.com/matlabcentral/fileexchange/75282-ecdf-based-distance-measure-algorithms">ECDF-based distance measures functions</a> are recommended.</p><p>To see some examples and case studies with SafeML idea please check the following GitHub project:</p><p><a href="https://github.com/ISorokos/SafeML">https://github.com/ISorokos/SafeML</a></p><p>More details about SafeML is available in our recent paper [<a href="https://arxiv.org/abs/2005.13166v1">arXiv</a>][<a href="https://www.researchgate.net/publication/341699548_SafeML_Safety_Monitoring_of_Machine_Learning_Classifiers_through_Statistical_Difference_Measure">ResearchGate</a>][<a href="https://deepai.org/publication/safeml-safety-monitoring-of-machine-learning-classifiers-through-statistical-difference-measure">DeepAI</a>][<a href="https://paperswithcode.com/paper/safeml-safety-monitoring-of-machine-learning">PaperWithCode</a>].</p><figure><img alt="SafeML: Exploring techniques for safety monitoring of machine learning and deep learning classifiers." src="https://cdn-images-1.medium.com/max/700/1*ZrL3BwNWPSa2AUx7G42j7w.png" /></figure><h3>4. Conclusion</h3><p>In this story, the topic of AI safety has briefly introduced and the idea of SafeML has explained with some possible applications. Some of the well-known ECDF-based distance measures algorithms have been provided with their simple python example. In our next stories, the above-mentioned applications of SafeML will be provided with code implementation. Each of the above-mentioned ECDF-based approaches works well for a certain class of system. Thus, the relation between the system’s characteristics and ECDF-based distance measures will be discussed in the next stories.</p><p>The SafeML is still in an early stage of development and it is aimed to extend it for dealing with time-series data, prediction and regression algorithms (i.e. Schulam, P., et al. (2019)) and domain adaptation (i.e. Shen, J., et al. (2018)). It is also possible to use SafeML as Explainable AI that will be discussed later. It should be mentioned that in parallel with “AI Safety” research, there are some other research works focusing on the application of AI for improving safety models (Gheraibia, Y., et al. (2019)).</p><h3>References</h3><p>Amodei, D., Olah, C., Steinhardt, J., Christiano, P., Schulman, J., &amp; Mané, D. (2016). Concrete problems in AI safety. <em>arXiv preprint </em><a href="https://arxiv.org/abs/1606.06565v2"><em>arXiv:1606.06565</em></a>.</p><p>Aslansefat, K., Gogani, M. B., Kabir, S., Shoorehdeli, M. A., &amp; Yari, M. (2020-a). Performance evaluation and design for variable threshold alarm systems through semi-Markov process. <em>ISA transactions</em>, <em>97</em>, 282–295. <a href="https://doi.org/10.1016/j.isatra.2019.08.015">https://doi.org/10.1016/j.isatra.2019.08.015</a></p><p>Aslansefat, K., Sorokos, I., Whiting, D., Kolagari, R. T., &amp; Papadopoulos, Y. (2020-b). SafeML: Safety Monitoring of Machine Learning Classifiers through Statistical Difference Measure. <em>arXiv preprint </em><a href="https://arxiv.org/abs/2005.13166v1"><em>arXiv:2005.13166</em></a>.</p><p>Balunovic, M., Baader, M., Singh, G., Gehr, T., &amp; Vechev, M. (2019). Certifying Geometric Robustness of Neural Networks. In <em>Advances in Neural Information Processing Systems</em> (pp. 15287–15297) [<a href="http://papers.nips.cc/paper/9666-certifying-geometric-robustness-of-neural-networks">Link</a>].</p><p>Gehr, T., Mirman, M., Drachsler-Cohen, D., Tsankov, P., Chaudhuri, S., &amp; Vechev, M. (2018, May). Ai2: Safety and robustness certification of neural networks with abstract interpretation. In <em>IEEE Symposium on Security and Privacy (SP)</em> (pp. 3–18). <a href="https://doi.org/10.1109/SP.2018.00058">https://doi.org/10.1109/SP.2018.00058</a></p><p>Gulrajani, I., Ahmed, F., Arjovsky, M., Dumoulin, V., &amp; Courville, A. C. (2017). Improved training of Wasserstein gans. In <em>Advances in neural information processing systems</em> (pp. 5767–5777) [<a href="http://papers.nips.cc/paper/7159-improved-training-of-wasserstein-gans">Link</a>].</p><p>Gheraibia, Y., Kabir, S., Aslansefat, K., Sorokos, I., &amp; Papadopoulos, Y. (2019). Safety+ AI: A Novel Approach to Update Safety Models Using Artificial Intelligence. <em>IEEE Access</em>, <em>7</em>, 135855–135869. <a href="https://doi.org/10.1109/ACCESS.2019.2941566">https://doi.org/10.1109/ACCESS.2019.2941566</a></p><p>Kabir, S., Sorokos, I., Aslansefat, K., Papadopoulos, Y., Gheraibia, Y., Reich, J., … &amp; Wei, R. (2019, October). A Runtime Safety Analysis Concept for Open Adaptive Systems. In <em>International Symposium on Model-Based Safety and Assessment</em> (pp. 332–346). Springer, Cham. <a href="https://doi.org/10.1007/978-3-030-32872-6_22">https://doi.org/10.1007/978-3-030-32872-6_22</a></p><p>Scudellari, S. (2020) Hospitals Deploy AI Tools to Detect COVID-19 on Chest Scans, <a href="https://spectrum.ieee.org/the-human-os/biomedical/imaging/hospitals-deploy-ai-tools-detect-covid19-chest-scans">IEEE Spectrum</a>.</p><p>Schulam, P., &amp; Saria, S. (2019). Can you trust this prediction? Auditing pointwise reliability after learning. <em>arXiv preprint </em><a href="https://arxiv.org/abs/1901.00403v2"><em>arXiv:1901.00403</em></a>.</p><p>Shen, J., Qu, Y., Zhang, W., &amp; Yu, Y. (2018, April). Wasserstein distance guided representation learning for domain adaptation. In <em>Thirty-Second AAAI Conference on Artificial Intelligence [</em><a href="https://www.aaai.org/ocs/index.php/AAAI/AAAI18/paper/viewPaper/17155">Link</a><em>]</em>.</p><h3>Related GitHub Projects</h3><p><a href="https://github.com/ISorokos/SafeML">SafeML Project:</a> The idea that has been briefly explained in this story.</p><p><a href="https://github.com/dependable-ai/nn-dependability-kit">NN-Dependability-KIT Project: </a>Toolbox for software dependability engineering of artificial neural networks.</p><p><a href="https://github.com/cfinlay/confident-nn">Confident-NN Project: </a>Toolbox for empirical confidence estimation in neural networks-based classification.</p><p><a href="https://eth-sri.github.io/research/safeai">SafeAI Project: </a>Different toolboxes like <a href="https://github.com/eth-sri/diffai">DiffAI</a>, <a href="https://github.com/eth-sri/dl2">DL2</a> and <a href="https://github.com/eth-sri/eran">ERAN</a> from SRILab ETH Zürich focusing on robust, safe and interpretable AI.</p><h3>Related Medium Posts</h3><ul><li><a href="https://medium.com/@deepmindsafetyresearch/building-safe-artificial-intelligence-52f5f75058f1">Building safe artificial intelligence: specification, robustness, and assurance</a></li><li><a href="https://towardsdatascience.com/ai-safety-how-do-you-prevent-adversarial-attacks-ede17480a24d">AI Safety — How Do you Prevent Adversarial Attacks?</a></li><li><a href="https://towardsdatascience.com/ai-safety-ai-ethics-and-the-agi-debate-d5ffaaca2c8c">AI safety, AI ethics and the AGI debate</a></li><li><a href="https://medium.com/@AssuringAutonomy/zen-and-the-art-of-safety-assurance-for-machine-learning-in-autonomous-driving-77ebb4c0a302">Zen and the art of safety assurance for machine learning in autonomous driving</a></li><li><a href="https://ai-alignment.com/ai-safety-vs-control-vs-alignment-2a4b42a863cc">AI “safety” vs “control” vs “alignment”</a></li></ul><h3>Acknowledgement</h3><p>I would like to thank contributors of SafeML project:</p><ul><li>Professor Yiannis Papadopoulos (University of Hull)</li><li>Dr. Ioannis Sorokos (Fraunhofer Institute for Experimental Software Engineering)</li><li>Dr. Ramin Tavakoli Kolagari (Nuremberg Tech)</li><li>Declan Whiting (University of Hull &amp; APD Communications)</li></ul><h3>To be continued …</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46d55f39f1ad" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-to-make-your-classifier-safe-46d55f39f1ad">How to Make Your Classifier Safe?</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Validate the Correctness of an Evolutionary Optimization Algorithm]]></title>
            <link>https://medium.com/data-science/how-to-validate-the-correctness-of-an-evolutionary-optimization-algorithm-570c8b71b6d7?source=rss-41e7b477247e------2</link>
            <guid isPermaLink="false">https://medium.com/p/570c8b71b6d7</guid>
            <category><![CDATA[metaheuristics]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[evolutionary-algorithms]]></category>
            <category><![CDATA[optimization-algorithms]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Koorosh Aslansefat]]></dc:creator>
            <pubDate>Thu, 07 May 2020 16:42:34 GMT</pubDate>
            <atom:updated>2020-05-12T03:49:22.639Z</atom:updated>
            <content:encoded><![CDATA[<h4>Possible ways for checking the correctness and accuracy of an implemented metaheuristic multi-objective optimization algorithm.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*5N1-SAEk41wXFyJOeZoSAw.png" /><figcaption>3D space with f = Y.*sin(X) — X.*cos(Y)</figcaption></figure><h3>Table of contents</h3><ol><li><strong>Introduction</strong></li><li><strong>Correctness Validation</strong></li><li><strong>A Brief Discussion on Performance Evaluation</strong></li><li><strong>Conclusion</strong></li><li><strong>References</strong></li><li><strong>Some Related Medium Posts</strong></li></ol><h3>1. Introduction</h3><p>Evolutionary and Metaheuristic optimization algorithms are considered as a subset of Artificial Intelligence (AI). These algorithms try to imitate nature mechanisms and solve an optimization problem. For example, the Genetic Algorithm (GA) uses inspired biological mechanisms such as reproduction, cross-over, selection, mutation, and recombination to find the best solution for an optimization problem. Another example can be an Imperialist Competitive Algorithm (ICA) where social mechanisms like domination, revolution, and colonization are used to find a solution [1]. Evolutionary algorithms are usually performing well in complex optimization problems where using classical approaches is mathematically difficult. They can easily deal with nonlinear problems without being stuck in local minimums.</p><p>To optimize a problem with an evolutionary optimization algorithm one can use a certified toolbox. However, for some algorithms, either there is no available certified toolbox or one may prefer to implement his/her own code with any program languages. In this situation, the most important questions are — How we can trust the written code? How we can validate the correctness of our implemented evolutionary or metaheuristic code?</p><p>In this post, some of the existing ways to check and validate the correctness of an implemented evolutionary optimization algorithm have been addressed briefly. In addition, a discussion regarding the performance evaluation of optimization algorithms is provided using an example of <a href="https://en.wikipedia.org/wiki/Ackley_function">Ackley function</a>.</p><h3><strong>2. Correctness Validation</strong></h3><p>There are different ways to check the correctness and accuracy of an implemented metaheuristic multi-objective optimization algorithm (e.g. Genetic Algorithm (GA) or Differential Evolution (DE)). The following approaches can be addressed briefly to check the correctness of the implemented optimization algorithm:</p><p>A) <strong>Comparison with classical approaches:</strong> In some problems, it can be possible to run both the classical approach and multi-variate GA to make sure the results are correct and accurate. However, in most cases, because of mathematical complexity using a classical approach for comparison is not possible.</p><p>B) <strong>Using Well-known Benchmarks:</strong> The correctness of the code can be also proven though existing benchmarks. The used algorithm can be validated via well-known benchmarks [2–6].</p><p>C) <strong>Using Expert Idea:</strong> An expert of the system can check the results and their rationality. They should all agree that the final results are logical. If for a problem exact minimum cost value is needed, then using an expert idea would not be convincing.</p><p>D) <strong>Convergence:</strong> The convergence of the implemented multi-objective genetic algorithm can be easily observed through the plot of cost vs. iterations. There are also other factors such as roundoff errors and local extrema that have the same perspective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G3fRgVKlU1FPADS4.png" /><figcaption>A sample convergence plot from [7] (Fitness vs. Number of Iterations)</figcaption></figure><p>E) <strong>Domination Factor:</strong> The new generation of optimization algorithms such as NSGA-II, NSGA-III, and MOPSO usually have a function to separate dominant results from non-dominant one. So, all final results should be dominant and with a proper initial population, it is very rare to be trapped by a local minimum. However, there is no guarantee that they find the global minimum of the system. For more information regarding the domination please check [8].</p><h3><strong>3. A Brief Discussion on Performance Evaluation</strong></h3><p>The following figure shows Ackley function with <em>a</em> equal to 20, <em>b </em>equal to 0.2 and <em>c</em> equal to 2 [9]. This function is one of the well-known benchmarks used for evolutionary or metaheuristic optimization. It has one unique global minimum and several local minimums.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fa6-SRMR5fj_d_LMguvFhg.png" /><figcaption>Ackley function with a = 20, b = 0.2, c = 2.</figcaption></figure><p>The above figure can be easily generated using the bellow MATLAB code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afc2bb1c4c192014d6f3508fff725b06/href">https://medium.com/media/afc2bb1c4c192014d6f3508fff725b06/href</a></iframe><p>By increasing the value of <em>b</em> to 1000 the following figure can be obtained. As can be seen in this function there are many local minimums and a narrow unique global minimum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*1S7-NrbHg6oK6rYc6yN3aA.png" /><figcaption>Ackley function with a = 20, b = 1000, c = 2.</figcaption></figure><p>It is possible to also put <em>c</em> equal to zero and remove all local minimums. Then the following figure can be obtained. A flat surface with a narrow and deep hole as a global minimum. In this case, the plot of Fitness vs Number of Iteration is not useful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9wI6xNxKLHdvz2Jt13MkA.png" /><figcaption>Ackley function with a = 20, b = 1000, c = 0.</figcaption></figure><p>To have a clue about the performance of an optimization algorithm lets simplify the problem. First of all, we can discretize the area. Consider X and Y have a range of -5 to 5 with a step size of one and point x = 0 and y = 0 is the global minimum value. So, there will be 121 possible combinations of X and Y. The probability of finding the optimal value randomly should be 1/121. <strong>In the worst-case scenario, what is the probability of finding the optimal value?</strong></p><p>The answer should be the total number of newly generated values (considering all algorithm section such as initial population, mutation, crossover, recombination, etc.) during a certain number of iterations divided by total possible combinations of inputs (genes). In this case, only the number of newly generated value and the accuracy of discretization can improve the performance. The following expression can be used as the probability of error for this example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*oGC-39F83wDRAmIzyzKb9w.png" /></figure><p>The above expression can be used as the upper bound probability of error for not only the worst-case scenario but also for any other scenarios. This expression can also prove that when the step size is small enough (N → ∞) in the discretization and the number of iterations is infinite (huge computation power is needed) then the probability of error should be zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*D9KZzZmdpJIUk7iG4X1NJg.png" /></figure><p>It should be noted that the worst-case scenario is given because the nature of the problem can easily be bypass or reduce the effect of strategy in an evolutionary algorithm. In other words, the strategy of an evolutionary optimization algorithm has a low effect on performance and accuracy for this example.</p><p>Finding the performance and accuracy of evolutionary optimizations is still an unanswered research question. In many cases, the strategy of the algorithm is affecting performance. For instance, Arnold, D. V. et al. [10] has proposed a method to measure the effect of step size in the output performance of an evolutionary optimization algorithm. But this research cannot be considered as a general solution for accuracy and performance evaluation of evolutionary optimization algorithms.</p><h3><strong>4. Conclusion</strong></h3><p>The computational effort that is related to the number of iterations, initial population and internal function evaluations that can be related to the performance or accuracy of a metaheuristic algorithm. So, calculating the big O for an optimization algorithm is useful.</p><p>The problem dimensions including the number of objectives, constraints, range and number of input genes plus structure of optimization algorithm can be related to the performance [11].</p><p>The correctness of an evolutionary optimization algorithm can be validated through different methods summarized as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*KjjaKRWpVq77rMsrLS9wCQ.png" /><figcaption>Possible ways to check the correctness of an evolutionary or metaheuristic algorithm</figcaption></figure><h3>5. References</h3><p>[1] Atashpaz-Gargari, E., &amp; Lucas, C. (2007). Imperialist competitive algorithm: an algorithm for optimization inspired by imperialistic competition. In <em>IEEE congress on evolutionary computation</em> (pp. 4661–4667).</p><p>[2] Yao, X., Liu, Y., &amp; Lin, G. (1999). Evolutionary programming made faster. IEEE Transactions on Evolutionary Computation, 3(2), 82–102.</p><p>[3] Digalakis, J. G., &amp; Margaritis, K. G. (2001). On benchmarking functions for genetic algorithms. International journal of computer mathematics, 77(4), 481–506.</p><p>[4] Molga, M., &amp; Smutnicki, C. (2005). Test functions for optimization needs. Test functions for optimization needs, 101.</p><p>[5] Yang, X. S. (2010). Test problems in optimization. arXiv preprint arXiv:1008.0549.</p><p>[6] Mirjalili, S., &amp; Lewis, A. (2013). S-shaped versus V-shaped transfer functions for binary particle swarm optimization. Swarm and Evolutionary Computation, 9, 1–14.</p><p>[7] Chen, Q., Chen, Y., &amp; Jiang, W. (2016). Genetic particle swarm optimization–based feature selection for very-high-resolution remotely sensed imagery object change detection. <em>Sensors</em>, <em>16</em>(8), 1204.</p><p>[8] Elarbi, M., Bechikh, S., Gupta, A., Said, L. B., &amp; Ong, Y. S. (2017). A new decomposition-based NSGA-II for many-objective optimization. IEEE transactions on systems, man, and cybernetics: systems, 48(7), 1191–1210.</p><p>[9] Ackley, D. (2012). <em>A connectionist machine for genetic hillclimbing</em> (Vol. 28). Springer Science &amp; Business Media.</p><p>[10] Arnold, D. V., &amp; Beyer, H. G. (2004). Performance analysis of evolutionary optimization with cumulative step length adaptation. <em>IEEE Transactions on Automatic Control</em>, <em>49</em>(4), 617–622.</p><p>[11]Website: <a href="https://www.researchgate.net/post/How_to_assess_the_performance_of_an_optimization_algorithm">https://www.researchgate.net/post/How_to_assess_the_performance_of_an_optimization_algorithm</a></p><h3>6. Some Related Medium Posts</h3><ul><li><a href="https://towardsdatascience.com/demystifying-optimizations-for-machine-learning-c6c6405d3eea">Demystifying Optimizations for machine learning</a></li><li><a href="https://towardsdatascience.com/understanding-rmsprop-faster-neural-network-learning-62e116fcf29a">Understanding RMSprop — faster neural network learning</a></li><li><a href="https://towardsdatascience.com/adaptive-meta-heuristically-intelligent-particle-ami-p-4badd123b3a2">Adaptive Meta-heuristically Intelligent Particle (AMI-P)</a></li><li><a href="https://towardsdatascience.com/introduction-to-evolution-strategy-1b78b9d48385">Introduction to Evolution Strategy</a></li></ul><p><strong>Note:<br></strong>The idea of writing this post started when we got a review comment on the following article:</p><p>Akhlaghi, Y. G., Badiei, A., Zhao, X., Aslansefat, K., Xiao, X., Shittu, S., &amp; Ma, X. (2020). A constraint multi-objective evolutionary optimization of a state-of-the-art dew point cooler using digital twins. <em>Energy Conversion and Management</em>, <em>211</em>, 112772. <a href="https://doi.org/10.1016/j.enconman.2020.112772">https://doi.org/10.1016/j.enconman.2020.112772</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=570c8b71b6d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-to-validate-the-correctness-of-an-evolutionary-optimization-algorithm-570c8b71b6d7">How to Validate the Correctness of an Evolutionary Optimization Algorithm</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>