<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jayesh Bapu Ahire</title>
    <description>The latest articles on DEV Community by Jayesh Bapu Ahire (@jbahire).</description>
    <link>https://dev.to/jbahire</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F79521%2F70c8162a-0a54-47c0-aeba-aa8bac1e73fa.jpg</url>
      <title>DEV Community: Jayesh Bapu Ahire</title>
      <link>https://dev.to/jbahire</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jbahire"/>
    <language>en</language>
    <item>
      <title>Adopt AI, But Responsibly!</title>
      <dc:creator>Jayesh Bapu Ahire</dc:creator>
      <pubDate>Sat, 13 Apr 2024 14:24:27 +0000</pubDate>
      <link>https://dev.to/genai/adopt-ai-but-responsibly-21e3</link>
      <guid>https://dev.to/genai/adopt-ai-but-responsibly-21e3</guid>
      <description>&lt;p&gt;In this riveting episode of the AI Guardrails Podcast, we dive deep into the transformative impact of artificial intelligence on the field of cybersecurity. Join us as we sit down with ⁠Andy Martin⁠, founder and CEO of ⁠Control Plane⁠, who shares his expert insights on the integration of AI technologies in protecting digital infrastructures. From the origins of AI in gaming to its pivotal role in modern cybersecurity strategies, Andy unpacks the complexities and potential of AI to reshape security paradigms. &lt;/p&gt;

&lt;p&gt;We explore cutting-edge topics such as AI's ability to automate vulnerability assessments, the ethical considerations of AI deployment, and the future of AI-enhanced security measures. Whether you're a cybersecurity professional, AI enthusiast, or just keen to understand the next big thing in tech, this episode will arm you with the knowledge you need to navigate the AI-powered security landscape. Tune in to discover if AI is truly the cybersecurity hero we've been waiting for or if it's a Pandora's box that might unleash new challenges.&lt;/p&gt;

&lt;h3&gt;
  
  
  Guest Bio:
&lt;/h3&gt;

&lt;p&gt;Andrew Martin is founder and CEO of ⁠⁠Control Plane, ⁠specializing in securely unlocking next-generation cloud technologies for highly regulated clients. He holds pro bono positions as CISO at OpenUK and co-chair of the CNCF’s Technical Advisory Group for Security. His clients include Google, the UK Government, Citibank, JPMC, PWC, BP, Visa, British Gas, The Economist, and News UK.&lt;br&gt;
He is co-author of Hacking Kubernetes (O’Reilly Media, 2022), has published training material and numerous whitepapers for clients including the Linux Foundation and SANS, and regularly speaks and delivers training at international security conferences and events.&lt;/p&gt;

&lt;h2&gt;
  
  
  Transcript
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Jayesh Ahire:&lt;/strong&gt; Hello, everyone. Welcome to the AI Guardians Podcast, where we discuss AI, the adoption challenges, and the security opportunities around building new AI and ML applications. Today, we have with us Andy from Control Plane.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Andy Martin:&lt;/strong&gt; Hello, thank you very much for having me on. I'm Andy, founder and CEO at Control Plane. I have a background in classic computer science, did a lot of development and infrastructure engineering, DevOps, and all that good stuff, and worked through a number of different regulated organizations and started Control Plane to bring consulting and assurance around cloud-native and next-generation technologies to regulated industries. We're based out of London with a lot of colleagues across Europe, Asia Pacific, and North America.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Jayesh Ahire:&lt;/strong&gt; Interesting. Andy and I met back in 2019 on the streets in Sydney where we shared some good kebabs and good talks, and that's where we actually got to know each other. Control Plane has been doing fantastic work in different domains of security and different strategic relationships they have with various organizations in the UK and across the world.&lt;/p&gt;

&lt;p&gt;Today, we'll be discussing different use cases Andy has come across specifically in the cybersecurity domain when it comes to AI and the new gen AI, the "LM" thing which has been catching up since last year. So to begin with, how did you get interested in this specific domain? And what are some of the interesting use cases you have seen while working on this?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Andy Martin:&lt;/strong&gt; Well, one of the first things that sparked the interest was watching some of the things that OpenAI did many years ago, where they released a playground, and you could build your own agents to play classic games so you could teach an agent to play pong and some side scrolling games and that kind of thing. A very dear friend of mine who actually trained as a lawyer turns around to me and says there's so much stuff going on here. DeepMind, they were just starting the AlphaGo project as well, and one of the DeepMind founders was, or still is, I think a lecturer at University College, London. His reinforcement learning course was live on YouTube. So my friend and I sat down and watched a lecture module on reinforcement learning and discovered that it was reasonably complicated. But this very simple process of having an agent with a feedback loop, observation of the environment, and a reward function, it's a very, very simple way of modeling something that's actually exponentially complex across multiple dimensions. We did this course, it was fantastically interesting during that time. DeepMind then got acquired by Google and integrated internally there. We've got Demis Hassabis, the CEO, now deeply integrated into Google's plans and all of their latest models. So the last two years since the release of OpenAI's ChatGPT in the open AI playground before the big launch, it was clear that there was something there, the token prediction capabilities of LLMs got to a point where they were really useful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Jayesh Ahire:&lt;/strong&gt; As you rightly mentioned, right specifically around the things like vulnerability assessment, and then like at least reducing the repetitive work which has been happening in these workflows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Andy Martin:&lt;/strong&gt; Absolutely, and it's becoming one of the interesting use cases. We have been seeing this across things like SAS, and even the DAST tooling, even SCA, for that matter. And traditionally, SAST is producing a lot of false positives. But how can we minimize them using all of this context we are feeding into these models?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Jayesh Ahire:&lt;/strong&gt; And I know you have been running some of the initiatives, including the FinOps AI readiness work group, and all of the others. We want to touch base on that, and go through. What are the different things you have been doing and exploring in this specific domain?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Andy Martin:&lt;/strong&gt; Yes. So, the financial services open source organization which sits under the Linux Foundation has soon to be announced AI readiness working group. I'm on the steering committee, and the goal of the group is to bring together stakeholders from all the major banks and some other financial services organizations and figure out what is the simplest way to get AI into these organizations. Now, roadblocks involved there include well, who owns this data and is the leak of this data an existential event for the bank, for a regulator. For existing security controls and mechanisms in place in the banks that we want to continue to respect because we spent many years building them, and they're compliant with regulation. So the AI Readiness working group is a collection of individuals operating under Chatham house rules to share experiences and to build out a set of common guidelines and frameworks for secure adoption of AI. So that that's very much based on the legal implications, privacy, and how we deal with the governance, risk, and compliance of the entire end-to&lt;/p&gt;

&lt;p&gt;-end AI ML lifecycle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Jayesh Ahire:&lt;/strong&gt; You made an interesting point at the end, right where? As you're adopting these technologies, it's very important to be responsible. And at the same time make sure that we are aware of all the caveats that come with it to protect ourselves from any of this damages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Andy Martin:&lt;/strong&gt; It's extremely difficult. Again, if we model what we've done with AI as an extension of human patterns of behavior, capturing of what biases, as well from from an ethical perspective, and our performance at keeping things private as a species, then we can see that we have just made a far more flamboyant rods for our for our own backs. But for data protection, it's a huge open goal. It's back to this question of where do we delineate those security boundaries? And do we put financial information in the same place as legal information in the same place as proprietary information? The answer, of course, is No, but what the the initial dream has been, or perhaps in this space of uncertainty, as we begin to adopt this as a commercial enterprise across the world. Is that? Yes, we can do this with a single model. And really, this is where I see the the greatest greatest issue. The inherent risks when the model is inherently opaque as to its training, data, composition. One piece, and then add on top of that. the mixing of different data classifications and sensitivities. And we're in quite a risky space. So one of the things that that I'm also involved with is open UK. which is a charity sorry, a nonprofit focused on open technology hardware data and software. And we try and stop governments from making non technically based legislation decisions. And and it is wonderful to work with the the UK Government and the European Union and and the White house on those things. One thing across the 3 is that the European Union has had an AI act in place and moving along for for a number of years. That's neo completion. We'll we'll be enforced in the next, I think. Couple of years from a UK perspective we got a consortium together of of countries from around the world, and agreed on safe and sort of trusted AI. But also, you know, the UK Government is really rushing into this. The UK is one of the biggest service industries in the world, and it's clear the AI is very well placed to eat some of that breakfast, if you like, and and and to make services more optimal so suddenly, there's a lot of challenges. So the the government in the UK has really pushed for you know they courted open AI which will open an office in London, and already. and a really push from that perspective. And then the US. Is is kind of just observing it. It doesn't have legislation moving in in the same way for these things. Of course it is the birthplace, and it's now looking more at. The embargoes around the hardware that needed for AI, so that Chip will with China, for example, TSMC being protected. In in Taiwan. spoke in terms of of where that privacy and data protection is sat. The European Union are doing the best job by a long way of actually codifying and sort of gathering those ethereal threats.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Jayesh Ahire:&lt;/strong&gt; Yeah. And that will be definitely very interesting to see where this evolves to that extent, where everything is in context. And we can actually just go and ask the question, and we get the answer. It will be just one more teammate in the whole process, I guess. The one thing which comes along with that is. as these, models are getting perfected. There are also some of these humans who are trying to perfect in the whole AI driven cybersecurity, or even learn more about the new advancements in LLM and the learn LLM space. What will be the advice from you, for them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Andy Martin:&lt;/strong&gt; My favourite piece of advice in this space is. consider the model as a frenemy. It's not your enemy, but it's not your friend and I, I'd say that it is an untrusted, non-deterministic. potentially hostile threat actor behind your firewall. So as long as we consider that we've dropped something in that is completely new in the history of computing. We haven't given an agent this level of autonomy. Now we have to some extent that those agents are testable, deterministic. In this case, we don't understand how models make their decisions. We understand how they're trained, but actually getting explainability back out of the model, which is also part of the EU AI act. Getting that explainability is not uniform across everything, and it's not necessarily accurate all the time. So we have to consider that we've installed something new we haven't dealt with before at this scale that is evolving extremely quickly. So just consider what actually is that model. as I say. half friend, half enemy, with the capacity to do incredible&lt;/p&gt;

&lt;p&gt;goods, and to reduce toil for humanity, and reduce the burden of repetitive tasks. But also we. We must use this to embellish ourselves and not replace ourselves, because we can't trust that. and we have society evolved to give us these constraints and and legal requirements and ethical concerns that we have baked into our souls, our personas, as people that are not replicated by the machines. So Firewall and everything, and trust but verify.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Jayesh Ahire:&lt;/strong&gt; Thank you. And absolutely so. That's I guess. more of a drawing drawing this boundary somewhere and making sure that everything you do remains in that specific constrained environment. and making sure all of the things you want to put it up, protected all of the things you want insights on are better served by the models you are using cool. So I guess, though, those are all the questions I had, and I wanted to go through on the sidelines like, Have you? Do you? As I can see you like reading a lot, I guess. And then you go through a bunch of these things. Any interesting book recommendations you have come across recently?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Andy Martin:&lt;/strong&gt; Yes. What? my friend and colleague Mr. Vicente Herrera, who has been doing a lot of work control plane on red teaming models, and and how we consider them as that's. And again, as these insecure things with security potential just recommended, a book to me called Generative AI Security. It's published by Springer and had it the yeah, I'll I'll share a link to that. That that's quite new, and it's very comprehensive. I've also been reading things like the OWASP LLM top 10, things like the NCSC Secure AI adoption guidelines. A lot of people have put out a lot of different literature. and it tends to come in at different levels. So on the one hand, you'll have security of data and privacy and keeping it very high level. At the other end, with something like OWASP, you have in depth. On what do these attacks look like? How might they actually happen? So so I find those very interesting as well. And it's a and buying and friends is the generative Bio Security Book.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Jayesh Ahire:&lt;/strong&gt; We? Yeah. thank you. And that, that that must be interesting to go through as so. thanks, Andy for joining in. And I guess. It was pretty long and detailed. Very interesting conversation one of the longest episode, for sure. and but I really like talking to you, and all the insights you have from different things you do. In your in your day to day. Again. Thanks for joining in. I hope you enjoyed it as much as I did. and see you again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Andy Martin:&lt;/strong&gt; It was tremendous. I enjoyed it thoroughly, and thank you very much for having me.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Jayesh Ahire:&lt;/strong&gt; Thank you. Have a good time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Thanks for listening/ reading the Second episode of AI Guardrails podcast. You can find the latest episode here: &lt;a href="https://podcasters.spotify.com/pod/show/ai-guardrails"&gt;https://podcasters.spotify.com/pod/show/ai-guardrails&lt;/a&gt; . We are available on Spotify, Apple Podcast, or any of your favorite podcast apps. What are the next topics you want to listen about? Let us know in comments!&lt;br&gt;
⁠⁠&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>cybersecurity</category>
      <category>llm</category>
    </item>
    <item>
      <title>Don't Keep Up with AI!</title>
      <dc:creator>Jayesh Bapu Ahire</dc:creator>
      <pubDate>Fri, 12 Apr 2024 13:34:09 +0000</pubDate>
      <link>https://dev.to/genai/dont-keep-up-with-ai-1boi</link>
      <guid>https://dev.to/genai/dont-keep-up-with-ai-1boi</guid>
      <description>&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://podcasters.spotify.com/pod/show/ai-guardrails/episodes/Dont-try-to-keep-up-with-AI-e2hlss8/a-a58em4" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--fS6XTX-c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://d3t3ozftmdmh3i.cloudfront.net/staging/podcast_uploaded_episode400/40847836/40847836-1711622868282-35531150a3428.jpg" height="400" class="m-0" width="400"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://podcasters.spotify.com/pod/show/ai-guardrails/episodes/Dont-try-to-keep-up-with-AI-e2hlss8/a-a58em4" rel="noopener noreferrer" class="c-link"&gt;
          Don't try to keep up with AI! by AI Guardrails
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          In this thought-provoking episode hosted by Jayesh Ahire, Noah Gift, founder and CEO of Pragmatic AI Labs, delves into the complex interplay between generative AI, cybersecurity, and ethics. Gift challenges the current hype surrounding AI, emphasizing its role as an enhancer of existing best practices rather than a disruptive force. With a keen focus on the importance of ethical considerations and the potential risks of commercial AI models, he offers insightful perspectives on the future of technology. Join us as we explore the ethical minefield of AI in cybersecurity and the critical importance of adhering to solid principles over chasing the latest trends, all through the insightful dialogue between Ahire and Gift.

Guest Bio:
Noah Gift is the founder of Pragmatic A.I. Labs. Noah Gift lectures at MSDS, at Northwestern, Duke MIDS Graduate Data Science Program, the Graduate Data Science program at UC Berkeley, the UC Davis Graduate School of Management MSBA program, UNC Charlotte Data Science Initiative, and University of Tennessee (as part of the Tennessee Digital Jobs Factory). 
He teaches and designs graduate machine learning, MLOps, AI, and Data Science courses, and consulting on Machine Learning and Cloud Architecture for students and faculty. These responsibilities include leading a multi-cloud certification initiative for students. 

Host Bio:
Jayesh Ahire is the Founding Product Manager at TraceableAI where he runs the Company’s API Security initiative. He is a Practitioner at heart and has worked with numerous organizations to design and implement secure API architectures and integrate security practices into their development processes. 
He is the maintainer of Open source projects like OWASP crAPI, Hypertrace, and many others. He has presented at various industry conferences on topics related to API security and secure development practices including DefCon, Bsides, and BlackHat, and also runs the API security Global community.

        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://res.cloudinary.com/practicaldev/image/fetch/s---0v5DPA3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://d12xoj7p9moygp.cloudfront.net/favicon/favicon-s4p-196x196.png" width="196" height="196"&gt;
        podcasters.spotify.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;In this episode hosted by ⁠Jayesh Ahire⁠, &lt;a href="https://www.linkedin.com/in/noahgift/"&gt;⁠Noah Gift⁠&lt;/a&gt;, founder and CEO of Pragmatic AI Labs, delves into the complex interplay between generative AI, cybersecurity, and ethics. Gift challenges the current hype surrounding AI, emphasizing its role as an enhancer of existing best practices rather than a disruptive force. With a keen focus on the importance of ethical considerations and the potential risks of commercial AI models, he offers insightful perspectives on the future of technology. &lt;/p&gt;

&lt;p&gt;Join us as we explore the ethical minefield of AI in cybersecurity and the critical importance of adhering to solid principles over chasing the latest trends, all through the insightful dialogue between Ahire and Gift.&lt;/p&gt;

&lt;h3&gt;
  
  
  Guest Bio
&lt;/h3&gt;

&lt;p&gt;⁠&lt;a href="https://www.linkedin.com/in/noahgift/"&gt;Noah Gift⁠&lt;/a&gt; is the founder of ⁠Pragmatic A.I. Labs⁠. Noah Gift lectures at ⁠MSDS⁠, at Northwestern, ⁠Duke MIDS Graduate Data Science Program⁠, the ⁠Graduate Data Science program at UC Berkeley⁠, the UC Davis Graduate School of Management MSBA program, ⁠UNC Charlotte Data Science Initiative⁠, and ⁠University of Tennessee (as part of the Tennessee Digital Jobs Factory)⁠. &lt;br&gt;
He teaches and designs graduate machine learning, MLOps, AI, and Data Science courses, and consulting on Machine Learning and Cloud Architecture for students and faculty. These responsibilities include leading a multi-cloud certification initiative for students. &lt;/p&gt;

&lt;h2&gt;
  
  
  Transcript
&lt;/h2&gt;

&lt;p&gt;Jayesh Ahire: Hello, everyone! Welcome to AI and Guardrails. Today we have with us Mr. Noah Gift.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: As you know, in this podcast, we talk about generative AI and security and how to incorporate generative AI into your security strategies. And how to put specific guardrails in your workflows.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: So Noah is the founder and CEO of Pragmatic AI Labs, and as we were chatting before this, he mentioned that he has done a bunch of interesting gigs in the past, one of those being a bouncer.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: So I will let him introduce himself and go through his journey through tech and AI, specifically.&lt;/p&gt;

