preface

This preface aims to describe the evolution of technology, our need to automate, and our responsibility to make ethical decisions while using artificial intelligence in building the future.

Our obsession with technology and automation

Throughout history, we have had a hunger to solve problems while reducing manual labor and human effort. We have always strived for survival and conservation of our energy through the development of tools and automation of tasks. Some may argue that we are beautiful minds that seek innovation through creative problem-solving or creative works of literature, music, and art, but this book wasn’t written to discuss philosophical questions about our being. This is an overview of artificial intelligence (AI) approaches that can be harnessed to address real-world problems practically. We solve hard problems to make living easier, safer, healthier, more fulfilling, and more enjoyable. All the advancements that you see in history and around the world today, including AI, address the needs of individuals, communities, and nations.

To shape our future, we must understand some key milestones in our past. In many revolutions, human innovation changed the way we live, and shaped the way we interact with the world and the way we think about it. We continue to do this as we iterate and improve the tools we use, which open future possibilities (figure 0.1).

This short high-level material on history and philosophy is provided purely to establish a baseline understanding of technology and AI, and to spur thought on responsible decision-making when embarking on your projects.

A close up of text on a black background Description automatically generated

Figure 0.1 A brief timeline of technological improvements in history

In the timeline figure, notice the compression of the milestones in more recent times. In the past 30 years, the most notable advancements have been in the improvement of microchips, the wide adoption of personal computers, the boom of networked devices, and the digitization of industries to break physical borders and connect the world. These are also the reasons that artificial intelligence has become a feasible and sensible area to pursue.

  • The internet has connected the world and made it possible to collect mass amounts of data about almost anything.

  • Advancements in computing hardware has given us the means to compute previously known algorithms using the massive amounts of data that we have collected, while discovering new algorithms along the way.

  • Industries have seen a need to leverage data and algorithms to make better decisions, solve harder problems, offer better solutions, and optimize our lives as people have done since the beginning of humanity.

Although we tend to think of technological progress as linear, by examining our history, we find that it is more likely that our progress is and will be exponential (figure 0.2). Advancements in technology will move faster each year that goes by. New tools and techniques need to be learned, but problem solving fundamentals underpin everything.

This book includes foundation-level concepts that help solve hard problems, but it also aims to make learning the more complex concepts easier.

A close up of text on a black background Description automatically generated

Figure 0.2 Perceived technological progress versus actual technological progress

Automation can be perceived differently by different people. For a technologist, automation may mean writing scripts that make software development, deployment, and distribution seamless and less error-prone. For an engineer, it may mean streamlining a factory line for more throughput or fewer defects. For a farmer, it may mean using tools to optimize the yield of crops through automatic tractors and irrigation systems. Automation is any solution that reduces the need for human energy to favor productivity or add superior value compared with what a manual intervention would have added (figure 0.3).

A close up of a logo Description automatically generated

Figure 0.3 Manual processes versus automated processes

If we think about reasons not to automate, one prominent reason is simply that a person can do the task better, with less chance of failure and better accuracy, if the task requires intuition about several perspectives in a situation, when abstract creative thinking is required, or when understanding social interactions and the nature of people is important.

Nurses don’t simply complete tasks, but connect with and take care of their patients. Studies show that the human interaction by caring people is a factor in the healing process. Teachers don’t simply offload knowledge, but find creative ways to present knowledge, mentor, and guide students based on their ability, personality, and interests. That said, there is a place for automation through technology and a place for people. With the innovations of today, automation via technology will be a close companion to any occupation.

Ethics, legal matters, and our responsibility

You may be wondering why a section on ethics and responsibility is in a technical book. Well, as we progress towards a world in which technology is intertwined with the way of life, the ones who create the technology have more power than they know. Small contributions can have massive knock-on effects. It important that our intentions be benevolent and that the output of our work not be harmful (figure 0.4).

A screenshot of a cell phone Description automatically generated

Figure 0.4 Aim for ethical and legal applications of technology

Intention and impact: Understanding your vision and goals

When you develop anything—such as a new physical product, service, or software—there’s always a question about the intention behind it. Are you developing software that affects the world positively, or is your intention malevolent? Have you thought about the broader impact of what you’re developing? Businesses always find ways to become more profitable and powerful, which is the whole point of growing a business. They use strategies to determine the best ways to beat the competition, gain more customers, and become even more influential. That said, businesses must ask themselves whether their intentions are pure, not only for the survival of the business, but also for the good of their customers and society in general. Many famous scientists, engineers, and technologists have expressed a need to govern the use of AI to prevent misuse. As individuals, we also have an ethical obligation to do what is right and establish a strong core set of values. When you’re asked to do something that violates your principles, it is important to voice those principles.

Unintended use: Protecting against malicious use

It is important to identify and protect against unintended use. Although this may seem obvious and easy to accomplish, it is difficult to understand how people will use whatever you are creating, and even more difficult to predict whether it aligns with your values and the values of the organization.