&lt;p&gt;Noah Gift: Yeah, hi, happy to be here. So my background is that I've had a lot of different jobs. Early in my career, I worked in live TV when I was a teenager, which was a pretty useful thing to know how to do because I learned how to edit.&lt;/p&gt;

&lt;p&gt;Noah Gift: And then, when I was in college, one of the jobs that I had just for maybe like 6 months was a bouncer at a really large bar, and it wasn't necessarily that I was looking to be a bouncer. It just happened to be the job that I could get so that I could pay the rent while I was in school. And it was pretty fun because I got to work with actually one of the UFC champions, Chuck Liddell. He was one of the bouncers there as well. So it was an interesting kind of accident to work with somebody like that. And then, later in my career, I've worked in TV and film quite a bit and then later startups in the Bay Area. So currently, though, I teach part-time at a couple of different universities, including Duke. And I'm focused on creating content around, I'd say, cloud computing, data engineering, and AI.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Interesting. Yeah, that must have been very interesting to throw people out of the bar.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Yeah. So, as you mentioned, right, you have been in this industry for a while now. And focusing on cloud computing, AI, a bunch of different things. So specific to the topic we are discussing right? What are some of the interesting use cases or impactful ways you have seen gen AI or LLM being used in the industry in general, as well as cybersecurity, for that matter, for the sake of the topic? If you can focus on both of those, it would be great.&lt;/p&gt;

&lt;p&gt;Noah Gift: Yeah, I think what I see right now with generative AI is that there's a lot of hype around it. But some of the hype doesn't really play out, I think, in terms of usefulness where the organizations that are going to have the best return on investment are going to be organizations that already are well organized. So they are using agile, they use DevOps. They have, you know, security best practices like the principle of least privilege, auditing, you know, multiple layers of security. And so where I see generative AI coming into play is just enhancing what you're already doing. So if you're already doing, you know, exploit analysis, then you can use generative AI to help you with exploit analysis. If you're already doing analysis for outliers, looking at strange behaviors, right? You can also use generative AI to help you with that. So I see it less as like some revolutionary change and more as an accelerant to best practices. So if you are not doing best practices, you're gonna have a very poor time getting results from generative AI.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: And that's an excellent point you made there, right? Enhancing the current workflows which you already have in place. And that's where we have been working with a bunch of customers where people are trying to incorporate this in a way where there's some existing workflow, some existing automation, some existing tech in place, with how can we increase the efficacy? How can we make that workflow more efficient?&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: So when it comes to the overall security strategy of an organization, how do you think this fits, and what are some of the interesting use cases or workflows you have seen where gen AI/LLM can have a significant impact?&lt;/p&gt;

&lt;p&gt;Noah Gift: Yeah, I think Google recently did a survey where they asked, I think, 100 C-level people what they think the main use cases are for generative AI, and to summarize, I think it was customer service, developer productivity, also content development, and then potentially automation. So where I see maybe a big takeaway would be in terms of developer productivity, you could use generative AI tools to help you look for security holes in your code. So you know, you could have an assistant, maybe with a specific prompt, and the prompt would look for specific patterns that you're trying to identify like, are you declaring&lt;/p&gt;

&lt;p&gt;variables that you're not using, or are you not freeing up memory, etc. And so I think that would be potentially an easy one would be to enhance what you're already doing with a chatbot. And then, in terms of automation, as I mentioned earlier, potentially, you could have your already good practices, like looking for outlier behavior or auditing logs, etc. You could have generative AI help you look for patterns like, do you see something that looks like it's a specific behavior, etc. So that's where I really see it fitting in is in those four areas of customer service, content development, developer productivity, and automation.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Yeah, absolutely. And so, in the same context, right? Also seeing things like people doing SCA and all of those things, using gen AI, using even analyzing the results which come out of this while having predictions to make sure they prioritize the right things, or having all the context built into things so that the personalization or prioritization of a few of these things can be efficient. And that's as we start using this, as you mentioned, the four use cases as we start adopting some of the strategies in our day-to-day workflows.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: What do you think are challenges when it comes to the CxO or CISOs' point of view, where we're trying to incorporate it into security operations. But there are still challenges, including data protection, privacy, a bunch of different things. Right? What is your view on those specific things?&lt;/p&gt;

&lt;p&gt;Noah Gift: Yeah, I think that there's a real problem with relying on a commercial, large language model technology. And it's probably much better to think about using open-source large language models as a trial. So what you could do is use technologies like LLaMA, for example, which is Mozilla's runner essentially for large language models. And you could start to take a look at potentially using things like MixTURE or some of these open-source models as maybe the start of what you're building in terms of automation. The real issue with these commercial large language models is that we really don't know yet what will happen when you send all this data to these commercial companies. In theory, the data will never get leaked, in practice, there's a lot of data leaks. So if you're really thinking about security, and then you immediately start using commercial third-party systems and start sending them your data. It doesn't really seem like it fits the smell test for doing security best practices to start sending a bunch of data to a company that, in many cases, is actually already being sued for pirating data or really not caring about data. So I think that's a very big risk for organizations.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Yeah. And as you're talking about this specifically and the solution being using some of these open-source technologies to make the process efficient and even reliable to some extent. Have you seen any specific scenarios where any examples around you where people have tried to use this, and they have gotten good results? What did that workflow look like, or what are the considerations still in place while using these open-source technologies and building the end-to-end pipeline on it?&lt;/p&gt;

&lt;p&gt;Noah Gift: I think an easy one potentially is transcribing video to text. I mean, I think that could be an interesting one. So let's say that you were looking for. Let's say you're working for a government, and the government organization wanted you to prevent classified information from being transmitted into the public. Well, an easy technique could be to transcribe all of the video content into text, and then take that text and then analyze it for leaks. So I think that could be a good example of an open-source tool like Whisper, for example, could use that technology.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Got it. And as you started talking about government, one of the aspects around AI which is continuously debated and continuously discussed on different fronts is AI and ethics. And when it comes to ethical considerations, there are definitely some of the challenges. On using this AI at a larger scale, especially when you're dealing with sensitive information when you're dealing with things that can impact a lot of lives. There are definitely regulations coming up and then the EU already has some of the things in place, even the laws coming in the US, Asia, but different places right? But at the same time, when we start adopting gen AI, LLM into our workflows, especially when you're dealing with things like security most of the security tools, or even any of the security pieces, will deal with a bunch of sensitive data in theory as well as in practice. And when it comes to dealing with this whole bunch of data, how do you navigate through this ethical consideration, especially around the privacy and protection?&lt;/p&gt;

&lt;p&gt;Noah Gift: Well, I think a good starting point would be if you're using commercial models to look at what the company is already doing. So I think if we look at different organizations that are&lt;/p&gt;

&lt;p&gt;doing large language models, some of them have already had problems right with ethical issues. And so I would say, avoiding those companies and choosing the companies that have the least amount of litigation, or least amount of concerns about them, would probably be a good choice. So you could rank the different commercial models. So you could pick, you know, 3, 4, different models, just like you would do with a bank, or will you do with any kind of vendor that you deal with, rank them and try to find the companies that seem like they're doing the best with data protection. So I think that's maybe the starting point. Then the second point would be to, you know, really think heavily as well about ways that you can have isolated data when it uses the large language model technology. So if we look at RAG, for example, that's a good example. Where you could have your data protected somewhere talking to a vector database. And there's a large language model that maybe is commercial. If you've implemented it correctly, maybe Amazon Bedrock has a good example of this, or maybe it's a local, large language model. But so I think isolating your data from being exposed to the third-party system. And then there's also things like bias, right where if you're using models that are accentuating what's already happening that was historically bad, like discrimination, then you want to be very careful about putting that into production because you're going to accelerate a problem that society has tried to solve.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Very good points, and irrespective of the industry in place. What is your personal take on the whole ethical aspect, like anything that is controversial, which can give me a quote?&lt;/p&gt;

&lt;p&gt;Noah Gift: So I mean, I think, in terms of the ethical components of large language models. Right now, I think one of the biggest issues is probably piracy. And I think when a large for-profit company is training data intentionally on pirated data, I think that raises a lot of questions about what are their true intentions in terms of helping the world or making a profit, etc. So I think that's probably one of the bigger issues is, are companies respecting intellectual property and are they asking for consent? And really the keyword is consent. And I think we see many examples of a lack of consent when training on data, and even in the case of open-source code, you know, there are different licenses. For example, there's MIT or Apache license, which you can do anything you want. But there's also Creative Commons license as well, where some people have said that their code is non-commercial Creative Commons. So if you've trained your model intentionally on code that's been licensed to be Creative Commons not commercial, then you're basically intentionally breaking the law. There's no other way to put it. I mean, the license specifically says that. So I think those kinds of questions really should be thought about when you're dealing with a company.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Absolutely. And so just one question slightly deviating from this one. Right? When you mentioned the self-hosted models and building some of these things in-house one of the regular things we keep hearing is cost—the cost of running these models internally or whereas the cost of running this from someone else like using third-party services can be less in some of the cases. So any thoughts around this cost of ownership, and how can we manage it to some extent?&lt;/p&gt;

&lt;p&gt;Noah Gift: Well, I think one of the ways to think about it again is thinking about what are your software engineering best practices. So if you have very poor software engineering best practices, you're not doing continuous integration, continuous delivery, you have poor DevOps skills or project management skills, well, you're gonna waste a lot of money on anything you do. So that might be the first place to start, and then in terms of hosting a model. I think it really depends on what it is you're doing. If you're taking an open-source model and you've already got an extremely efficient software system. It may be actually very efficient to host your own model in terms of calling an API. I think one of the problems with calling an API is you have unbounded cost. So if we look at Big O notation, you've got O to the 10 to the N, O to the N squared. When you're basically having O to the N calls. So as your company gets larger and larger, and you keep making calls over and over to an API every time you make a call, you're being charged for it. On the flip side, if the model lives locally, it's O to the 1. Every time you call it, it's just a fixed cost. Like, if you already have a server and you're calling some kind of generative AI workflow, it's essentially a fixed cost that you never have to pay for again. So I think it's really a combination of what you already are doing in&lt;/p&gt;

&lt;p&gt;terms of software engineering best practices as well as how you reason about the number of API calls you're going to make.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: That definitely helps, and I guess that will be helpful for many of the others as well.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: So as we go through all of this, like, we talked about some problems, we talked about some solutions. But at the end, if we want to talk about the future specifically, what do you think will be some of the interesting use cases? Which can become prominent in the next 2 to 3 years?&lt;/p&gt;

&lt;p&gt;Noah Gift: I think probably software engineering will be more of a collaborative workflow with lots of different agents. So it's possible that you have 2 or 3 different chatbots that are watching what you're writing, and maybe one of them is looking for security. Maybe another one is looking for architecture. And then maybe another one is looking for code quality. Right? So it's almost like you could have lots of different people pair programming with you, but not slowing you down, so I think I think we'll probably see more tooling around code. I don't think coding will be automated anytime soon, but I think there will be different workflows.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Interesting and anything specific to security?&lt;/p&gt;

&lt;p&gt;Noah Gift: I think it's the same with security. So in terms of security, anything you're doing already, you could just think of it as adding additional personnel, right? So maybe you have someone when you're looking at security incidents, you could have a chatbot helping you right? Looking at different outliers, giving you ideas, but it's up to you, as the domain expert, to filter all those different ideas, to make sure that they make sense.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: And as you mentioned one thing right? Like, you don't think programmers will be replaced by AI at all. It will be more of a collaborative effort going forward. Do you think like any of the do you think this this applies to most of the jobs that exist right now, like most of the jobs, will turn into that kind of fashion. Or do you feel that some of those things can get replaced at some point? I know we are way diverging the topic at this point. But yeah, to take your view.&lt;/p&gt;

&lt;p&gt;Noah Gift: Yeah, I think anything that requires human judgment. We're a far way off, right? So if it requires an expert to make a decision, I don't think that's going to happen anytime soon. So in the case of security, sure, maybe some things could be automated. But at some point, somebody's still gonna have to make a decision based on that data. And that's where I think there are real gaps in what we've currently got. Same with coding, same with self-driving cars. Right? We're nowhere close to self-driving cars. And so I think the same with the automation. Now, on the flip side, if what you've been doing is cutting and pasting text, yeah, I think you're going to get automated.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Cool absolutely. And as we're talking about this specific point, there are a lot of folks who are interested in learning more about LLM, learning more about gen AI, as this is going to be more collaborative in the future. And we'll need to know these things. Anyways, there's a lot of interest in learning about these things. Right? So what would be your advice for these folks who want to learn more about gen AI, LLM any workflows, or any of the things you have in mind, any courses you have in mind? I know you have been working on one for some time, so.&lt;/p&gt;

&lt;p&gt;Noah Gift: Yeah, so I do a lot of work with Duke on Coursera. I also have some stuff coming up on EdX. That's gonna get announced in Q2, 2024. But basically, if you just look for Coursera Noah Gift, the amount of courses I have is, I think I have roughly 40 courses on Coursera, which is one of the largest amounts of courses by an individual. But a lot of the topics are around real-world, large language model usage, real-world security, real-world cloud computing. So stuff that would really apply to you immediately at work, or maybe would help you get a job. And so that's probably where I would point people is, look at the content I've created on Coursera. There are, I think, 7 courses that are live right now around large language models. It's in the realm of LLM Ops on Coursera, and that would probably be a good spot. I also have some stuff coming up in the next few months on Agile with AI, and also security with AI.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Interesting. Yeah. So that will definitely be helpful. But one of the things which keep coming up. And I have been discussing&lt;/p&gt;

&lt;p&gt;with a bunch of people. So there are a lot of things happening, a bunch of things happening every single day right there. There are new models coming in, new papers being written, so how to keep up with the space, and how to keep ourselves updated every single day. Like, what do you follow, or what will you recommend for people to follow?&lt;/p&gt;

&lt;p&gt;Noah Gift: Yeah, I think that's an interesting question, because it's true that there's so much stuff happening that it feels like how could you possibly keep up, and what I would say is that don't keep up. So what I mean by that is that you can. There's nothing that's urgent in the last 20 years, 30 years that I've been in the tech industry. There's never been a case where, if you didn't know something that one week that you lose your job. That's not how the tech industry works. What's the most important is the principles. So, as I mentioned before, you know, agile, DevOps, all these core principles of software engineering best practices. That's what's important. So if you don't have that, it really doesn't matter what new advance is happening. I mean, if you're thinking that you can basically cut the line and get in front of other people who have deep, expert experience by cutting and pasting things from ChatGPT, you're gonna be in for a deep surprise, right? Because that's not how the world works is cutting and pasting code. Right? It works with automation, continuous improvements, these best practices. So I would say, it's not really that important to be up to date on a week to week basis. I think it's much more important to have a deep portfolio of work that shows software engineering best practices, and then wait a little bit. Let the people filter out what's important, right? Because there's so many people trying to be on top of everything. Just wait a week or two, and then you'll figure out based on what the community has decided is important. And then just do that.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: That's definitely a very interesting take on the whole thing.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Yeah, absolutely. I agree with some of this part, because I remember, like a couple of months back having a discussion. And then one thing that came up was this feels so important because this is one of the most interesting things that has happened in the last decade. Also because everybody was doing exactly the same thing right level. Everything was running in AWS, Azure, Google Cloud day off. All of those things were becoming so standard that there was nothing new to look forward to. And then suddenly the hype started. And now everybody has something to discuss every single day. And that's why I guess people keep falling for keeping up with things, because meetings are happening, but, as you likely pointed out, don't keep up you're trying to see something.&lt;/p&gt;

&lt;p&gt;Noah Gift: Yeah, I mean, I'm not saying that you shouldn't try to be up to date on technology. It's just the time interval. So what I mean is that it's okay to be a month behind. There's absolutely nothing really of value that's going to happen within one month. There really just is not that the core principles are what's important. And I would say, there's actually a huge strategy to letting other people figure out what's important first and again waiting a few weeks. And then, if you know, like somebody figures out a new technology great, then use it. Be lazy. Stop working so hard. Be much lazier.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Yeah, absolutely.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Cool. So mostly that was all I had around the specific topic, right? As we go towards them. I like reading myself. But do you read often, or any fiction nonfiction recommendations which you have gone to recently?&lt;/p&gt;

&lt;p&gt;Noah Gift: Yeah, I read a lot of books, I would say in terms of reading, I think a lot of books around the turn of the century. Like, in terms of 1910, 1920, 1930, have all been kind of interesting to me lately. I think reading Hemingway is an interesting author because he talks about a lot of the things that happened in World War I, World War II, the different changes. So if someone hasn't read Hemingway, I think that could be a good choice for a book to read like, for example, For Whom the Bell Tolls is actually a pretty good book, and maybe even a timely book that talks about the rise of fascism in the 1930s. And how a fascist dictator came to Spain, Franco, and there was a civil war between socialism and fascism. It could be a very interesting book, especially in the world that we're in right now. There's a lot of political unrest, and that could be a good author to read&lt;/p&gt;

&lt;p&gt;, because he covers a lot of the topics that I think are potentially topics that we're re-addressing a hundred years later.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Interesting. Yeah, absolutely I'll personally go through that. But anybody who is interested in the specific era and the specific topic as Noah comments go through it. Cool. So mostly that's it. And thanks for joining us. Thanks for giving the insights. And I think a lot of these things will be very helpful for listeners as well as I. Personally, learned a few important things from the conversation as well. So yeah, thank you, and have a great evening.&lt;/p&gt;

&lt;p&gt;Noah Gift: Alright! Talk to you later. Bye.&lt;/p&gt;

&lt;p&gt;Jayesh Ahire: Bye.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Thanks for listening/ reading the first episode of AI Guardrails podcast. You can find the latest episode here: &lt;a href="https://podcasters.spotify.com/pod/show/ai-guardrails"&gt;https://podcasters.spotify.com/pod/show/ai-guardrails&lt;/a&gt; . We are available on Spotify, Apple Podcast, or any of your favorite podcast apps. What are the next topics you want to listen about? Let us know in comments! &lt;/p&gt;

</description>
      <category>ai</category>
      <category>cloud</category>
      <category>llm</category>
      <category>security</category>
    </item>
    <item>
      <title>Getting started with Observability</title>
      <dc:creator>Jayesh Bapu Ahire</dc:creator>
      <pubDate>Mon, 09 Aug 2021 13:12:06 +0000</pubDate>
      <link>https://dev.to/hypertrace/getting-started-with-observability-3lee</link>
      <guid>https://dev.to/hypertrace/getting-started-with-observability-3lee</guid>
      <description>&lt;p&gt;Most of the tech giants including companies like Amazon, Netflix, started to build their systems using a monolithic architecture because back in the time it was much faster to set up a monolith and get the business moving. But over time as the product matures or fat growth happens, with growing systems the code gets more and more complicated. They all faced this problem and looked at microservices as a solution. One of the biggest benefits of microservices is that each microservice can be developed, scaled, and deployed independently. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hWFr4Dhr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://thumbs.gfycat.com/SpicySpecificArrowcrab-small.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hWFr4Dhr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://thumbs.gfycat.com/SpicySpecificArrowcrab-small.gif" alt="space-1.jpg" width="544" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;With great power comes great responsibility&lt;/em&gt; and that’s what happened when organizations switched to microservices from more monolithic application architectures, they got significant benefits in delivery speed and scalability but on the flip side now they have to deal with the operational complexity in managing, monitoring and securing the new distributed architecture. &lt;/p&gt;

&lt;p&gt;One of the benefits of working with older technologies was the limited set of defined failure modes. Yes, things broke, but you would pretty much know what broke at any given time, or you could find out quickly because a lot of older systems failed in pretty much the same three ways over and over again.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O4EE5h1k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://res.cloudinary.com/practicaldev/image/fetch/s--ql9tvPuO--/c_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_880/https://divante.com/blog/wp-content/uploads/2019/07/Frame-25.png" alt="space-1.jpg" width="800" height="419"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;Microservice interactions at Amazon and Netflix (Image by divante.com)&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Adopting a single deployment platform can address some of the concerns regarding operational complexity but it goes against the philosophy that makes microservice architectures effective. Using APIs to expose core business functionality and facilitate service-to-service communication gives us several control points and makes it easier to deal with complex modern applications. API-driven applications come with their issues like design complexity, visibility, communication, security, etc. which we discussed in detail in &lt;a href="https://dev.to/hypertrace/challenges-with-microservice-and-api-ecosystem-435l"&gt;this blog post&lt;/a&gt;.  &lt;/p&gt;

&lt;p&gt;In a nutshell, Operating distributed systems is hard, not only because of their inherent complexity of the number of components and their distribution but also because of the unpredictability of their failure modes: there are plenty of unknown unknowns. We are left with an imperative to build systems that can be debugged, armed with evidence instead of conjectures.&lt;/p&gt;

&lt;p&gt;With the growing complexity of systems and fast-moving software delivery trains due to modern cloud-native architectures, the possible failure modes became more abundant. Monitoring tools helped us for a while in keeping track of application and infrastructure performance analytics but it isn’t very suitable for modern distributed applications. As we discussed above, developers these days don’t know what their software failure modes are and more unknown unknowns means we won’t put any effort into fixing something because we don’t know the problem exists in the first place. Standard monitoring can only help you with tracking known unknown and it’s very relative. Your monitoring is only as useful as your system is monitorable. &lt;/p&gt;

&lt;p&gt;This monitor-ableness of your modern applications is what we call "&lt;strong&gt;Observability&lt;/strong&gt;". &lt;/p&gt;

&lt;p&gt;In control theory, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Observability is defined as a measure of how well internal states of a system can be inferred from knowledge of that system’s external outputs. Simply put, observability is how well you can understand your complex system.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Metrics, events, logs, and traces—or MELT—are at the core of Observability. But, Observability is about a whole lot more than just data.&lt;/p&gt;

&lt;p&gt;Observability is all about the ability to ask abstract questions to your system and find the answer without the need of opening a black box. Like, consider your process of placing an order on Amazon failed due to query timeout so What characteristics did the queries that timed out at 500ms share in common? Service versions? Browser plugins? Here, Instrumentation produces data which is what we call telemetry, and querying that data answers our questions.&lt;/p&gt;

&lt;p&gt;Whenever we talk about Observability, we also talk about metrics, logs, and traces which are three pillars of Observability. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Metrics&lt;/strong&gt;: Aggregated summary statistics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logs&lt;/strong&gt;: Detailed debugging information emitted by processes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distributed Tracing&lt;/strong&gt;: Provides insights into the full lifecycles, aka traces of requests to a system, allowing you to pinpoint failures and performance issues.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will discuss all three of these in detail in the upcoming articles in this series. &lt;/p&gt;

&lt;h3&gt;
  
  
  In a nutshell,
&lt;/h3&gt;

&lt;p&gt;This blog post was about giving you a brief overview of Observability and help you understand why you need Observability. In the upcoming blog posts, we will talk about metrics, logs, and traces and also see different applications of modern Observability for modern distributed applications. &lt;/p&gt;

&lt;p&gt;Until then, if your organization is using microservice architecture and exploring Observability solutions, feel free to check out &lt;a href="https://github.com/hypertrace/hypertrace"&gt;Hypertrace&lt;/a&gt;, which is a modern API Observability platform. &lt;a href="https://bit.ly/hypertrace-community-slack"&gt;join our slack community&lt;/a&gt; to interact with folks who are on the same microservice transition journey and are exploring Observability. &lt;/p&gt;

&lt;h4&gt;
  
  
  References
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.bmc.com/blogs/observability-vs-monitoring/"&gt;https://www.bmc.com/blogs/observability-vs-monitoring/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.infoworld.com/article/3607980/what-is-observability-software-monitoring-on-steroids.html"&gt;https://www.infoworld.com/article/3607980/what-is-observability-software-monitoring-on-steroids.html&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://en.wikipedia.org/wiki/Observability"&gt;https://en.wikipedia.org/wiki/Observability&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.brighttalk.com/webcast/18765/499011"&gt;https://www.brighttalk.com/webcast/18765/499011&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://anchor.fm/talkin-observability"&gt;https://anchor.fm/talkin-observability&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>monitoring</category>
      <category>discuss</category>
      <category>opensource</category>
      <category>devops</category>
    </item>
    <item>
      <title>Challenges with Microservice and API ecosystem</title>
      <dc:creator>Jayesh Bapu Ahire</dc:creator>
      <pubDate>Tue, 01 Jun 2021 10:59:34 +0000</pubDate>
      <link>https://dev.to/hypertrace/challenges-with-microservice-and-api-ecosystem-435l</link>
      <guid>https://dev.to/hypertrace/challenges-with-microservice-and-api-ecosystem-435l</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/hypertrace/evolution-of-api-and-microservice-ecosystem-part-1-399a"&gt;last post of this series&lt;/a&gt;, we discussed the evolution of microservices and API ecosystems and what are the different benefits microservices and APIs offer when it comes to building large, scalable, and efficient systems. As I said in the last part (actually as uncle Ben said this), with great power comes great responsibility and the same thing applies to microservices and API architectures. These complex systems bring a lot of challenges with them and we will discuss those challenges in this part. &lt;/p&gt;

&lt;p&gt;There are many challenges when it comes to adopting microservices or dealing with microservice architectures. We will be discussing a few of the important ones in this blog post. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; Complexity comes in different forms, either it can be design complexity or operational complexity. In the case of microservice architecture design, you have to deal with both of those. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Design:&lt;/strong&gt; When it comes to distributed systems, complexity is given. But, one way to mitigate this complexity is to create optimal abstractions. The effective modularization of the complex monolith can be done with proper and accurate service boundary definitions but creating those service boundary definitions is hard as well. That’s where design thinking comes into the picture. 
Defining clear boundaries and responsibility for each service is complicated and developers have to use a data-centric approach to arrive at a proper conclusion here. 
As compared to microservice design, API design is mature and has defined standard practices. API design thinking helps to identify the right service boundaries and helps to establish loose coupling between services so that implementation details don’t leak through.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operational:&lt;/strong&gt; The main benefit of using microservices is you can develop, deploy and upgrade every service independently. This same benefit becomes the biggest pain point for many small teams who are trying to adopt microservice architectures as now there are maybe 60 services to be managed by 10 people and that operational load is very high. Maintaining, and continuously monitoring these complex architectures becomes very hard after some point. Some of the major pain points in operations management are:

&lt;ul&gt;
&lt;li&gt;Monitoring&lt;/li&gt;
&lt;li&gt;Optimizations and scaling&lt;/li&gt;
&lt;li&gt;Fault tolerance&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Communication:&lt;/strong&gt; Microservices have to communicate with each other to get desired things done. There need to be some infrastructure layer configs to enable resource sharing across services which ultimately enables these microservices to talk to each other. These configurations, if not optimized properly can result in high latency and error rate. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security:&lt;/strong&gt; As discussed in the above point, microservices use infrastructure layer configs to talk to each other. This along with multi-environment (multi-cloud as well as on-prem) deployments, results in even less visibility and creates many vulnerable points. This collectively increases the risk of a security attack. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Microservice frameworks in general come with many challenges when it comes to security, some of them are as follows:&lt;br&gt;
    - Data is distributed so maintain privacy, confidentiality, and integrity is hard.&lt;br&gt;
    - Setting up access control and service level authentication is tricky and makes services more prone to attack sometimes.&lt;br&gt;
    - Finding the origin of the attack and affected services can be tricky depending on the size of the architecture. &lt;/p&gt;

&lt;p&gt;Most of the challenges we discussed above have some common origins and the most common one being less visibility in the system due to complex architectures and infrastructure. Observability into these microservice architectures and APIs can help us to understand these complex interactions better and help us solve design issues, operational issues, communication issues as well as security issues. &lt;/p&gt;

&lt;p&gt;How? Going forward in this series, we will discuss API Observability and how we can use it to solve these complex but very important issues in API and Microservices ecosystem. &lt;/p&gt;

&lt;p&gt;Until then, if your organization is using microservice architecture and exploring Observability solutions, feel free to check out &lt;a href="https://github.com/hypertrace/hypertrace"&gt;Hypertrace&lt;/a&gt;, which is a modern API Observability platform. If you are in transition and want to learn more about Observability and instrumentation, &lt;a href="https://bit.ly/hypertrace-community-slack"&gt;join our slack community&lt;/a&gt; to interact with folks who have been through this transition or going through this transition. &lt;/p&gt;

&lt;h3&gt;
  
  
  References:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.mertech.com/blog/7-api-management-challenges-and-how-to-solve-them"&gt;https://www.mertech.com/blog/7-api-management-challenges-and-how-to-solve-them&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.bmc.com/blogs/microservices-challenges-when-to-avoid/"&gt;https://www.bmc.com/blogs/microservices-challenges-when-to-avoid/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gartner.com/en/documents/302868"&gt;https://www.gartner.com/en/documents/302868&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.broadcom.com/doc/microsurfaces-the-role-of-apis-in-a-microservice-architecture"&gt;https://docs.broadcom.com/doc/microsurfaces-the-role-of-apis-in-a-microservice-architecture&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.thoughtworks.com/insights/blog/microservices-nutshell"&gt;https://www.thoughtworks.com/insights/blog/microservices-nutshell&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dzone.com/articles/challenges-in-implementing-microservices"&gt;https://dzone.com/articles/challenges-in-implementing-microservices&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.infoworld.com/article/3075880/microservice-architecture-is-agile-software-architecture.html"&gt;https://www.infoworld.com/article/3075880/microservice-architecture-is-agile-software-architecture.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>opensource</category>
      <category>cloud</category>
      <category>discuss</category>
      <category>architecture</category>
    </item>
    <item>
      <title>4 Easy Ways to Contribute to an Open Source Project</title>
      <dc:creator>Jayesh Bapu Ahire</dc:creator>
      <pubDate>Thu, 20 May 2021 10:35:30 +0000</pubDate>
      <link>https://dev.to/hypertrace/4-easy-ways-to-contribute-to-an-open-source-project-3f0d</link>
      <guid>https://dev.to/hypertrace/4-easy-ways-to-contribute-to-an-open-source-project-3f0d</guid>
      <description>&lt;p&gt;Want to contribute to an Open Source project but don't know where to start? You're in luck! This article will explain 4 easy ways you can contribute to an Open Source project as well as a few Hypertrace contributions you can make as examples.&lt;/p&gt;

&lt;p&gt;Let's get started, shall we?&lt;/p&gt;

&lt;h2&gt;
  
  
  Documentation
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi0.wp.com%2Fmedia2.giphy.com%2Fmedia%2FxT4uQwLt2AyurOGWFW%2Fgiphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi0.wp.com%2Fmedia2.giphy.com%2Fmedia%2FxT4uQwLt2AyurOGWFW%2Fgiphy.gif" alt="documenting for OSS project"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do you like to write. Do you like to share with people? As the face of an open source project, documentation is one of the most important contributions. Every open source project welcomes contributions to documentation. If you are just getting started with Distributed Tracing or Hypertrace and felt that we were missing some documentation details especially on our Getting Started page, you can go ahead and raise a pull request in &lt;a href="https://github.com/hypertrace/hypertrace-docs-website" rel="noopener noreferrer"&gt;Hypertrace-docs&lt;/a&gt;. We will be more than happy to review and add your suggestions.&lt;/p&gt;

&lt;p&gt;Here are few important documentation categories you can contribute to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Getting Started and Installation&lt;/li&gt;
&lt;li&gt;FAQs&lt;/li&gt;
&lt;li&gt;UI &amp;amp; Platform Overview&lt;/li&gt;
&lt;li&gt;Anything else users can see&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Code/ Features/ Bug fixes
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsteamcdn-a.akamaihd.net%2Fsteamcommunity%2Fpublic%2Fimages%2Fclans%2F32755091%2F4756e5ee81cd570346e2cc9ff9d08af36e51518f.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsteamcdn-a.akamaihd.net%2Fsteamcommunity%2Fpublic%2Fimages%2Fclans%2F32755091%2F4756e5ee81cd570346e2cc9ff9d08af36e51518f.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You like to code and would love to contribute code to an open source project? Here are the few ways to find an issue you want to fix or a feature you want to add.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the GitHub &lt;code&gt;Issues&lt;/code&gt; tab of the open source project repository you would like to contribute to. For Hypertrace, you can find open issues &lt;a href="https://github.com/hypertrace/hypertrace/issues" rel="noopener noreferrer"&gt;here&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;If you are contributing for the first time,, look for issues with the &lt;code&gt;good first issue&lt;/code&gt; label. Otherwise just find something that interests you and start working on it.&lt;/li&gt;
&lt;li&gt;Do you have a feature/enhancement idea that you want to work on? Open an issue or start a &lt;a href="https://github.com/hypertrace/hypertrace/discussions/categories/ideas" rel="noopener noreferrer"&gt;discussion&lt;/a&gt; thread. Once you get some feedback, then start working!&lt;/li&gt;
&lt;li&gt;If you can't find something then you can also write unit tests if  they are missing. No maintainer will say no to more/better tests in the suite. Here's an article to help you get started: &lt;a href="https://www.toptal.com/qa/how-to-write-testable-code-and-why-it-matters" rel="noopener noreferrer"&gt;https://www.toptal.com/qa/how-to-write-testable-code-and-why-it-matters&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;While trying the project, if you find a bug, report them right away as that itself is a nice contribution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are first time contributor, here are few articles which might help you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://towardsdatascience.com/five-tips-for-contributing-to-open-source-software-8fd3d6f5606f" rel="noopener noreferrer"&gt;Five Tips for Contributing to Open Source&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://medium.com/@kevinjin/contributing-to-open-source-walkthrough-part-0-b3dc43e6b720" rel="noopener noreferrer"&gt;Contributing to Open Source&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;H&lt;a href="https://css-tricks.com/how-to-contribute-to-an-open-source-project" rel="noopener noreferrer"&gt;ow to Contribute to Open Source&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.freecodecamp.org/news/the-definitive-guide-to-contributing-to-open-source-900d5f9f2282" rel="noopener noreferrer"&gt;The Definitive Guide to Contributing to Open Source&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Evangelism
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F720%2F1%2A4oAYsSrlX9nXALxkKG9ZNA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F720%2F1%2A4oAYsSrlX9nXALxkKG9ZNA.gif" alt="Evangelising OSS projects"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Would you like to share your experience using an open source project? Enterprise products use marketing teams to get the word out about themselves but open source projects depend upon users. You can join the Hypertrace user community &lt;a href="https://hypertrace.org/get-started" rel="noopener noreferrer"&gt;here&lt;/a&gt;. Once you join the community, you can talk with other users about their experience and perhaps even chat with the creators of the project. Once you are comfortable, you can write a blog post explaining how the project helped you and what problems it solved.&lt;/p&gt;

&lt;p&gt;Similarly, you can also share your experience in a meetup or online event or create a tutorial video which will help others learn about the project.&lt;/p&gt;

&lt;p&gt;If you want to write a blog post about Hypertrace, take a look at blog.hypertrace.org and let us know what you are interested in writing about. You can reach in the Welcome channel on Slack &lt;/p&gt;

&lt;h2&gt;
  
  
  Helping others
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2F6yxIP39EMwP7IlIA28%2F200.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2F6yxIP39EMwP7IlIA28%2F200.gif" alt="Always help each other"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Are you experienced but don't have time to invest? Be a part of Slack and GitHub communities and answer questions there. Or share your thoughts on open issues and feature ideas.&lt;/p&gt;

&lt;p&gt;You can also help in reviewing PRs, moderating discussions or reporting bugs.&lt;/p&gt;

&lt;p&gt;Videos are very popular these days. A short tutorial or sample app can help others build deeper understanding about the project. Even your smallest contribution can have a bigger impact on an open source project.&lt;/p&gt;

&lt;p&gt;So, what are you waiting for? Pick up any of these ideas and dive into the world of Open Source. If you ask me, I will tell you to get started with documentation as it will give you a deeper understanding of the project and help you build confidence too.&lt;/p&gt;

&lt;h3&gt;
  
  
  On that note,
&lt;/h3&gt;