An example is the loudspeaker, which was invented by Peter Jensen in 1915. The loudspeaker was originally called Magnavox, which was initially used to play opera music to large crowds in San Francisco, which is quite a benevolent use of the technology. The Nazi regime in Germany had other ideas, however: they placed loudspeakers in public places in such a way that everyone was subjected to hearing Hitler’s speeches and announcements. Because the monologues were unavoidable, people became more susceptible to Hitler’s ideas, and after this point in time, the Nazi regime gained the majority of its support in Germany. This is not what Jensen envisioned his invention being used for, but there’s not much he could have done about it.

Times have changed, and we have more control of the things we build, especially software. It is still difficult to imagine how the technology you build may be used, but it is almost guaranteed that someone will find a way to use it in a way that you did not intend, with positive or negative consequences. Given this fact, we, as professionals in the technology industry and the organizations we work with must think of ways to mitigate malevolent use as far as possible.

Unintended bias: Building solutions for everyone

When building AI systems, we use our understanding of contexts and domains. We also use algorithms that find patterns in data and act on it. It can’t be denied that there is bias all around us. A bias is a prejudice against a person or group of people, including, but not limited to their gender, race, and beliefs. Many of these biases arise from emergent behavior in social interactions, events in history, and cultural and political views around the world. These biases affect the data that we collect. Because AI algorithms work with this data, it is an inherent problem that the machine will “learn” these biases. From a technical perspective, we can engineer the system perfectly, but at the end of the day, humans interact with these systems, and it’s our responsibility to minimize bias and prejudice as much as possible. The algorithms we use are only as good as the data provided to them. Understanding the data and the context in which it is being used is the first step in battling bias, and this understanding will help you build better solutions—because you will be well versed in the problem space. Providing balanced data with as little bias as possible should result in better solutions.

The law, privacy, and consent: Knowing the importance of core values

The legal aspect of what we do is hugely important. The law governs what we can and cannot do in the interest of society as a whole. Due to the fact that many laws were written in a time when computers and the internet were not as important in our lives as they are today, we find many gray areas in how we develop technology and what we are allowed to do with that technology. That said, laws are slowly changing to adapt to the rapid innovation in technology.

We are compromising our privacy almost every hour of every day via our interactions on computers, mobile phones, and other devices, for example. We are transmitting a vast amount of information about ourselves, some more personal than others. How is that data being processed and stored? We should consider these facts when building solutions. People should have a choice about what data is captured, processed, and stored about them; how that data is used; and who can potentially access that data. In my experience, people generally accept solutions that use their data to improve the products they use and add more value to their lives. Most important, people are more accepting when they are given a choice and that choice is respected.

Singularity: Exploring the unknown

The singularity is the idea that we create an AI that is so generally intelligent that it is capable of improving itself and expanding its intelligence to a stage where it becomes super intelligence. The concern is that something of this magnitude cannot be understood by humans which could change civilization as we know it for reasons we can’t even comprehend. Some people are concerned that this intelligence may see humans as a threat; others propose that we may be to a super intelligence what ants are to us. We don’t pay explicit attention to ants or concern ourselves with how they live, but if we are irritated by them, we deal with them in isolation.

Whether these assumptions are accurate representations of the future or not, we must be responsible and think about the decisions we make, as they ultimately affect a person, a group of people, or the world at large.

acknowledgments

Writing this book has been one of the most challenging yet rewarding things I’ve done to date. I needed to find time where I had none, find the right headspace while juggling many contexts, and find motivation while being caught up in the reality of life. I couldn’t have done it without a number of amazing people. I have learned and grown through this experience. Thank you, Bert Bates, for being a fantastic editor and mentor to me. I’ve learned so much about effective teaching and written communication from you. Our discussions and debates, and your empathy throughout the process has helped mold this book into what it is. Every project needs someone organized with a finger on the pulse making sure things are happening. For this, I’d like to thank Elesha Hyde, my development editor. Working with you has been an absolute pleasure. You always provide direction and interesting insights about my work. We always need people to bounce ideas off, and who better to annoy than your friends. I’d like to especially thank Hennie Brink for being a great sounding board and pillar of support always. Next, I’d like to thank Frances Buontempo and Krzysztof Kamyczek for providing constructive criticism and objective feedback from a writing and technical perspective. Your input has helped fill gaps and make the teaching more accessible. I would also like to thank Deirdre Hiam, my project manager; my review editor, Ivan Martinovic; my copyeditor Kier Simpson; and my proofreader, Jason Everett.

Finally, I’d like to thank all the reviewers who took the time to read my manuscript throughout development and provided invaluable feedback that has made the book better in some or other way: Andre Weiner, Arav Agarwal, Charles Soetan, Dan Sheikh, David Jacobs, Dhivya Sivasubramanian, Domingo Salazar, GandhiRajan, Helen Mary Barrameda, James Zhijun Liu, Joseph Friedman, Jousef Murad, Karan Nih, Kelvin D. Meeks, Ken Byrne, Krzysztof Kamyczek, Kyle Peterson, Linda Ristevski, Martin Lopez, Peter Brown, Philip Patterson, Rodolfo Allendes, Tejas Jain, and Weiran Deng.