&lt;p&gt;We are looking for contributors to help us build &lt;a href="https://github.com/hypertrace/hypertrace" rel="noopener noreferrer"&gt;Hypertrace&lt;/a&gt;, an Open Source distributed tracing and Observability platform. And any contributions you make are greatly appreciated. Feel free to reach out to us on &lt;a href="https://github.com/hypertrace/hypertrace/discussions" rel="noopener noreferrer"&gt;GitHub Discussions&lt;/a&gt; or &lt;a href="https://join.slack.com/t/hypertrace/shared_invite/zt-oln0psj9-lm1CSkXE1vsWdcw6YKWGDg" rel="noopener noreferrer"&gt;join us on slack&lt;/a&gt; to learn more. &lt;/p&gt;

</description>
      <category>opensource</category>
      <category>contributorswanted</category>
      <category>codenewbie</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Evolution of API and Microservice ecosystem</title>
      <dc:creator>Jayesh Bapu Ahire</dc:creator>
      <pubDate>Tue, 18 May 2021 14:30:04 +0000</pubDate>
      <link>https://dev.to/hypertrace/evolution-of-api-and-microservice-ecosystem-part-1-399a</link>
      <guid>https://dev.to/hypertrace/evolution-of-api-and-microservice-ecosystem-part-1-399a</guid>
      <description>&lt;p&gt;In this first installment in a series on the evolution of API and microservices ecosystem, we will learn about how microservices and APIs became industry standards and what are different benefits microservices offer. We will explore different challenges with this ecosystem and how to solve them in the second part of this series. &lt;/p&gt;

&lt;p&gt;Most of the tech giants including companies like Amazon, Netflix, started to build their systems using a monolithic architecture because back in the time it was much faster to set up a monolith and get the business moving. But over time as the product matures or fat growth happens, with growing systems the code gets more and more complicated. They all faced this problem and looked at microservices as a solution. One of the biggest benefits of microservices is that each microservice can be developed, scaled, and deployed independently. You can replace or upgrade any part of the system without affecting the whole system. &lt;/p&gt;

&lt;p&gt;But, &lt;em&gt;what is microservice architecture?&lt;/em&gt; &lt;a href="https://www.martinfowler.com/articles/microservices.html"&gt;As called out by James Lewis and Martin Fowler&lt;/a&gt;, The term "Microservice Architecture" has sprung up over the last few years to describe a particular way of designing software applications as suites of independently deployable services. While there is no precise definition of this architectural style, there are certain common characteristics around organization around business capability, automated deployment, intelligence in the endpoints, and decentralized control of languages and data. &lt;br&gt;
I hope it’s not that hard to guess but these microservices talk to each other via APIs and two of the most commonly used protocols are HTTP request-response with resource APIs and lightweight messaging. Although as I mentioned above, companies like Netflix and Amazon have been using microservices for quite a long time, many small organizations have also started adopting API first or microservice driven architectures recently, because &lt;a href="https://www.infoq.com/articles/web-apis-business-perspective/"&gt;APIs have become the heart of the global tech industry in the past decade.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Rise of Microservices
&lt;/h2&gt;

&lt;p&gt;Let’s dive more into the origins of APIs and Microservices as they share a common origin story. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rise of service-oriented architectures&lt;/li&gt;
&lt;li&gt;Rise of cloud computing and managed services&lt;/li&gt;
&lt;li&gt;Rise of decentralization movement&lt;/li&gt;
&lt;li&gt;Rise of Agile movement&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Rise of service-oriented architectures
&lt;/h3&gt;

&lt;p&gt;As we all know, building distributed systems is hard and managing them is even harder. The rise of the web back in the days opened the doors to innovate the way we build distributed systems and that’s where Service based architecture came into the picture. SOA was defined as a style of multi-tier computing that helps organizations share logic and data among multiple applications and usage modes. [as defined by &lt;a href="https://www.gartner.com/en/documents/302868"&gt;Gartner&lt;/a&gt; ]&lt;/p&gt;

&lt;p&gt;Though a failed movement back in the time, SOA surely helped a lot in initiating microservice movements, and even organizations like Netflix and Amazon were calling their architectures SOAs before the microservice movement. Due to the centralized nature of ESB topology and some other reasons, SOAs increased complexity and introduced bottlenecks, and the costs of implementing an SOA infrastructure (based on the ESB, registry, and service platform template) were excessive.  &lt;/p&gt;

&lt;p&gt;Due to these problems, people started looking for better alternatives.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rise of cloud computing and managed services
&lt;/h3&gt;

&lt;p&gt;The rise of RESTful Web APIs arose as a lighter-weight alternative to SOAP services. -- a style of interconnecting applications that had evolved organically on the Web --. The distributed nature of cloud infrastructure challenged the placement of the centralized ESB topology.&lt;br&gt;
Everyone started adopting microservices due to the benefits they provided and here we are today looking at complex modern architectures. Cloud computing helped in removing barriers for deployment and provided a variety of new use-cases for APIs. It worked out as a novel platform for deploying more granular API-fronted application components. Cloud services provided another reason to move towards more service-oriented and modular deployment architectures. &lt;/p&gt;

&lt;h3&gt;
  
  
  Rise of decentralization movement
&lt;/h3&gt;

&lt;p&gt;As we discussed earlier, at one point in time, service-oriented computing became an increasingly popular paradigm for modeling and building distributed systems in open and heterogeneous environments. However, proposed service-oriented architectures are typically based on centralized components, such as service registries or service brokers, that introduce reliability, management, and performance issues. &lt;/p&gt;

&lt;p&gt;During this whole time, the capabilities and scale of distributed systems have increased. The trend towards decentralization in both the system itself as well as the supporting organization started to catch up and the decentralization moment started. &lt;/p&gt;

&lt;h3&gt;
  
  
  Rise of Agile movement
&lt;/h3&gt;

&lt;p&gt;In his blog post titled “&lt;a href="http://www.codingthearchitecture.com/2013/09/03/what_is_agile_software_architecture.html"&gt;Coding the Architecture&lt;/a&gt;”, &lt;a href="https://twitter.com/simonbrown"&gt;Simon Brown&lt;/a&gt; pointed out that agile architecture does not naturally emerge from agile development practices. Rather, it must be consciously sought. Note that his description of agile software architecture is a perfect match for microservice architecture. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If we look at the characteristics of agile software architecture, we tend to think of something that is built using a collection of small, loosely coupled components/services that collaborate together to satisfy an end-goal. This style of architecture provides agility in a number of ways. Small, loosely coupled components/services can be built, modified, and tested in isolation, or even ripped out and replaced depending on how requirements change. This style of architecture also lends itself well to a very flexible and adaptable deployment model, since new components/services can be added and scaled if needed.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The agile software movement arose as a reaction to the same centralized approach to enterprise IT that hampered the SOA movement. Agile’s popularity and success in software development led to the CI/CD approach to software deployment, followed by the cultural philosophy of the DevOps movement. Between CI/CD, DevOps, agile development, and progressive delivery, the software delivery train also started speeding up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Microservices
&lt;/h2&gt;

&lt;p&gt;Now that we have gone through the reasons behind the rise of Microservices, Let’s try to understand what business value microservices provide. &lt;/p&gt;

&lt;p&gt;The main reason that drives the move to microservices in any organization is speed and agility at scale which helps in software delivery. Reducing cross-team coordination, building diverse language applications, flexible deployments, enhanced manageability are some of the additional perks that organizations with microservice architectures enjoy. &lt;/p&gt;

&lt;p&gt;Many of the benefits which come with Microservice architectures are mostly due to the API-first nature of microservices and here are a few of them: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Composability:&lt;/strong&gt; When services are published through an API, it is easier to use them in multiple business contexts to assist in various business processes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Testability:&lt;/strong&gt; When services are accessible over a network boundary, it is easier to isolate tests and exercise individual components of the system&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability:&lt;/strong&gt; Each microservice can be scaled autonomously without disrupting the other microservices that comprise the application. When demand increases, you only need to upgrade or divert more resources to the microservice affected by the increasing demands. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evolvability:&lt;/strong&gt; When services are exposed through an API, implementation details can be hidden from the consumer, making it easier to change components without impacting dependent parts of the system &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comprehensibility:&lt;/strong&gt; When a complex system is broken down into modular APIs, it is easier to understand the overall business functionality of the system, which helps in both designing and maintaining the system&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatability:&lt;/strong&gt; Along with the data plane API benefits above, control plane APIs allow automation in the deployment and management of microservices, thus increasing the velocity of software delivery&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But as we know &lt;em&gt;with great power comes great responsibility&lt;/em&gt; and the same thing applies to microservices and API ecosystems as well. These complex systems bring a lot of challenges with them and we will discuss those challenges in the next part of this blog post. &lt;/p&gt;

&lt;p&gt;Until then, if your organization is using microservice architecture and exploring Observability solutions, feel free to check out our Open Source Observability platform &lt;a href="https://github.com/hypertrace/hypertrace"&gt;Hypertrace&lt;/a&gt;. If you are in transition and want to learn more about Observability or want to contribute to Hypertrace, &lt;a href="https://bit.ly/hypertrace-community-slack"&gt;join our slack community&lt;/a&gt; to interact with folks who have been through this transition or going through this transition. &lt;/p&gt;

&lt;h3&gt;
  
  
  References:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.martinfowler.com/articles/microservices.html"&gt;https://www.martinfowler.com/articles/microservices.html&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.infoq.com/articles/web-apis-business-perspective/"&gt;https://www.infoq.com/articles/web-apis-business-perspective/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gartner.com/en/documents/302868"&gt;https://www.gartner.com/en/documents/302868&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.infoworld.com/article/3080611/learning-from-soa-5-lessons-for-the-microservices-era.html"&gt;https://www.infoworld.com/article/3080611/learning-from-soa-5-lessons-for-the-microservices-era.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.broadcom.com/doc/microsurfaces-the-role-of-apis-in-a-microservice-architecture"&gt;https://docs.broadcom.com/doc/microsurfaces-the-role-of-apis-in-a-microservice-architecture&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.thoughtworks.com/insights/blog/microservices-nutshell"&gt;https://www.thoughtworks.com/insights/blog/microservices-nutshell&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://link.springer.com/article/10.1007/s12083-009-0062-6"&gt;https://link.springer.com/article/10.1007/s12083-009-0062-6&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.infoworld.com/article/3075880/microservice-architecture-is-agile-software-architecture.html"&gt;https://www.infoworld.com/article/3075880/microservice-architecture-is-agile-software-architecture.html&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cloud</category>
      <category>architecture</category>
      <category>kubernetes</category>
      <category>agile</category>
    </item>
    <item>
      <title>The ethics of AI</title>
      <dc:creator>Jayesh Bapu Ahire</dc:creator>
      <pubDate>Wed, 06 May 2020 11:12:32 +0000</pubDate>
      <link>https://dev.to/twilio/the-ethics-of-ai-3ikf</link>
      <guid>https://dev.to/twilio/the-ethics-of-ai-3ikf</guid>
      <description>&lt;p&gt;Whether in daily mobility, in industrial applications or in the form of assistance solutions at home: Artificial Intelligence permeates an ever wider range of our lives. It is associated with great hopes, but it also raises fears. Therefore, the call for ethical guidelines regarding the new technologies is becoming increasingly louder.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TJ0Sk5g6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://media1.giphy.com/media/l4pTsNgkamxfk2ZLq/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TJ0Sk5g6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://media1.giphy.com/media/l4pTsNgkamxfk2ZLq/giphy.gif" alt="" width="480" height="264"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;There are various questions we need to find answers to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How can the “right” values be integrated into technical action? &lt;/li&gt;
&lt;li&gt;Can and may AI determine what is right? &lt;/li&gt;
&lt;li&gt;How to ensure that AI is developed, used and provided in the service of mankind? &lt;/li&gt;
&lt;li&gt;And how can the decision-making processes of AI, including wrong decisions, be made transparent, given the huge, complex amounts of data?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We organized a panel discussion on what is importance of implementing ethical practices within your predictive models, data workflows, products and AI research. I was the part of the panel along with &lt;a href="https://dev.to/newfront"&gt;Scott Haines&lt;/a&gt;, &lt;a href="https://dev.to/lizziepika"&gt;Lizzie Siegle&lt;/a&gt; and &lt;a href="https://dev.to/thenickwalsh"&gt;Nick Walsh&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;In this article, we will go through some of the points we discussed with panel and their views on various topics along with my view on each topic.&lt;/p&gt;

&lt;p&gt;For the sake of simplicity, we will discuss further details into 3 broad categories:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fairness &amp;amp; Bias&lt;/li&gt;
&lt;li&gt;Interpretability &amp;amp; Explainability&lt;/li&gt;
&lt;li&gt;Privacy&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's jump into it!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Fairness &amp;amp; Bias:
&lt;/h2&gt;

&lt;p&gt;Bias is often identified as one of the major risks associated with artificial intelligence (AI) systems. As A Survey on Bias and Fairness in Machine Learning suggests, there are clear benefits to algorithmic decision-making; unlike people, machines do not become tired or bored, and can take into account orders of magnitude more factors than people can. However, like people, algorithms are vulnerable to biases that render their decisions “unfair”. In the context of decision-making, fairness is the absence of any prejudice or favoritism toward an individual or a group based on their inherent or acquired characteristics. Thus, an unfair algorithm is one whose decisions are skewed toward a particular group of people.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SgsrAi4h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://languagelog.ldc.upenn.edu/myl/SMBC_AI_Firing.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SgsrAi4h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://languagelog.ldc.upenn.edu/myl/SMBC_AI_Firing.png" width="684" height="813"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The public discussion about bias in such scenarios often assigns blame to the algorithm itself. The algorithm, it is said, has made the wrong decision, to the detriment of a particular group. But this claim fails to take into account the human component: People perceive bias through the subjective lens of fairness.&lt;/p&gt;

&lt;p&gt;So, Bias occurs when we discriminate against (or promote) a defined group consciously or unconsciously, and it can creep into an AI system as a result of skewed data or an algorithm that does not account for skewed data. Fairness, meanwhile, is a social construct. And in fact, when people judge an algorithm to be “biased,” they are often conflating bias and fairness: They are using a specific definition of fairness to pass judgment on the algorithm. &lt;/p&gt;

&lt;p&gt;No AI system can be universally fair or unbiased as there are more than 20 definitions of fairness and it is impossible for every decision to be fair to all parties. But we can design these systems to meet specific fairness goals, thus mitigating some of the perceived unfairness and creating a more responsible system overall.&lt;/p&gt;

&lt;p&gt;This discussion also brings us to a question if we can relate trolley problem here? &lt;/p&gt;

&lt;p&gt;Let's first understand what is trolley problem:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A runaway trolley is heading down the tracks toward five workers who will all be killed if the trolley proceeds on its present course. Adam is standing next to a large switch that can divert the trolley onto a different track. The only way to save the lives of the five workers is to divert the trolley onto another track that only has one worker on it. If Adam diverts the trolley onto the other track, this one worker will die, but the other five workers will be saved.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--54SKUErX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://thumbs.gfycat.com/SneakyUnrealisticFlee-size_restricted.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--54SKUErX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://thumbs.gfycat.com/SneakyUnrealisticFlee-size_restricted.gif" alt="" width="500" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Should Adam flip the switch, killing the one worker but saving the other five?&lt;/em&gt;&lt;br&gt;
The original trolley problem came from a paper about the ethics of abortion, written by English philosopher Phillipa Foot. It’s the third of three increasingly complicated thought experiments she offers to help readers assess whether intentionally harming someone (e.g. choosing to hit them) is morally equivalent to merely allowing harm to occur (choosing not to intervene to stop them getting hit). &lt;/p&gt;

&lt;p&gt;Apart from above version there are various modern day implications of this problem which are considered while social psychology studies conducted by different universities. You can try &lt;a href="http://moralmachine.mit.edu/"&gt;Moral Machine&lt;/a&gt; by MIT. &lt;/p&gt;

&lt;p&gt;Who else is ready to accept this as a solution?&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OS31KDj1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://thumbs.gfycat.com/HomelyIckyBlackfly-size_restricted.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OS31KDj1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://thumbs.gfycat.com/HomelyIckyBlackfly-size_restricted.gif" alt="" width="444" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Jokes apart, But is this applicable in case of AI?&lt;br&gt;
&lt;a href="https://qz.com/author/simon-beard/"&gt;Simon Beard&lt;/a&gt; explains in his article that this philosophical issue is irrelevant to self-driving cars because they don’t have intentions. Those who think intentions are morally significant tend to hold strong views about our freedom of will. But machines don’t have free will (at least not yet). Thus, as far back as Isaac Asimov’s three laws of robotics, we’ve recognized that for machines to harm someone—or “through inaction, allow a human being to come to harm”—is morally equivalent.&lt;/p&gt;

&lt;p&gt;Which seems logical explanation as AI because trolley problem is very situational and AI works in real-world scenarios which are extremely uncertain and you can't certainly apply universal laws of ideal behavior to machines. AI tends to learn continuously from it's mistake and try to achieve a state with better decision making capabilities with each iteration.&lt;/p&gt;

&lt;p&gt;This brings us to second point of our discussion that how important explainability and Interpretability of decisions made by AI is considering ever increasing lack of transparency has only become more visible, midst of techlash.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Interpretability &amp;amp; Explainability
&lt;/h2&gt;

&lt;p&gt;When it comes to machine learning and artificial intelligence, explainability and interpretability are often used interchangeably.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GSxNoCtQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgflip.com/2yc1nf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GSxNoCtQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgflip.com/2yc1nf.jpg" alt="" width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;According to &lt;a href="https://arxiv.org/abs/1706.07269"&gt;Miller&lt;/a&gt;, interpretability is the degree to which a human can understand the cause of a decision. Interpretable predictions lead to better trust and provide insight into how the model may be improved. We can also define intepretability as the extent to which we are able to predict what is going to happen, given a change in input or algorithmic parameters. &lt;/p&gt;

&lt;p&gt;Explainability, meanwhile, is the extent to which the internal mechanics of a machine or deep learning system can be explained in human terms. It’s easy to miss the subtle difference with interpretability, but consider it like this: interpretability is about being able to discern the mechanics without necessarily knowing why. Explainability is being able to quite literally explain what is happening.&lt;/p&gt;

&lt;p&gt;Let's understand using example, consider a chemistry experiment: Knowing that when you mix 1 gm. of blue colour chemical with 100 ml of liquid you get pink colour solution and this is interpretability but understanding exact chemical reaction for this experiment means explanability.&lt;/p&gt;

&lt;p&gt;Interpretability &amp;amp; Explanability are not required if the model has no significant impact or when the problem is well studied. This might also enable people or programs to manipulate the system but if we’re unable to properly deliver improved interpretability, and ultimately explainability, in our algorithms, we’ll seriously be limiting the potential impact of artificial intelligence. Which would be a shame.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BArGyyD0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://media.wired.com/photos/5c871a4592cce301f3dfae3a/191:100/w_955%2Ch_500%2Cc_limit/TopArt_Final_04.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BArGyyD0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://media.wired.com/photos/5c871a4592cce301f3dfae3a/191:100/w_955%2Ch_500%2Cc_limit/TopArt_Final_04.gif" alt="" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's discuss few methods to increase the interpretability of complex ML models.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;LIME or Local Interpretable Model-Agnostic Explanations&lt;/strong&gt;, is a method developed in the paper &lt;a href="https://arxiv.org/abs/1602.04938"&gt;Why should I trust you?&lt;/a&gt; for interpreting individual model predictions based on locally approximating the model around a given prediction. The researchers explain that LIME can explain “the predictions of any classifier in an interpretable and faithful manner, by learning an interpretable model locally around the prediction.”&lt;br&gt;
What this means in practice is that the LIME model develops an approximation of the model by testing it out to see what happens when certain aspects within the model are changed. Essentially it’s about trying to recreate the output from the same input through a process of experimentation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;DeepLIFT (Deep Learning Important FeaTures)&lt;/strong&gt; is another method which serves as a recursive prediction explanation method for deep learning.  This method decomposes the output prediction of a neural network on a specific input by backpropagating the contributions of all neurons in the network to every feature of the input. DeepLIFT assigns contribution scores based on the difference between activation of each neuron and its ‘reference activation’. DeepLIFT can also reveal dependencies which are missed by other approaches by optionally giving separate consideration to positive and negative contributions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Layerwise Relevance Propagation (LRP)&lt;/strong&gt; is a technique for determining which features in a particular input vector contribute most strongly to a neural network’s output. The technique was originally described in &lt;a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0130140"&gt;this paper&lt;/a&gt;. It defines a set of constraints to derive a number of different relevance propagation functions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Algorithmic generalization:&lt;/strong&gt; Improving generalization is not as easy as it sounds. Sometimes Models feel secondary when we realise that most ML engineering is applying algorithms in a very specific way to uncover a certain desired outcome. However, by shifting this attitude to consider the overall health of the algorithm, and the data on which it is running, you can begin to set a solid foundation for improved interpretability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pay attention to feature importance:&lt;/strong&gt; Feature importance tries to answer question, what features have the biggest impact on predictions. Looking closely at the way the various features of your algorithm have been set is a practical way to actually engage with a diverse range of questions, from business alignment to ethics. Debate and discussion over how each feature should be set might be a little time-consuming, but having that tacit awareness that different features have been set in a certain way is nevertheless an important step in moving towards interpretability and explainability.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, we explored the views around to open a black-box or not! Now, we have to think about privacy aspect which is one of the major concern in today's world.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/lea5DJxF4Lz4k/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/lea5DJxF4Lz4k/giphy.gif" alt="" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Privacy
&lt;/h2&gt;

&lt;p&gt;When we look around for application areas of AI, we find that much of the most privacy-sensitive data analysis today–such as search algorithms, recommendation engines, and adtech networks–are driven by machine learning and decisions by algorithms. As artificial intelligence evolves, it magnifies the ability to use personal information in ways that can intrude on privacy interests by raising analysis of personal information to new levels of power and speed.&lt;/p&gt;

&lt;p&gt;The discussion of AI in the context of the privacy debate often brings up the limitations and failures of AI systems. Bias in data and unfair systems have raised significant issues, but privacy legislation is complicated enough even without packing in all the social and political issues that can arise from uses of information. As Cameron F. Kerry suggested in one of his survey, to evaluate the effect of AI on privacy, it is necessary to distinguish between data issues that are endemic to all AI, like the incidence of false positives and negatives or overfitting to patterns, and those that are specific to use of personal information.&lt;/p&gt;

&lt;p&gt;The privacy legislative proposals that involve these issues refer to decisions made by AI as “automated decisions” (borrowed from EU data protection law) or “algorithmic decisions”. In general I believe that this helps to shift people’s focus from the use of AI as a tool to the use of personal data in AI and to the impact this use may have on individuals. This debate centers in particular on algorithmic bias and the potential for algorithms to produce unlawful or undesired discrimination in the decisions to which the algorithms relate. These are major concerns for civil rights and consumer organizations that represent populations that suffer undue discrimination.&lt;/p&gt;

&lt;p&gt;There's lot to think about and discuss about the scope of privacy legislation as some of them also address algorithmic discrimination. &lt;br&gt;
Let's split our views into two separate points:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;to what extent can or should legislation address issues of algorithmic bias? According to Law, Discrimination is not self-evidently a privacy issue, since it presents broad social issues that persist even without the collection and use of personal information, and fall under various civil rights laws.&lt;/li&gt;
&lt;li&gt;When we want to ensure privacy protection in AI systems and regulate use of consumer data and try to stop this unfair and deceptive practices the consumer choice based notice-and-choice model for privacy policies become meaningless. We will require a change in the paradigm of privacy, to protect such privacy interests in the context of AI. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;we need an approach that addresses risk more obliquely, with accountability measures designed to identify discrimination in the processing of personal data and regulate use of it. Number of organizations and companies as well as several legislators propose such accountability. Their proposals take various forms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Transparency:&lt;/em&gt; Accountability is a major concern and being able to examine how company is handling data makes it much more easier to hold company accountable for things. This mostly refers to disclosures relating to uses of algorithmic decision-making. Replacing current lengthy, detailed privacy policies are not helpful to most consumers with “privacy disclosures” that require a complete description of what and how data is collected, used, and protected would enhance the benchmarking which is being done by regulators. In turn, requiring that these disclosures identify significant uses of personal information for algorithmic decisions would help watchdogs and consumers know where to look out for untoward outcomes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Explainability:&lt;/em&gt; As we discussed above, this helps us understand how the data has been used to reach to particular decision and which features have played significant role in conclusion. European Union’s General Data Protection Regulation (GDPR) also follows this approach to settle disputes because of automated decisions. The GDPR requires that, for any automated decision with “legal effects or similarly significant effects” such as employment, credit, or insurance coverage, the person affected has recourse to a human who can review the decision and explain its logic. This incorporates a “human-in-the-loop” component and an element of due process that provide a check on anomalous or unfair outcomes. The central problem with both explainability is that you’re adding an additional step in the development process along with significant regulatory burden. Indeed, you’re probably adding multiple steps. From one perspective, this looks like you’re trying to tackle complexity with even greater complexity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Risk assessment:&lt;/em&gt; When we talk about risk assessment in this context we are mostly dealing will assessing impact of algorithmic decision on individuals and potential bias in design of a system. As Cameron F. Kerry rightly points out, for the regulatory burden to be proportionate, the level of risk assessment should be appropriate to the significance of the decision-making in question, which depends on the consequences of the decisions, the number of people and volume of data potentially affected, and the novelty and complexity of algorithmic processing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Audits:&lt;/em&gt; There are some general accountability requirements as well as ways such as self-audits or third-party audits which help authorities to ensure companies comply with their privacy programs. When we couple auditing outcomes of AI decisions with proactive risk assessments it can help us match foresight with hindsight; although, like explainability, auditing machine-learning routines is difficult and still developing.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because of the difficulties of foreseeing machine learning outcomes as well as reverse-engineering algorithmic decisions, no single measure can be completely effective in avoiding perverse effects. Thus, where algorithmic decisions are consequential, it makes sense to combine measures to work together. That's why it’s important for algorithm operators and developers to ensure that they won't leave some groups of people worse off as a result of the algorithm’s design or its unintended consequences. [&lt;a href="https://www.brookings.edu/research/algorithmic-bias-detection-and-mitigation-best-practices-and-policies-to-reduce-consumer-harms/"&gt;AI debate&lt;/a&gt;, Nicol Turner Lee with Paul Resnick and Genie Barton]&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N7uYHB_I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.washingtonpost.com/sf/national/wp-content/uploads/sites/11/2017/12/o-jibo1210.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N7uYHB_I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.washingtonpost.com/sf/national/wp-content/uploads/sites/11/2017/12/o-jibo1210.gif" alt="" width="800" height="466"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  On a positive note,
&lt;/h3&gt;

&lt;p&gt;Amid the dissonance of concern over unfair decisions made by artificial intelligence (AI) and use of personal data. The potential for AI to do good cannot be overlooked. Technology leaders such as Microsoft, IBM, Google and many others have entire sections of their business focused on the topic and dedicate resources to build AI solutions for good and to support developers who do. In the fight to solve extraordinarily difficult challenges such as Accessibility, Climate Change, Conservation and the Environment, World hunger, Human rights, Fake News and so many others, we can surely use help by AI!&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Note&lt;/code&gt;: In case you're interested to watch this discussion, you can check out the video here:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/pPwJqIAZ4QE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  References:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://christophm.github.io/interpretable-ml-book/interpretability-importance.html"&gt;Importance of Interpretability&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.technologyreview.com/2018/10/24/139313/a-global-ethics-study-aims-to-help-ai-solve-the-self-driving-trolley-problem/"&gt;MIT's self-driving cars survey for Moral Machines&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.scientificamerican.com/article/can-we-open-the-black-box-of-ai/"&gt;can we open the Black Box?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hbr.org/2019/10/what-do-we-do-about-the-biases-in-ai"&gt;What do we do about the biases in AI?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.strategy-business.com/article/What-is-fair-when-it-comes-to-AI-bias?gko=827c0"&gt;what is fair?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://arxiv.org/pdf/1908.09635.pdf"&gt;A Survey on Bias and Fairness in Machine Learning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.kdnuggets.com/2018/12/machine-learning-explainability-interpretability-ai.html"&gt;Explainability &amp;amp; interpretability in AI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.brookings.edu/research/protecting-privacy-in-an-ai-driven-world/"&gt;protecting privacy in an AI driven world&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://strongbytes.ai/the-trolley-dilemma-in-ai/"&gt;The trolley dilemma in AI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://qz.com/1716107/the-problem-with-the-trolley-problem/"&gt;The problem with the trolley problem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://danshiebler.com/2017-04-16-deep-taylor-lrp/"&gt;Layerwise Relevance Propagation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://privacyinternational.org/learn/artificial-intelligence"&gt;AI &amp;amp; Privacy&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
      <category>techtalks</category>
      <category>discuss</category>
    </item>
    <item>
      <title>MLOps with AML and Azure Devops</title>
      <dc:creator>Jayesh Bapu Ahire</dc:creator>
      <pubDate>Mon, 04 May 2020 10:43:55 +0000</pubDate>
      <link>https://dev.to/jbahire/mlops-with-aml-and-azure-devops-glj</link>
      <guid>https://dev.to/jbahire/mlops-with-aml-and-azure-devops-glj</guid>
      <description>&lt;p&gt;Few years ago, when someone used to say machine learning or AI the focus used to be on data prep and cleaning, EDA, modeling etc. Inferencing/ prediction used to be final steps for most people. But the situation has changed today, people are now talking about more elusive and less tangible final state — often termed “deployment”, “delivery”.&lt;/p&gt;

&lt;p&gt;When is comes to deploying your machine learning solution in production there are various ways to do that. Some of them are as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python code behind e.g. Flask: This is the simplest way to go into production. write python or flask wrapper for your machine learning model inferencing and you're ready. But this way is very hard to scale.&lt;/li&gt;
&lt;li&gt;Execution service from cloud provider: All major cloud service providers easy and scalable out of the box solutions.&lt;/li&gt;
&lt;li&gt;Runtime

&lt;ul&gt;
&lt;li&gt;TensorFlow serving&lt;/li&gt;
&lt;li&gt;Clipper&lt;/li&gt;
&lt;li&gt;NVIDIA TensorRT inference server&lt;/li&gt;
&lt;li&gt;MXNet Model Server&lt;/li&gt;
&lt;li&gt;…&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Bespoke solutions (C++, …): Write your own runtime&lt;/li&gt;
&lt;li&gt;kubernetes-ize everything above: Any solution above can be scaled using Kubernetes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are some things we need to consider before we deploy our model in production. Whatever deployment solution you choose must fulfill following criteria:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Must fit the technology stack&lt;/li&gt;
&lt;li&gt;Not just about languages, but about semantics, scalability, guarantees&lt;/li&gt;
&lt;li&gt;Run anywhere, any size&lt;/li&gt;
&lt;li&gt;Composable building blocks&lt;/li&gt;
&lt;li&gt;Must try to limit the amount of moving parts and the amount of moving data&lt;/li&gt;
&lt;li&gt;Must make best use of resources&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, if you have built some machine learning solution and if you will like to set up a minimal, robust, repeatable set of pipelines for productionising Machine Learning models in the cloud using Microsoft Azure, this article will help you with steps as well as resources you should refer.&lt;/p&gt;

&lt;p&gt;First let's go through some terms:&lt;/p&gt;

&lt;h3&gt;
  
  
  What is MLOps?
&lt;/h3&gt;

&lt;p&gt;According to &lt;a href="https://www.aitrends.com/machine-learning/mlops-not-just-ml-business-new-competitive-frontier/"&gt;Nisha Talagala&lt;/a&gt;, MLOps (a compound of Machine Learning and “information technology OPerationS”) is new discipline/focus/practice for collaboration and communication between data scientists and information technology (IT) professionals while automating and productizing machine learning algorithms. Via practice and tools, MLOps aims to establish a culture and environment where ML technologies can generate business benefits by rapidly, frequently and reliably building, testing, and releasing ML technology into production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Y-TaAJrn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.c-sharpcorner.com/UploadFile/BlogImages/11122019223851PM/image1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y-TaAJrn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.c-sharpcorner.com/UploadFile/BlogImages/11122019223851PM/image1.png" alt="" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Azure Machine Learning:
&lt;/h3&gt;

&lt;p&gt;Azure Machine Learning service provides a cloud-based environment you can use to develop, train, test, deploy, manage, and track machine learning models.&lt;/p&gt;

&lt;h3&gt;
  
  
  Azure DevOps:
&lt;/h3&gt;

&lt;p&gt;We will be using the Azure DevOps project for build and release pipelines along with Azure ML services for ML/AI model management and operationalization. &lt;/p&gt;

&lt;h3&gt;
  
  
  Azure Pipelines:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GKRDHMID--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/4000/1%2AvoXX_vKb7jJjH15VWSI-lg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GKRDHMID--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/4000/1%2AvoXX_vKb7jJjH15VWSI-lg.png" alt="" width="800" height="240"&gt;&lt;/a&gt;&lt;br&gt;
Azure Pipelines are cloud-hosted pipelines that are fully integrated with Azure DevOps. You can either use a yaml file or a UI-based tool in Azure DevOps to set up your pipelines. It allows us to frequently update models, test new models, and continuously roll out new ML models alongside your other applications and services.&lt;/p&gt;

&lt;p&gt;The end-to-end Machine learning pipeline includes data-prep, training, packaging and validating model, deploying model and continuous testing. It looks like below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NMzE-gO---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://docs.microsoft.com/en-us/azure/machine-learning/media/concept-ml-pipelines/pipeline-flow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NMzE-gO---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://docs.microsoft.com/en-us/azure/machine-learning/media/concept-ml-pipelines/pipeline-flow.png" alt="" width="800" height="166"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our end-to-end CI/CD pipeline will look like below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OG9GEvOa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.azuredevopslabs.com/labs/vstsextend/aml/images/aml.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OG9GEvOa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.azuredevopslabs.com/labs/vstsextend/aml/images/aml.png" alt="" width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's get started:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Microsoft Azure Account: You will need a valid and active Azure account for the Azure labs. If you do not have one, you can sign up for a &lt;a href="https://azure.microsoft.com/en-us/free/"&gt;free trial&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;You will need an Azure DevOps account. If you do not have one, you can sign up for free &lt;a href="https://azure.microsoft.com/en-us/services/devops/"&gt;here.&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Setup
&lt;/h3&gt;

&lt;p&gt;We will be using Azure Demo Generator to initiate setup. Azure DevOps Demo Generator helps you create team projects on your Azure DevOps Organization with sample content that include source code, work items, iterations, service endpoints, build and release definitions based on the template you choose during the configuration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q6Gy_LIj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/setup-adg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q6Gy_LIj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/setup-adg.png" alt="" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use the &lt;a href="https://azuredevopsdemogenerator.azurewebsites.net/?name=machinelearning"&gt;Azure DevOps Demo Generator&lt;/a&gt; to provision the project on your Azure DevOps organization. This URL will automatically select Azure Machine Learning template in the demo generator. This template contains code and pipeline definition for a machine learning project demonstrating how to automate the end to end ML/AI project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MqVkvD2A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/setup-done.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MqVkvD2A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/setup-done.png" alt="" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Configure CI pipeline
&lt;/h3&gt;

&lt;p&gt;In this step, we will configure CI pipeline for your ML/AI project. This pipeline will include DevOps tasks for &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;data sanity test, &lt;/li&gt;
&lt;li&gt;model training on different compute targets,&lt;/li&gt;
&lt;li&gt;model version management, &lt;/li&gt;
&lt;li&gt;model evaluation/model selection etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;a. Let's go to Azure Devops Dashboard:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R02aLMa4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/AD-Dash.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R02aLMa4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/AD-Dash.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;b. Select your project and Navigate to &lt;code&gt;Pipeline &amp;gt; Builds&lt;/code&gt;. Select the pipeline &lt;code&gt;DevOps-for-AI-CI&lt;/code&gt; and click on &lt;code&gt;edit&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KUSJtNJ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/pipe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KUSJtNJ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/pipe.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your current pipeline configs will look like below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XICivyjn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/pipe-config.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XICivyjn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/pipe-config.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;c. In this, Python environment and Install Requirements tasks will be required to setup and prepare python environment for subsequent builds.&lt;/p&gt;