about this book

Grokking Artificial Intelligence Algorithms was written and illustrated to make understanding and implementing artificial intelligence algorithms and their uses in solving problems more accessible to the average person in the technology industry through the use of relatable analogies, practical examples, and visual explanations.

Who should read this book

Grokking Artificial Intelligence Algorithms is for software developers and anyone in the software industry who want to uncover the concepts and algorithms behind artificial intelligence through practical examples and visual explanations over theoretical deep dives and mathematical proofs.

This book is aimed at anyone with an understanding of basic computer programming concepts including variables, data types, arrays, conditional statements, iterators, classes, and functions—experience in any language is sufficient; and, anyone with an understanding of basic mathematical concepts such as data variables, the representation of functions, and plotting data and functions on a graph.

How this book is organized: A roadmap

This book contains 10 chapters, each focusing on a different artificial intelligence algorithm or algorithmic approach. The material covers fundamental algorithms and concepts at the start of the book that form a foundation for learning more sophisticated algorithms throughout the book.

  • Chapter 1Intuition of artificial intelligence, introduces the intuition and fundamental concepts that surround data, types of problems, categories of algorithms and paradigms, and use cases for artificial intelligence algorithms.

  • Chapter 2Search fundamentals, covers the core concepts of data structures and approaches for primitive search algorithms, and their uses.

  • Chapter 3Intelligent search, goes beyond primitive search algorithms and introduces search algorithms for finding solutions more optimally, and finding solutions in a competitive environment.

  • Chapter 4Evolutionary algorithms, dives into the workings of genetic algorithms where solutions to problems are iteratively generated and improved upon by mimicking evolution in nature.

  • Chapter 5Advanced evolutionary approaches, is a continuation of genetic algorithms but tackles advanced concepts involving how steps in the algorithm can be adjusted to solve different types of problems more optimally.

  • Chapter 6Swarm intelligence: Ants, digs into the intuition for swam intelligence and works through how the ant colony optimization algorithm uses a theory of how ants live and work to solve hard problems.

  • Chapter 7Swarm intelligence: Particles, continues with swarm algorithms while diving into what optimization problems are, and how they’re solved using particle swarm optimization—as it seeks good solutions in large search spaces.

  • Chapter 8Machine learning, works through a machine learning workflow for data preparation, processing, modeling, and testing—to solve regression problems with linear regression, and classification problems with decision trees.

  • Chapter 9Artificial neural networks, uncovers the intuition, logical steps, and mathematical calculations in training and using an artificial neural network to find patterns in data and make predictions; while highlighting its place in a machine learning workflow.

  • Chapter 10Reinforcement learning with Q-Learning, covers the intuition of reinforcement learning from behavioral psychology, and works through the Q-Learning algorithm for agents to learn good and bad decisions to make in an environment.

The chapters should be read from start to end sequentially. Concepts and understandings are built up along the way as the chapters progress. It is useful to reference the Python code in the repository after reading each chapter to experiment and gain practical insight into how the respective algorithm can be implemented.

About the Code

This book contains Pseudocode to focus on the intuition and logical thinking behind the algorithms, as well as to ensure that the code is accessible to anyone, regardless of programming language preferences. Pseudocode is an informal way to describe instructions in code. It is intended to be more readable and understandable; basically more human-friendly.

With that said, all algorithms described in the book have examples of working Python code available on Github (http://mng.bz/Vgr0). Setup instructions and comments are provided in the source code to guide you as you learn. One potential learning approach would be to read each chapter then reference the code after to cement your understanding of the respective algorithms.

The Python source code is intended to be a reference for how the algorithms could be implemented. These examples are optimized FOR LEARNING and NOT PRODUCTION use. The code was written to serve as a tool for teaching. Using established libraries and frameworks is recommended for projects that will make their way into production, as they are usually optimized for performance, well tested, and well supported.

liveBook discussion forum

Purchase of Grokking Artificial Intelligence Algorithms includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum, go to http://mng.bz/xWoe. You can also learn more about Manning’s forums and the rules of conduct at https://livebook.manning.com/#!/discussion.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We suggest you try asking the author some challenging questions lest his interest stray! The forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

Other online resources

Source code for Grokking Artificial Intelligence Algorithms:

http://mng.bz/Vgr0

Author website:

https://rhurbans.com

about the author

Rishal has been obsessed with computers, technology, and crazy ideas since childhood. Throughout his career he has been involved in the leadership of teams and projects, hands-on software engineering, strategic planning, and the end-to-end design of solutions for various international businesses. He has also been responsible for actively growing a culture of pragmatism, learning and skills development within his company, community, and industry.

Rishal has a passion for business mechanics and strategy, growing people and teams, design thinking, artificial intelligence, and philosophy. Rishal has founded various digital products to help people and businesses be more productive and focus on what’s important. He has also spoken at dozens of conferences around the globe to make complex concepts more accessible and help people elevate themselves.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.72.74