&lt;p&gt;Select next task, which will be &lt;code&gt;Create or get Workspace&lt;/code&gt; (currently it's showing &lt;code&gt;some setting need attention&lt;/code&gt;). In task configurations, Select the Azure subscription from the drop-down list and click Authorize to configure Azure service connection. Make sure your subscription allows to create AML workspace as this task will be used to create Workspace for Azure Machine learning service.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4stMaokf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/pipe-mid-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4stMaokf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/pipe-mid-1.png" alt="" width="800" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;d. Follow similar procedure for all other tasks and select same subscription. Your end configs will look like below. &lt;code&gt;save&lt;/code&gt; this configs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CYCLZA8k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/pipe-final.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CYCLZA8k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/pipe-final.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;e. Also, click on triggers tab and make sure CI is enabled. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kS5ytE0i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/trig.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kS5ytE0i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/trig.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;f. Now, we are done with our CI pipeline which does following tasks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prepare the python environment for our upcoming builds&lt;/li&gt;
&lt;li&gt;Get or Create the workspace for AML service&lt;/li&gt;
&lt;li&gt;Submit Training job on the remote DSVM / Local Python Env&lt;/li&gt;
&lt;li&gt;Compare performance of different models and select the best&lt;/li&gt;
&lt;li&gt;Register model to the workspace&lt;/li&gt;
&lt;li&gt;Create Docker Image for Scoring Web service&lt;/li&gt;
&lt;li&gt;Copy and Publish the Artifacts to Release Pipeline&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 2: Configure CD pipeline
&lt;/h3&gt;

&lt;p&gt;So, as we are done with CI pipeline let's configure Release pipeline which will deploy the image created from the build pipeline to Azure Container Instance and Azure Kubernetes Services.&lt;/p&gt;

&lt;p&gt;a. Now, navigate to Pipeline &amp;gt; Releases and select Deploy Web service and click Edit pipeline.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VfyGST51--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/release-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VfyGST51--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/release-2.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;b. As we can see here, pipeline has two steps QA and Prod. We have to modify configs for QA so click on QA.&lt;/p&gt;

&lt;p&gt;Similar to &lt;code&gt;sub-step c&lt;/code&gt; in step-1,&lt;br&gt;
Python environment and Install Requirements tasks will be required to setup and prepare python environment for subsequent builds.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---S2Ohul_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/release-3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---S2Ohul_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/release-3.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;c. Select next task, which will be &lt;code&gt;Deploy webservice of ACI&lt;/code&gt; (currently it's showing &lt;code&gt;some setting need attention&lt;/code&gt;). In task configurations, Select the Azure subscription from the drop-down list and click Authorize to configure Azure service connection. This task creates ACI (Azure Container Instance) and deploys web service image created in Build Pipeline to ACI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Avcn4fMi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/release-5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Avcn4fMi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/release-5.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;d. Follow similar steps for &lt;code&gt;Prod-Deploy on AKS&lt;/code&gt; which you can find form drop-down in top bar. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jR9fKPP5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/release-6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jR9fKPP5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/release-6.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This task configures AKS (Azure Kubernetes Service) so we can deploy our web-service on AKS in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fIoC6INN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/release-4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fIoC6INN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/release-4.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Update config file in the source code to trigger CI and CD
&lt;/h3&gt;

&lt;p&gt;a. Navigate to &lt;code&gt;Repos&lt;/code&gt; and choose files. Go to directory &lt;code&gt;aml_config/&lt;/code&gt; and open &lt;code&gt;config.json&lt;/code&gt; file. &lt;/p&gt;

&lt;p&gt;b. Update your Azure subscription ID in place of &amp;lt;&amp;gt;. If required Change resource group name, AML workspace name and the location where you want to deploy your Azure ML service workspace. Click Commit to commit the changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nFzexulD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/repo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nFzexulD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/repo.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Note&lt;/code&gt;: Navigate to &lt;code&gt;environment_setup/install_requirements.sh&lt;/code&gt;, change the Azure CLI version from existing &lt;code&gt;2.0.X&lt;/code&gt; to &lt;code&gt;2.5.0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;c. Since we have enabled in CI trigger a build will be queued automatically.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LFgFkiX5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/CI-trig.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LFgFkiX5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/CI-trig.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;d. If you want to check build, you can navigate to Pipelines &amp;gt; Builds and you will see a build is queued. Open the build to see the progress. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7ozK3-sk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/job.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7ozK3-sk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/azure/job.png" alt="" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;e. Once the build is success a release will be queued automatically. Navigate to Pipelines –&amp;gt; Releases to see the release in progress.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uokKj_Fa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.azuredevopslabs.com/labs/vstsextend/aml/images/build-release-progress.gif" alt="space-1.jpg" width="" height=""&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;Deployment process in action (courtesy: Azure DevOps Labs)&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;f. If you want to view the resources provisioned and deployed by CI-CD pipelines, navigate to your Azure portal as shown below!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z_x93dD1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.azuredevopslabs.com/labs/vstsextend/aml/images/azureportal1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z_x93dD1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.azuredevopslabs.com/labs/vstsextend/aml/images/azureportal1.gif" alt="" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was a very short and high-level overview to play with Azure DevOps and Azure pipelines to create manage machine learning deployments. We used the Azure DevOps project for build and release pipelines along with Azure ML services for ML/AI model management and operationalization. &lt;/p&gt;

&lt;h3&gt;
  
  
  What's next?
&lt;/h3&gt;

&lt;p&gt;If you want to go through detailed step-by-step explanation, you can check out blog by our friend &lt;a href="https://github.com/benalexkeen"&gt;Ben Alex Keen&lt;/a&gt; available &lt;a href="https://benalexkeen.com/creating-end-to-end-mlops-pipelines-using-azure-ml-and-azure-pipelines-part-1/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For more information about various services we used here, you can go through list of references and learn more.&lt;/p&gt;

&lt;h3&gt;
  
  
  References:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/learn/paths/automate-deployments-azure-devops/?wt.mc_id=AID3011243_QSG_EML_426806"&gt;Automate your deployments with Azure DevOps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.codemag.com/Article/1909021/Azure-Machine-Learning-Workspace-and-MLOps"&gt;AML &amp;amp; MLOps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/machine-learning/concept-ml-pipelines"&gt;ML Pipeline Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.azuredevopslabs.com/labs/vstsextend/aml/#exercise-3-update-config-file-in-the-source-code-to-trigger-ci-and-cd"&gt;CI/CD Pipeline&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.c-sharpcorner.com/blogs/mlops"&gt;MLOps Explained&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/@nirespire/what-is-cicd-concepts-in-continuous-integration-and-deployment-4fe3f6625007"&gt;What is CI/CD?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/praneet22/DevOpsForAI"&gt;Sample Application&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/machine-learning/samples-notebooks"&gt;AML Samples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/devops/?view=azure-devops&amp;amp;viewFallbackFrom=vsts"&gt;Azure DevOps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/machine-learning/overview-what-is-azure-ml"&gt;AML Overview&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>machinelearning</category>
      <category>azure</category>
      <category>devops</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Data extraction from documents made easy with Amazon Textract</title>
      <dc:creator>Jayesh Bapu Ahire</dc:creator>
      <pubDate>Sun, 05 Apr 2020 11:30:42 +0000</pubDate>
      <link>https://dev.to/jbahire/text-extraction-made-easy-with-amazon-textract-12p</link>
      <guid>https://dev.to/jbahire/text-extraction-made-easy-with-amazon-textract-12p</guid>
      <description>&lt;p&gt;&lt;strong&gt;Artificial Intelligence&lt;/strong&gt; as we know found use cases in every possible industry! Many complicated problems we used to face during our day to day are now being solved using AI. Some of them might not give results upto human standards but with improvements in underlying algorithms and optimizations we are progressing towards achieving this standards. In this article we will see one such important problem, Text Extraction from documents. For many years, companies are working on this problem using manual techniques, rule-based methods or customized OCR which are both time consuming and complicated.&lt;/p&gt;

&lt;p&gt;One important point here is &lt;strong&gt;documents are important!&lt;/strong&gt; How? Let's see!&lt;/p&gt;

&lt;p&gt;Documents are primary tools for keeping the records. Large amount of data is stored in structured or unstructured documents. They are also important when it comes to communicate, collaborate or transact the data across industries like medical, legal, business management, finance, education, tax management and many more.&lt;/p&gt;

&lt;h4&gt;
  
  
  What are the types of documents we are looking at?
&lt;/h4&gt;

&lt;p&gt;We are looking at scanned documents, digital documents, forms, tables, contracts and many other. &lt;/p&gt;

&lt;p&gt;I mentioned some classical techniques which we are using above. What is the problem with those? The major problems in this manual techniques are they are &lt;code&gt;too expensive&lt;/code&gt;, &lt;code&gt;error prone&lt;/code&gt; and &lt;code&gt;time consuming&lt;/code&gt; as it involves human-intervention.&lt;/p&gt;

&lt;p&gt;Let's see problems with each of the technique:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Manual processing (humans):
&lt;/h4&gt;

&lt;p&gt;When we depend on humans processing the docs there might be issues like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variable output&lt;/li&gt;
&lt;li&gt;Inconsistent results&lt;/li&gt;
&lt;li&gt;Reviews for consensus&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;in a example below humans can process and interpret this blocks differently and it depends on variety of factors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CN3jYV6j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/test.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CN3jYV6j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/test.png" alt="" width="800" height="358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Customized OCR was better solution than manual extraction but it has it's own problem:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Paragraph detection (You can code this but again manual intervention comes in. You can annotate the sample set and train a ML model on model on that which will give you separated paragraphs and again there are some unsupervised methods but ML comes into play here. )&lt;/li&gt;
&lt;li&gt;No rotated text and stylized text detection&lt;/li&gt;
&lt;li&gt;No multi-column detection&lt;/li&gt;
&lt;li&gt;Table Extraction&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can obviously add this features and if you want to do it without ML you have to maintain a separate code template (and templates are brittle) for each document and it's time consuming. If we consider tax form for any country there will be different variations for different job categories and you have to maintain different template and rule-sets for all of them which is nightmare.&lt;/p&gt;

&lt;p&gt;So how can we not complicate our life further and still make a robust text extraction solution? Amazon textract comes handy and solves many of the problems we have seen! It's tagline says extract text and data from virtually any document! &lt;/p&gt;

&lt;p&gt;Let's jump into details!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iDTuQEU3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://media1.tenor.com/images/be762c04caee026253f66cf89d7ac7a8/tenor.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iDTuQEU3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://media1.tenor.com/images/be762c04caee026253f66cf89d7ac7a8/tenor.gif" alt="" width="498" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What Amazon Textract can do?
&lt;/h3&gt;

&lt;p&gt;Let's first list down some things you can achieve using amazon textract and then see core features in details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Text detection from documents&lt;/li&gt;
&lt;li&gt;Multi-column detection and reading order&lt;/li&gt;
&lt;li&gt;Natural language processing and document classification&lt;/li&gt;
&lt;li&gt;Natural language processing for medical documents&lt;/li&gt;
&lt;li&gt;Document translation&lt;/li&gt;
&lt;li&gt;Search and discovery&lt;/li&gt;
&lt;li&gt;Form extraction and processing&lt;/li&gt;
&lt;li&gt;Compliance control with document redaction&lt;/li&gt;
&lt;li&gt;Table extraction and processing&lt;/li&gt;
&lt;li&gt;PDF document processing&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How textract works?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4F-xIiTU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/pipeline.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4F-xIiTU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/pipeline.png" alt="" width="800" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Amazon textract API accepts the document stored in s3 and uses ML models built in to extract text, tables or any fields of interest from docs. Now we get an option to either store this extracted data into some other format or stack some other services for further processing the output. We can use services like &lt;a href="https://www.elastic.co/what-is/elasticsearch"&gt;Elasticsearch&lt;/a&gt; to create indexes for the data to built a search application around it or we can &lt;a href="https://aws.amazon.com/comprehend/"&gt;amazon comprehend&lt;/a&gt; to use Natural Language Processing on our data. &lt;/p&gt;

&lt;p&gt;We can use services like &lt;a href="https://aws.amazon.com/comprehend/medical/"&gt;amazon comprehend medical&lt;/a&gt; which uses advanced machine learning models to accurately and quickly identify medical information, such as medical conditions and medications, and determines their relationship to each other, for instance, medicine dosage and strength. Amazon Comprehend Medical can also link the detected information to medical ontologies such as ICD-10-CM or RxNorm. And if you are not interested in all this fancy stuff you can just store your data in database with pre-defined schema and use it in your application! The above self-explanatory diagram from documentation will make understanding of things little easy!&lt;/p&gt;

&lt;h3&gt;
  
  
  Before going ahead let's just see request and response format of Textract API.
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Request Syntax:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Document&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bytes&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;S3Object&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bucket&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Version&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;},&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;FeatureTypes&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="p"&gt;],&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HumanLoopConfig&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;DataAttributes&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ContentClassifiers&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;FlowDefinitionArn&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HumanLoopName&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;Document&lt;/code&gt; is input document which can be base64-encoded bytes or an Amazon S3 object and it's required. &lt;code&gt;FeatureTypes&lt;/code&gt; is list of features you want to extract like tables, forms etc. and it's also required. &lt;code&gt;HumanLoopConfig&lt;/code&gt; allows you to set human reviewer and it's not required.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Response Syntax:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;AnalyzeDocumentModelVersion&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Blocks&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; 
      &lt;span class="p"&gt;{&lt;/span&gt; 
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;BlockType&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ColumnIndex&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ColumnSpan&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Confidence&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;EntityTypes&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="p"&gt;],&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Geometry&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;BoundingBox&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
               &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Height&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
               &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Left&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
               &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Top&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
               &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Width&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Polygon&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; 
               &lt;span class="p"&gt;{&lt;/span&gt; 
                  &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;X&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                  &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Y&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;
               &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;]&lt;/span&gt;
         &lt;span class="p"&gt;},&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Page&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Relationships&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; 
            &lt;span class="p"&gt;{&lt;/span&gt; 
               &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Ids&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="p"&gt;],&lt;/span&gt;
               &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
         &lt;span class="p"&gt;],&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;RowIndex&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;RowSpan&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SelectionStatus&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;],&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;DocumentMetadata&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Pages&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;
   &lt;span class="p"&gt;},&lt;/span&gt;
   &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HumanLoopActivationOutput&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HumanLoopActivationConditionsEvaluationResults&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HumanLoopActivationReasons&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;HumanLoopArn&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;string&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;AnalyzeDocumentModelVersion&lt;/code&gt; tells you version of model used used and Blocks contains all the detected items. &lt;code&gt;DocumentMetadata&lt;/code&gt; gives additional information about document and &lt;code&gt;HumanLoopActivationOutput&lt;/code&gt; gives results of evaluation by human reviewer.&lt;/p&gt;

&lt;p&gt;Now we know what textract can do and how it works, let's see the core features and capabilities textract provides in details:&lt;/p&gt;

&lt;h3&gt;
  
  
  Core Features:
&lt;/h3&gt;

&lt;p&gt;You can try this all from &lt;a href="https://console.aws.amazon.com/textract/home?region=us-east-1#/"&gt;Amazon Textract Console&lt;/a&gt; directly!&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Table Extraction:
&lt;/h4&gt;

&lt;p&gt;Amazon textract can extract tables from given document and provide them into any format we want including CSV or spreadsheet and we can even automatically load the extracted data into a database using a pre-defined schema. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KUcVee9Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/table.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KUcVee9Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/table.png" alt="" width="800" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's consider one document and see how Textract works for that!&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b2n-_HNg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.gstzen.in/articles/gst/forms/registrations/reg-16/reg-16-table-1e.29ca20f3-hs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b2n-_HNg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.gstzen.in/articles/gst/forms/registrations/reg-16/reg-16-table-1e.29ca20f3-hs.png" alt="" width="800" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are the results which are really promising!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m9xegU0I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/table1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m9xegU0I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/table1.png" alt="" width="800" height="262"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xzU7kwjG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/table2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xzU7kwjG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/table2.png" alt="" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  2. Form Extraction:
&lt;/h4&gt;

&lt;p&gt;Amazon textract can extract data from forms in key-value pairs which we can use for various applications. For example you want to setup automated process which accepts scanned bank account opening application and fills required data into system and creates account you can do that using amazon textract form extraction. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lHuh4qmp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/form.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lHuh4qmp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/form.png" alt="" width="800" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;let's try this on below document:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bCvcfw1F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.gstzen.in/articles/gst/forms/registrations/reg-16/reg-16-table-1a.85e6d32a-hs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bCvcfw1F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.gstzen.in/articles/gst/forms/registrations/reg-16/reg-16-table-1a.85e6d32a-hs.png" alt="" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are the results:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kKjIc1xr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/form1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kKjIc1xr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/form1.png" alt="" width="800" height="736"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's see harder problem with document like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Cse1XcVn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://guillaumejaume.github.io/FUNSD/img/form_example.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Cse1XcVn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://guillaumejaume.github.io/FUNSD/img/form_example.png" alt="" width="777" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's what we got:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G5z6Do2O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/form2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G5z6Do2O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/form2.png" alt="" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IAfejbcd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/form3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IAfejbcd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/form3.png" alt="" width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  3. Text Extraction:
&lt;/h4&gt;

&lt;p&gt;Amazon textract uses a better adoption of OCR which uses ML along with OCR (some people like to call it OCR++) which detects printed text and numbers in a scan or rendering of a document. This can be used for medical reports, financial reports or we can use it for applications like clause extraction in legal documents when paired with amazon comprehend.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nJ89iZNX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/txt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nJ89iZNX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/txt.png" alt="" width="800" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's try to extract text from this document:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cAA5_77I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://weagree.com/wp-content/uploads/2017/02/EU_style_final_page_15-05-2011.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cAA5_77I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://weagree.com/wp-content/uploads/2017/02/EU_style_final_page_15-05-2011.png" alt="" width="701" height="570"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are the results:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lKZho53i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/text1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lKZho53i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/text1.png" alt="" width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Along with this 3 core features, textract also provides you bunch of features like &lt;strong&gt;Bounding Boxes&lt;/strong&gt;, &lt;strong&gt;Adjustable Confidence Thresholds&lt;/strong&gt;, &lt;strong&gt;Built-in Human Review Workflow&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;So, how can we use the textract API with python?&lt;/p&gt;

&lt;p&gt;Let's build a very simplified upload and analyze pipeline based on &lt;a href="https://github.com/aws-samples/amazon-textract-textractor"&gt;amazon textractor&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;Pipeline:&lt;/code&gt;
First, we will upload document to s3 and then use amazon textractor to extract fields we want from document.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;sp&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;s3_upload&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;upload&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run_pipeline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bucket_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;upload&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bucket_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;s3://&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;bucket_name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

    &lt;span class="n"&gt;command_analysis&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;python textractor.py --documents &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;command_analysis&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;argparse&lt;/span&gt;
    &lt;span class="n"&gt;parser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;argparse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ArgumentParser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;source_file&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;The path and name of the source file to upload.&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;bucket_name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;The name of the destination bucket.&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;object_key&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;The key of the destination object.&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;flags&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Only one of the flags (--text, --forms and --tables) is required at the minimum. You can use combination of all three.&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse_args&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="nf"&gt;run_pipeline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;source_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bucket_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here, we will provide local file path, s3 bucket we want to upload file in and name of the file along with what we want to extract.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;Upload file to s3:&lt;/code&gt;
uploading file to s3 is really easy:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;upload&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bucket_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;s3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s3&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket_name&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;upload_file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;Textractor:&lt;/code&gt;
Textractor is the ready to use solution made by amazon which helps to speed up the PoC's. It can convert output in different formats including raw JSON, JSON for each page in the document, text, text in reading order, key/values exported as CSV, tables exported as CSV. It can also generate insights or translate detected text by using Amazon Comprehend, Amazon Comprehend Medical and Amazon Translate. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is how textractor uses response parser library which helps process JSON returned from Amazon Textract. See the repo and documentation for more details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Call Amazon Textract and get JSON response
&lt;/span&gt;&lt;span class="n"&gt;docproc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;DocumentProcessor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucketName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;filePath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;awsRegion&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;detectText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;detectForms&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tables&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;docproc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Get DOM
&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Iterate over elements in the document
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Print lines and words
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Line: {}--{}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;confidence&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Word: {}--{}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;confidence&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="c1"&gt;# Print tables
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tables&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cells&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Table[{}][{}] = {}-{}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;confidence&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="c1"&gt;# Print fields
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Field: Key: {}, Value: {}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="c1"&gt;# Get field by key
&lt;/span&gt;    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Phone Number:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getFieldByKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Field: Key: {}, Value: {}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="c1"&gt;# Search fields by key
&lt;/span&gt;    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;address&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;searchFieldsByKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Field: Key: {}, Value: {}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how the output looks like!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_6_thGC3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/op1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_6_thGC3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/op1.png" alt="" width="744" height="708"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E65xCOSw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/op2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E65xCOSw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://textract-console-us-east-1-6375b349-b720-4339-99ab-c4a951ea5a70.s3.amazonaws.com/blog/op2.png" alt="" width="800" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What's next
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--esi9li5j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://media.workandmoney.com/f6/04/f604a9a462ff4fc5afce3bf6eea0ae9c.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--esi9li5j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://media.workandmoney.com/f6/04/f604a9a462ff4fc5afce3bf6eea0ae9c.gif" alt="" width="600" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We went through various features and capabilities textract provides! This is one of the ready to use solution which can simplify some very complicated problems we face while building business applications around documents. This is not 100% accurate and directly usable for every case but some small tweaks here and there should make it usable for most of the use cases. In next article, we will see how we can use this is some of the business applications and we will also try to build end to end pipeline using various AWS services. &lt;/p&gt;

&lt;p&gt;Until then, let me know if you have some use-cases where you are already using amazon textract or you're planning to use this in comments. If you have any questions or want to discuss any use-cases ping me on &lt;a href="https://twitter.com/jayesh_ahire1"&gt;twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Stay safe!&lt;/p&gt;

&lt;h3&gt;
  
  
  References:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Amazon Textract : &lt;a href="https://aws.amazon.com/textract/"&gt;https://aws.amazon.com/textract/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Amazon Textract Console: &lt;a href="https://console.aws.amazon.com/textract/home?region=us-east-1#/"&gt;https://console.aws.amazon.com/textract/home?region=us-east-1#/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Amazon Blogs: &lt;a href="https://aws.amazon.com/blogs/machine-learning/automatically-extract-text-and-structured-data-from-documents-with-amazon-textract/"&gt;https://aws.amazon.com/blogs/machine-learning/automatically-extract-text-and-structured-data-from-documents-with-amazon-textract/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Amazon Textract Documentation: &lt;a href="https://docs.aws.amazon.com/textract/latest/dg/what-is.html"&gt;https://docs.aws.amazon.com/textract/latest/dg/what-is.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/aws-samples/amazon-textract-textractor"&gt;Amazon textract textractor&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>machinelearning</category>
      <category>tutorial</category>
      <category>aws</category>
      <category>ai</category>
    </item>
    <item>
      <title>Demystifying the XOR problem</title>
      <dc:creator>Jayesh Bapu Ahire</dc:creator>
      <pubDate>Fri, 03 Apr 2020 14:21:32 +0000</pubDate>
      <link>https://dev.to/jbahire/demystifying-the-xor-problem-1blk</link>
      <guid>https://dev.to/jbahire/demystifying-the-xor-problem-1blk</guid>
      <description>&lt;p&gt;In my previous post on &lt;a href="https://dev.to/jbahire/demystifying-extreme-learning-machines-part-1-22h2"&gt;Extreme learning machines&lt;/a&gt; I told that the famous pioneers in AI Marvin Minsky and Seymour Papert claimed in their book &lt;code&gt;Perceptron [1969]&lt;/code&gt;,  that the simple XOR cannot be resolved by two-layer of feedforward neural networks, which "drove research away from neural networks in the 1970s, and contributed to the so-called AI winter".[Wikipedia 2013]&lt;/p&gt;

&lt;p&gt;Let's explore what is this XOR problem...&lt;/p&gt;

&lt;h3&gt;
  
  
  The XOR Problem
&lt;/h3&gt;

&lt;p&gt;The XOR, or “exclusive or”, problem is a classic problem in ANN research. It is the problem of using a neural network to predict the outputs of XOR logic gates given two binary inputs. An XOR function should return a true value if the two inputs are not equal and a false value if they are equal. All possible inputs and predicted outputs are shown in figure 1.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ALYlt6CZJHOJkNRHJ." class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ALYlt6CZJHOJkNRHJ."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;XOR is a &lt;a href="https://en.wikipedia.org/wiki/Statistical_classification" rel="noopener noreferrer"&gt;classification problem&lt;/a&gt; and one for which the expected outputs are known in advance. It is therefore appropriate to use a supervised learning approach.&lt;/p&gt;

&lt;p&gt;On the surface, XOR appears to be a very simple problem, however, Minksy and Papert (1969) showed that this was a big problem for neural network architectures of the 1960s, known as perceptrons.&lt;/p&gt;

&lt;h3&gt;
  
  
  Perceptrons
&lt;/h3&gt;

&lt;p&gt;Like all ANNs, the perceptron is composed of a network of &lt;a href="https://en.wikipedia.org/wiki/Artificial_neuron" rel="noopener noreferrer"&gt;*units&lt;/a&gt;*, which are analagous to biological neurons. A unit can receive an input from other units. On doing so, it takes the sum of all values received and decides whether it is going to forward a signal on to other units to which it is connected. This is called activation. The &lt;a href="https://en.wikipedia.org/wiki/Activation_function" rel="noopener noreferrer"&gt;activation function&lt;/a&gt; uses some means or other to reduce the sum of input values to a 1 or a 0 (or a value very close to a 1 or 0) in order to represent activation or lack thereof. Another form of unit, known as a bias unit, always activates, typically sending a hard coded 1 to all units to which it is connected.&lt;/p&gt;

&lt;p&gt;Perceptrons include a single layer of input units — including one bias unit — and a single output unit (see figure 2). Here a bias unit is depicted by a dashed circle, while other units are shown as blue circles. There are two non-bias input units representing the two binary input values for XOR. Any number of input units can be included.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AwOYoifz24Wz_I152." class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AwOYoifz24Wz_I152."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The perceptron is a type of &lt;a href="http://cs.stanford.edu/people/eroberts/courses/soco/projects/neural-networks/Architecture/feedforward.html" rel="noopener noreferrer"&gt;feed-forward&lt;/a&gt; network, which means the process of generating an output — known as forward propagation — flows in one direction from the input layer to the output layer. There are no connections between units in the input layer. Instead, all units in the input layer are connected directly to the output unit.&lt;/p&gt;

&lt;p&gt;A simplified explanation of the forward propagation process is that the input values X1 and X2, along with the bias value of 1, are multiplied by their respective weights W0..W2, and parsed to the output unit. The output unit takes the sum of those values and employs an activation function — typically the &lt;a href="https://en.wikipedia.org/wiki/Heaviside_step_function" rel="noopener noreferrer"&gt;Heavside step function&lt;/a&gt; — to convert the resulting value to a 0 or 1, thus classifying the input values as 0 or 1.&lt;/p&gt;

&lt;p&gt;It is the setting of the weight variables that gives the network’s author control over the process of converting input values to an output value. It is the weights that determine where the classification line, the line that separates data points into classification groups, is drawn. If all data points on one side of a classification line are assigned the class of 0, all others are classified as 1.&lt;/p&gt;

&lt;p&gt;A limitation of this architecture is that it is only capable of separating data points with a single line. This is unfortunate because the XOR inputs are not &lt;a href="https://en.wikipedia.org/wiki/Linear_separability" rel="noopener noreferrer"&gt;linearly separable&lt;/a&gt;. This is particularly visible if you plot the XOR input values to a graph. As shown in figure 3, there is no way to separate the 1 and 0 predictions with a single classification line.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AqdRb80zUpJPtrbRD." class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AqdRb80zUpJPtrbRD."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Multilayer Perceptrons
&lt;/h3&gt;

&lt;p&gt;The solution to this problem is to expand beyond the single-layer architecture by adding an additional layer of units without any direct access to the outside world, known as a hidden layer. This kind of architecture — shown in Figure 4 — is another feed-forward network known as a multilayer perceptron (MLP).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A158hcRQzzw_wpEZW." class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A158hcRQzzw_wpEZW."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is worth noting that an MLP can have any number of units in its input, hidden and output layers. There can also be any number of hidden layers. The architecture used here is designed specifically for the XOR problem.&lt;/p&gt;

&lt;p&gt;Similar to the classic perceptron, forward propagation begins with the input values and bias unit from the input layer being multiplied by their respective weights, however, in this case there is a weight for each combination of input (including the input layer’s bias unit) and hidden unit (excluding the hidden layer’s bias unit). The products of the input layer values and their respective weights are parsed as input to the non-bias units in the hidden layer. Each non-bias hidden unit invokes an activation function — usually the classic &lt;a href="https://en.wikipedia.org/wiki/Sigmoid_function" rel="noopener noreferrer"&gt;sigmoid function&lt;/a&gt; in the case of the XOR problem — to squash the sum of their input values down to a value that falls between 0 and 1 (usually a value very close to either 0 or 1). The outputs of each hidden layer unit, including the bias unit, are then multiplied by another set of respective weights and parsed to an output unit. The output unit also parses the sum of its input values through an activation function — again, the sigmoid function is appropriate here — to return an output value falling between 0 and 1. This is the predicted output.&lt;/p&gt;

&lt;p&gt;This architecture, while more complex than that of the classic perceptron network, is capable of achieving non-linear separation. Thus, with the right set of weight values, it can provide the necessary separation to accurately classify the XOR inputs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Afd1nXdp1WpwbagTs." class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Afd1nXdp1WpwbagTs."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Backpropagation
&lt;/h3&gt;

&lt;p&gt;The elephant in the room, of course, is how one might come up with a set of weight values that ensure the network produces the expected output. In practice, trying to find an acceptable set of weights for an MLP network manually would be an incredibly laborious task. In fact, it is &lt;a href="https://en.wikipedia.org/wiki/NP-completeness" rel="noopener noreferrer"&gt;NP-complete&lt;/a&gt; (Blum and Rivest, 1992). However, it is fortunately possible to learn a good set of weight values automatically through a process known as backpropagation. This was first demonstrated to work well for the XOR problem by Rumelhart et al. (1985).&lt;/p&gt;

&lt;p&gt;The backpropagation algorithm begins by comparing the actual value output by the forward propagation process to the expected value and then moves backward through the network, slightly adjusting each of the weights in a direction that reduces the size of the error by a small degree. Both forward and back propagation are re-run thousands of times on each input combination until the network can accurately predict the expected output of the possible inputs using forward propagation.&lt;/p&gt;

&lt;p&gt;For the XOR problem, 100% of possible data examples are available to use in the training process. We can therefore expect the trained network to be 100% accurate in its predictions and there is no need to be concerned with issues such as &lt;a href="https://en.wikipedia.org/wiki/Bias%E2%80%93variance_tradeoff" rel="noopener noreferrer"&gt;bias and variance&lt;/a&gt; in the resulting model.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this post, we explored the classic ANN XOR problem. The problem itself was described in detail, along with the fact that the inputs for XOR are not linearly separable into their correct classification categories. A non-linear solution — involving an MLP architecture — was explored at a high level, along with the forward propagation algorithm used to generate an output value from the network and the backpropagation algorithm, which is used to train the network.&lt;/p&gt;

&lt;p&gt;The next post in this series will feature a implementation of the MLP architecture described here, including all of the components necessary to train the network to act as an XOR logic gate.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Blum, A. Rivest, R. L. (1992). Training a 3-node neural network is NP-complete. Neural Networks, 5(1), 117–127.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Minsky, M. Papert, S. (1969). Perceptron: an introduction to computational geometry. The MIT Press, Cambridge, expanded edition, 19(88), 2.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rumelhart, D. Hinton, G. Williams, R. (1985). Learning internal representations by error propagation (No. ICS-8506). California University San Diego LA Jolla Inst. for Cognitive Science.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
      <category>datascience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Demystifying Extreme Learning Machines: Part 1</title>
      <dc:creator>Jayesh Bapu Ahire</dc:creator>
      <pubDate>Wed, 01 Apr 2020 13:52:55 +0000</pubDate>
      <link>https://dev.to/jbahire/demystifying-extreme-learning-machines-part-1-22h2</link>
      <guid>https://dev.to/jbahire/demystifying-extreme-learning-machines-part-1-22h2</guid>
      <description>&lt;p&gt;&lt;strong&gt;Artificial Intelligence&lt;/strong&gt; is hot research area since past few years and there are many major breakthroughs happening in this area. The traditional problems (or goals) of AI research include reasoning, knowledge representation, planning, learning, natural language processing, perception and the ability to move and manipulate objects. Extreme Learning Machines (ELMs)—has become one of the hot area of research over  the  past years, many researchers around the world are contributing to the research in this topic.&lt;/p&gt;

&lt;p&gt;In this series of articles, we will explore &lt;strong&gt;Extreme Learning Machines [ELMs]&lt;/strong&gt;. In this part, we will see introductions to various concepts which will help us understand ELMs in details.&lt;/p&gt;

&lt;p&gt;According to &lt;a href="http://www.eee.ntu.edu.sg/NewsnEvents/PeopleProfile/Pages/HuangGuangbin.aspx"&gt;Professor Huang Guangbin&lt;/a&gt;, Extreme Learning Machines (ELM) are filling the Gap between Frank Rosenblatt's Dream and John von Neumann's Puzzle. &lt;/p&gt;

&lt;p&gt;Let's go 60 years back and see what he meant by that:&lt;/p&gt;

&lt;p&gt;Rosenblatt made statements about the perceptron that caused a heated controversy among the fledgling AI community. Based on Rosenblatt's statements, The New York Times reported the perceptron to be "the embryo of an electronic computer that [the Navy] expects will be able to walk, talk, see, write, reproduce itself and be conscious of its existence. Which was to be fair is the definition of cognition. &lt;code&gt;[http://en.wikipedia.org/wiki/Perceptron]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In their book &lt;code&gt;Perceptron [1969]&lt;/code&gt;, the famous pioneers in AI Marvin Minsky and Seymour Papert claimed that the simple &lt;a href="https://medium.com/@jayeshbahire/the-xor-problem-in-neural-networks-50006411840b"&gt;XOR cannot be resolved by two-layer of feedforward neural networks&lt;/a&gt;, which "drove research away from neural networks in the 1970s, and contributed to the so-called AI winter".&lt;code&gt;[Wikipedia 2013]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;During same time, John Von Neumann felt puzzled on why "an imperfect (biological) neural network, containing many random connections, can be made to perform reliably those functions which might be represented by idealized wiring diagrams.”&lt;/p&gt;

&lt;p&gt;If you want to read more about what are Artificial Neural Networks, you can read my series over here.&lt;/p&gt;

&lt;p&gt;For now, Let's see what are FeedForward Neural Network: &lt;/p&gt;

&lt;h3&gt;
  
  
  Feedforward neural network :
&lt;/h3&gt;

&lt;p&gt;Feedforward neural network is the first invention is also the most simple artificial neural network. It contains multiple neurons (nodes) arranged in multiple layers. Adjacent layer nodes have connections or edges. All connections are weighted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9Y3NQK30--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/1300/0%2AhBHGyyDt5EtV9Uq2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9Y3NQK30--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/1300/0%2AhBHGyyDt5EtV9Uq2.jpg" alt="" width="650" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A feedforward neural network can contain three kinds of nodes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Monolayer:&lt;/code&gt; This is the simplest feedforward neural network that does not contain any hidden layers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Multilayer Perception:&lt;/code&gt; Multilayer Perception has at least one hidden layer. We will only discuss multilayer perceptrons below, as they are more useful than single-layer perceptrons in today’s real world.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Multilayer perceptrons:&lt;/code&gt; Multilayer Perceptron (MLP) includes at least one hidden layer (except for one input layer and one output layer). Single-layer sensors can only learn linear functions, while multi-layer sensors can also learn nonlinear functions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Broadly describing there are 3 types of layers:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Input Layer:&lt;/code&gt; The input layer has three nodes. The offset node value is 1. The other two nodes take external inputs from X1 and X2 (both are digital values ​​from the input data set). As discussed above, no calculations are performed at the input layer, so the output of the input layer node is 1, and three values ​​X1 and X2 are passed to the hidden layer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Hidden layer:&lt;/code&gt; Hidden layer also has three nodes, offset node output is 1. The output of the other two nodes of the hidden layer depends on the output (1, X1, X2) of the input layer and the weight attached to the connection (boundary). Figure 4 shows the calculation of an output in hidden layer (highlighted). The output of other hidden nodes is calculated in the same way. Note that f refers to the activation function. These outputs are passed to nodes in the output layer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Output Layer:&lt;/code&gt; The output layer has two nodes that receive input from the hidden layer and perform calculations similar to the highlighted hidden layer. These calculated values ​​(Y1 and Y2) as the result of the calculation are the output of the multilayer sensor.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For our convenience let's classify feedforward neural networks into two categories: &lt;strong&gt;Single-Hidden-Layer Feedforward Networks (SLFNs)&lt;/strong&gt; and &lt;strong&gt;Multi-Hidden-Layer Feedforward Networks&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mathematical Model for SLFNs–
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Approximation capability [Leshno 1993, Park and Sandberg 1991]:&lt;/code&gt;  Any continuous target function f(x) can be approximated by SLFNs with adjustable hidden nodes. In other words, given any small positive value 

&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;ε\varepsilon&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;ε&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 , for SLFNs with enough number of hidden nodes (L) we have 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;∣∣fa(x)−f(x)∣∣−ε|\left | {f_{a}}(x) - f(x)|\right | - \varepsilon&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;∣&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;f&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;f&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathnormal"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mord"&gt;∣&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;ε&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Classification capability [Huang, et al 2000]:&lt;/code&gt; As long as SLFNs can approximate any continuous target function f(x), such SLFNs can differentiate any disjoint regions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--asnkqx1S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/Blog_images/elm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--asnkqx1S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/Blog_images/elm.png" alt="" width="800" height="829"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;A. Learning Issues:&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Conventional theories: only resolves the existence issue, however, does not tackle learning issue at all.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In real applications, target function f is usually unknown. One wishes that unknown f could be approximated by SLFNs appropriately 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;fl{f_{l}}&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;f&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;l&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;B. Learning Methods:&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Many learning methods mainly based on gradient-descent / iterative approaches have been developed over the past three decades.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Back-Propagation (BP) [Rumelhart 1986]and its variants are most popular.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Least-square (LS) solution for RBF network, with singleimpact factor for all hidden nodes &lt;code&gt;[Broomhead and Lowe 1988]&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;QuickNet&lt;code&gt;(White, 1988)&lt;/code&gt; and Random vector functional network (RVFL) &lt;code&gt;[Igelnikand Pao 1995]&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Support vector machines and its variants. &lt;code&gt;[Cortes and Vapnik 1995]&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deep learning: dated back to 1960s and resurgence in mid of 2000s &lt;code&gt;[wiki 2015]&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Let's understand the Aim of ELM:
&lt;/h4&gt;

&lt;p&gt;According to Professor Huang:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Unlike conventional learning theories and tenets, our doubts are "Do we really need so many different types of learning algorithms (SVM, BP, etc) for so many different types of networks (different types of SLFNs (RBF networks, polynomial networks, complex networks, Fourier series, wavelet networks, etc) and multi-layer of architectures, different types of neurons, etc)? "&lt;/p&gt;

&lt;p&gt;Is there a general learning scheme for wide type of different networks (SLFNs and multi-layer networks)?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Neural networks (NN) and support vector machines (SVM) play key roles in machine learning and data analysis. Feedforward neural networks and support vector machines are usually considered different learning techniques in computational intelligence community. Both popular learning techniques face some challenging issues such as: &lt;strong&gt;intensive human intervene, slow learning speed, poor learning scalability.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is clear that the learning speed of feedforward neural networks including deep learning is in general far slower than required and it has been a major bottleneck in their applications for past decades. Two key reasons behind may be: &lt;code&gt;1) the slow gradient-based learning algorithms are extensively used to train neural networks, and 2) all the parameters of the networks are tuned iteratively by using such learning algorithms.&lt;/code&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Why ELM?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;How ELM theories manage to address the open problem which has puzzled the neural networks, machine learning and neuroscience communities for 60 years: &lt;code&gt;whether hidden nodes/neurons need to be tuned in learning&lt;/code&gt;, and proved that in contrast to the common knowledge and conventional neural network learning tenets, hidden nodes/neurons do not need to be iteratively tuned in wide types of neural networks and learning models (Fourier series, biological  learning,  etc.).  Unlike  ELM  theories,  none  of  those earlier works provides theoretical foundations on feedforward neural networks with random hidden nodes; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ELM is proposed for both generalized single-hidden-layer feedforward network and multi-hidden-layer feedforward networks(including biological  neural  networks);  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;homogeneous architecture-based ELM&lt;/code&gt; is proposed for feature  learning,clustering, regression and (binary/multi-class) classification.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compared to ELM, SVM and LS-SVM tend to provide suboptimal solutions, and SVM and LS-SVM do not consider feature representations in hidden layers of multi-hidden-layer feedforward networks either.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What's next
&lt;/h3&gt;

&lt;p&gt;Now we know all the basics which are required to understand ELM better and we are good to go deep to understand mathematical aspect of ELM along with details of how that works.&lt;br&gt;
In next part, we will &lt;strong&gt;define ELM and see how ELMs learn&lt;/strong&gt;. If you want to learn more about &lt;a href="https://medium.com/coinmonks/the-artificial-neural-networks-handbook-part-1-f9ceb0e376b4"&gt;Neural Networks&lt;/a&gt;, &lt;a href="https://medium.com/@jayeshbahire/the-xor-problem-in-neural-networks-50006411840b"&gt;XoR Problem&lt;/a&gt; you can visit articles I linked here.&lt;/p&gt;

&lt;h4&gt;
  
  
  References:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.sciencedirect.com/science/article/abs/pii/S0925231206000385"&gt;Extreme learning machines: theory and applications&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.sciencedirect.com/science/article/abs/pii/S0925231219302073"&gt;Convolutional neural network based on an extreme learning machine for image classification&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.ntu.edu.sg/home/egbhuang/"&gt;Extreme Learning Machines&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.ntu.edu.sg/home/egbhuang/pdf/ELM-Rosenblatt-Neumann.pdf"&gt;What are Extreme Learning Machines? Filling the Gap BetweenFrank Rosenblatt’s Dream and John von Neumann’s Puzzle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/@jayeshbahire/perceptron-and-backpropagation-970d752f4e44"&gt;Perceptron and backpropagation&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
      <category>datascience</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Building BookWorm: A book info &amp; recommendation bot using Twilio!</title>
      <dc:creator>Jayesh Bapu Ahire</dc:creator>
      <pubDate>Mon, 30 Mar 2020 17:59:30 +0000</pubDate>
      <link>https://dev.to/twilio/building-bookworm-a-book-info-recommendation-bot-using-twilio-i63</link>
      <guid>https://dev.to/twilio/building-bookworm-a-book-info-recommendation-bot-using-twilio-i63</guid>
      <description>&lt;p&gt;In previous article, we built the WhatsApp bot to fight fake news! If you missed it you can check it out &lt;a href="https://dev.to/twilio/fake-news-foe-machine-learning-and-twilio-5fln"&gt;here&lt;/a&gt;. In this detailed tutorial we will see how we can build a bot which will give us some book recommendations and tell us information about a book we want.&lt;/p&gt;

&lt;p&gt;Let's just jump into this!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/3bzBs5iaHaOPKx8NmM/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/3bzBs5iaHaOPKx8NmM/giphy.gif" alt="Let's just jump into this" width="480" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Aim:
&lt;/h3&gt;

&lt;p&gt;We will be building the WhatsApp bot which will give us more information about the book whose name we will be providing as an input and will also recommend us similar books!&lt;/p&gt;

&lt;h3&gt;
  
  
  What we will need?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A Twilio account ---&lt;a href="//www.twilio.com/referral/YmyL1H"&gt;  sign up for a free one here&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A Twilio whatsapp sandbox ---&lt;a href="https://www.twilio.com/console/sms/whatsapp/sandbox"&gt;  configure one here&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5DLykB50--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/Blog_images/console.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5DLykB50--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/Blog_images/console.png" alt="" width="800" height="804"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.twilio.com/docs/usage/tutorials/how-to-set-up-your-python-and-flask-development-environment"&gt;Set up your Python and Flask developer environment&lt;/a&gt; --- Make sure you have Python 3.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://ngrok.com/"&gt;ngrok&lt;/a&gt; so we can &lt;a href="https://www.twilio.com/blog/2015/09/6-awesome-reasons-to-use-ngrok-when-testing-webhooks.html"&gt;expose our local endpoints so that we can receive incoming webhooks&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Dataset:
&lt;/h3&gt;

&lt;p&gt;We will be using &lt;a href="https://github.com/zygmuntz/goodbooks-10k"&gt;goodbooks-10k&lt;/a&gt; dataset.&lt;/p&gt;

&lt;p&gt;This dataset contains six million ratings for ten thousand most popular (with most ratings) books. There are also:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;books marked to read by the users&lt;/li&gt;
&lt;li&gt;book metadata (author, year, etc.)&lt;/li&gt;
&lt;li&gt;tags/shelves/genres&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can download zipped data from here: &lt;a href="https://github.com/zygmuntz/goodbooks-10k/releases"&gt;https://github.com/zygmuntz/goodbooks-10k/releases&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Pre-Processing:
&lt;/h3&gt;

&lt;p&gt;We will do some preprocessing for initial stage. This is ready to use dataset though we will drop some columns which we will not be using and fill some blank cells.&lt;br&gt;
Initially the dataset has 23 columns out of which we dropped 4 columns which are title, work_ratings_count, image_url and small_image_url as we won't be using them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# importing pandas module 
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt; 

&lt;span class="c1"&gt;# making data frame from csv file 
&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;books.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index_col&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; 

&lt;span class="c1"&gt;# dropping passed columns 
&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;work_ratings_count&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;image_url&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;small_image_url&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;axis&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inplace&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#filling blank values with "Not Available" 
&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fillna&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Not Available&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will do some occasional formatting whenever needed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Let's split further task into two modules:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Fetch Book information &lt;/li&gt;
&lt;li&gt;Book recommendation system&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's see first part: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KADTSLc2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://i.gifer.com/S3sm.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KADTSLc2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://i.gifer.com/S3sm.gif" alt="" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Fetch Book information:
&lt;/h4&gt;

&lt;p&gt;This part is very simple and you don't need to know anything apart from basic python.&lt;br&gt;
Here, we will go through our clean CSV file which we got after preprocessing and search for book title which we received from user in title field in csv (which is renamed original_title field).&lt;br&gt;
If we find a match we will return the index of that row and store that index into list of matched books.&lt;br&gt;
So now we have the list of indexes books matching to user query. Now we can fetch whatever information we want so let's just keep this list aside for a second.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_matches&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;book_title&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;matching_books_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;clean_books.csv&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;file_reader&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;flines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;file_reader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readline&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flines&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rstrip&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
        &lt;span class="n"&gt;search&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;file_reader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readlines&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sline&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;book_title&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;sline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
                &lt;span class="n"&gt;matching_books_list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;matching_books_list&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we have to see how we can infer for serving results on WhatsApp!&lt;br&gt;
Let's create a flask server for that which we can use to serve our book information API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/sms&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;methods&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;POST&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sms&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MessagingResponse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;inbMsg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Body&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;book_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;book_ratings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_matches&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inbMsg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;clean_books.csv&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;book_list&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;The book with title&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;original_title&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;iloc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;written by &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;authors&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;iloc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;has average user rating of &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;average_rating&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;iloc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; and this book is reviewed by &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;work_text_reviews_count&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;iloc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;people.&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt; ---------------------------------&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's go ahead and see how we can build the recommendation engine.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Book recommendation engine:
&lt;/h4&gt;

&lt;p&gt;We will generate recommendations using 3 different criteria. For all of them we will vectorize the input and find the cosine similarity with our particular columns in our dataset and return ones those have very high similarity.&lt;br&gt;
Let's see how we can do this&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Author Based recommendations:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;tf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TfidfVectorizer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;analyzer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;word&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;ngram_range&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;min_df&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stop_words&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;english&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;tfidf_matrix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;authors&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;cosine_sim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;linear_kernel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tfidf_matrix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tfidf_matrix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Build a 1-dimensional array with book titles
&lt;/span&gt;&lt;span class="n"&gt;titles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;indices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Series&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Function that get book recommendations based on the cosine similarity score of book authors
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;authors_recommendations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;indices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;sim_scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cosine_sim&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
    &lt;span class="n"&gt;sim_scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sim_scores&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;sim_scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sim_scores&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;book_indices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;sim_scores&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;titles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iloc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;book_indices&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Tags based recommendations:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;tf1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TfidfVectorizer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;analyzer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;word&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;ngram_range&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;min_df&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stop_words&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;english&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;tfidf_matrix1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tf1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;books_with_tags&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;tag_name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;head&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;cosine_sim1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;linear_kernel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tfidf_matrix1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tfidf_matrix1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Build a 1-dimensional array with book titles
&lt;/span&gt;&lt;span class="n"&gt;titles1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;indices1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Series&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Function that get book recommendations based on the cosine similarity score of books tags
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;tags_recommendations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;indices1&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;sim_scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cosine_sim1&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
    &lt;span class="n"&gt;sim_scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sim_scores&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;sim_scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sim_scores&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;book_indices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;sim_scores&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;titles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iloc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;book_indices&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Corpus based recommendations:
In this we will build recommendation of books using the authors and tags attributes for better results. We will create corpus of features and calculate the TF-IDF on the corpus of attributes for gettings better recommendations.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;corpus&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Series&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;authors&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;tag_name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
                &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fillna&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tolist&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                &lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;tf_corpus&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TfidfVectorizer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;analyzer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;word&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;ngram_range&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;min_df&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stop_words&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;english&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;tfidf_matrix_corpus&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tf_corpus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;corpus&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;cosine_sim_corpus&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;linear_kernel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tfidf_matrix_corpus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tfidf_matrix_corpus&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Build a 1-dimensional array with book titles
&lt;/span&gt;&lt;span class="n"&gt;titles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;indices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Series&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;books&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Function that get book recommendations based on the cosine similarity score of books tags
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;corpus_recommendations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;indices1&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;sim_scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cosine_sim_corpus&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
    &lt;span class="n"&gt;sim_scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sim_scores&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;sim_scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sim_scores&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;book_indices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;sim_scores&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;titles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iloc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;book_indices&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Above functions will return list of recommended books but for the sake of inference we will return list of indexes which match our criteria using &lt;code&gt;return book_indices&lt;/code&gt; instead of &lt;code&gt;return titles.iloc[book_indices]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now let's see how inferencing will work in case of book recommendation system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/sms&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;methods&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;POST&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sms&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MessagingResponse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;inbMsg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Body&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;recommendations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;corpus_recommendations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inbMsg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;clean_books.csv&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Recommendations based on your input:&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;message &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;original_title&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;iloc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use any of the recommendation function though I have used corpus recommendation here as it considers both author and tags.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final steps
&lt;/h3&gt;

&lt;p&gt;Once this is done, we will run our flask server using this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;FLASK_APP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="n"&gt;FLASK_ENV&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;development&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To test this we'll need to open up a tunnel to our server running on our machine. We will be using ngrok for this. Run this once you have installed ngrok:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ngrok http 5000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will open a tunnel pointing to port 5000 and will provide us a  public ngrok URL which will point to our local application. Now, we have to open the WhatsApp Sandbox in our Twilio console and enter that URL plus the path &lt;code&gt;/sms&lt;/code&gt; into the field labelled &lt;code&gt;When a message comes in&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XrFL2B7b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/Blog_images/twilio-console.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XrFL2B7b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/Blog_images/twilio-console.png" alt="" width="800" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's send our sandbox number a message with book name and let's see results:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Book Information&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eaj69P_y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/Blog_images/info.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eaj69P_y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/Blog_images/info.jpg" alt="" width="800" height="1676"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Book Recommendation &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cfbS393h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/Blog_images/recom.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cfbS393h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://s3.amazonaws.com/fininity.tech/Blog_images/recom.jpg" alt="" width="800" height="891"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have successfully generated book information and recommendation! Isn't this cool?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Hti_tHMV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://lh3.googleusercontent.com/proxy/bflKruxU76AKnR7Zc_9ZInZZk5qc5zF0cUZL6EXSVkPgsUeT9KWVmwP1Odz0RfNy2XFYbdd0GX-zEFd6J3LUWPY-e5v1rSX0n-SEOj4876vljTMKCA5JG4hl8imgndBfs19B2snF7pDI5WDF69QyI4gK719qDa0EOxE" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Hti_tHMV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://lh3.googleusercontent.com/proxy/bflKruxU76AKnR7Zc_9ZInZZk5qc5zF0cUZL6EXSVkPgsUeT9KWVmwP1Odz0RfNy2XFYbdd0GX-zEFd6J3LUWPY-e5v1rSX0n-SEOj4876vljTMKCA5JG4hl8imgndBfs19B2snF7pDI5WDF69QyI4gK719qDa0EOxE" alt="" width="400" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find the complete code &lt;a href="https://github.com/JBAhire/BookWorm"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's next?
&lt;/h3&gt;

&lt;p&gt;This was an basic intro to how you can create an recommendation system using Twilio WhatsApp API or Messaging API. You can use similar approach to enhance customer experience in your business.&lt;br&gt;
What you are planning to build with this? Let me know in comments below or hit me up on &lt;a href="https://twitter.com/Jayesh_Ahire1"&gt;twitter&lt;/a&gt; ! &lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>ai</category>
      <category>twiliohackathon</category>
    </item>
  </channel>
</rss>
