<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adithya Penagonda on Medium]]></title>
        <description><![CDATA[Stories by Adithya Penagonda on Medium]]></description>
        <link>https://medium.com/@penadi?source=rss-8cc5f069719f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sfdDm6BSr-ZfdIm7qcpv0g.png</url>
            <title>Stories by Adithya Penagonda on Medium</title>
            <link>https://medium.com/@penadi?source=rss-8cc5f069719f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 00:34:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@penadi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AI is chasing something it’ll never reach]]></title>
            <link>https://medium.com/@penadi/ai-is-chasing-something-itll-never-reach-dd3d300b17a5?source=rss-8cc5f069719f------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd3d300b17a5</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[thermodynamics]]></category>
            <dc:creator><![CDATA[Adithya Penagonda]]></dc:creator>
            <pubDate>Sat, 14 Mar 2026 14:33:13 GMT</pubDate>
            <atom:updated>2026-03-14T14:33:13.477Z</atom:updated>
            <content:encoded><![CDATA[<p>Since the launch of GPT, AI has been mainstream and as every headline claims, everyone is waiting for when It’ll replace humans?</p><p>But what if I say, It’s physically impossible for it to ever reach a human brain.</p><h3>Parameters vs. Synapses</h3><p>During 1940s and 50s, when researchers were trying to build <em>Artificial Intelligence, </em>one good way was to reverse engineer a human brain. The early neural network was a mathematical reduction of a neuron. There were several reasons why it’s considered mimicing a human brain:</p><ol><li><strong>Both learn from examples: </strong>Even seen a shakespear like child? Even a child learns from real life examples, as the neurons in their brain adjust internal connections through exposure and feedback.</li><li><strong>Both are pattern recognition machines: </strong>At the core of brain, it’s great at identifying patterns. Show a kid a gray cat, what would he say when he sees a black cat?</li><li><strong>Both have “layers” of abstraction: </strong>Most CNNs are inspired from the way our visual cortex processes images. edges -&gt; Shapes -&gt; Objects -&gt; etc.</li><li>And finally both get better with<strong> more data and connections.</strong></li></ol><p>As simple as it seems the comparision is not straight forward</p><p>A synapse is chemical and an electrical reaction, while most connections in a neural network is just matrix multiplication. Brain learns by structural rewiring powered by hormones, sleep and so many other factors while learning in a AI model is typically Gradient Descent, backpropagation.</p><p>Ironically, most companies who like to compare AI models do not release the exact parameter number. <strong>GPT3 was 175 Billion (B)</strong>, <strong>Gemini Ultra is predicted near 1 Trillion (T)</strong>, and the best open source model available in terms of number of parameters is <strong>Deepseek V3 with 671B</strong> parameters.</p><p>For a comparison, take a look at the graph below:</p><figure><img alt="A graph showing the diffences in parameter counts for different models" src="https://cdn-images-1.medium.com/max/750/1*wLyx3u0dlYGns1bS8UQIJQ.gif" /></figure><p>Now take a guess how this does in front of an average human brain? There’s no exact answer of how many synapses a human has, but a very widely cited estimate is <strong>10¹⁴ to 5 × 10¹⁴ synapses.</strong></p><p>Again comparing a direct number of synapses to parameters is trying to compare life with non living things. Another interesting study suggested that</p><blockquote>“5–8 layers with about 1000 neurons in total in an artificial neural network is required to simulate a single biological neuron of a certain kind”</blockquote><p>These models are obliterated just with this comparision, even with 100B neurons in a human brain, it takes approximately 100T parameters for a AI model to even reach the physical number of neurons close to a human brain.</p><p>Even if we ever reach those numbers, Synapses learn through <strong>Hebbian plasticity </strong>(It’s local, continuous, and doesn’t require a global error signal passed back through the whole system), Not to forget Synapses are 3D and operate in analog.</p><p>Now that we’ve established we’re pretty far from ever reaching numbers close to our brain, is it impossible? and why is Claude Opus 4.6 crushing in coding and other benchmarks? It’s 0–1 with my Grandma and AI, does that mean my grandma is useless? Ofcouse no!</p><p>As some redditor said “It’s like comparing strawberries to vegetables”, is a perfect way to put it. LLMs don’t work by actually thinking, It’s not thinking. It’s pattern completion at extreme scale. When a programmer tries to solve a problem they usually build a mental model of the problem, feeling frustrated, having an insight in the shower. but LLMs have seen so much code that a human lifetime isn’t sufficient. Do not get fooled by the benchmarks, they only compare the output and not the process that got it there.</p><h3>Thermodynamics of AI</h3><p>Every year, we’ve been making progress in increasing the number of parameters and making models bigger and bigger. Every few months a company starts a demo with “Our best model ever”, so is there a hope that we’ll reach a human brain (close to what everyone calls AGI)?</p><p>While the number maybe achievable, physics itself is a wall. We’ve established that even matching brain’s numbers is a near impossible task. But let’s say, hypothetically we built a system with 100T parameters, 3D analog connections, and continous Hebbian learning, could we get it to actually work in real world?</p><p>If anyone doesn’t remember the second law of thermodynamics, it’ll be a good time to revise. Every computation, at its most fundamental level, generates heat. In 1961 Rolf Landeraur proved that erasing a single bit of information dissipates a minimum amount of energy as heat approximately <strong>2.9 × 10⁻²¹ joules</strong> at room temperature. This is called Landauer Limit, and current transistors operate at roughly <strong>1,000 times above</strong> the Landauer limit</p><h4>Let’s do the math</h4><p>The human brain performs an estimated <strong>10¹⁵ to 10¹⁷ synaptic operations per second</strong>, and that too on <strong>20 Watts </strong>and that’s an energy efficiency of roughly <strong>10 petaFLOPS per watt</strong> at the high end.</p><p>The Nvidia H100, the chip powering most frontier AI today. delivers roughly <strong>2,000 teraFLOPS</strong> of AI performance and consumes <strong>700 watts.</strong> That’s approximately <strong>3 teraFLOPS per watt</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TAUM7jciFnnd6atSbBMSQg.jpeg" /><figcaption>Nvidia H100 ref: Nvidia</figcaption></figure><p>For comparison, our brain 3333 times more efficient. You can’t even see it on the graph😭</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*f5-XXECThhUFCby1TgtifA.png" /><figcaption>Efficiency of human brain vs Nvidia H100</figcaption></figure><p>To run a brain-scale AI model continuosly (Remember, not to train but just for Inference), on current hardware would require somewhere between <strong>1 and 10 gigawatts of continuous power. </strong>To put that to perspective it’s how much Mumbai and Bangalore use combined or here’s something more fun, the Indian Railways (4th largest in the world) averages roughly <strong>2–2.3 GW continuously, </strong>that means One AGI system would need <strong>4–5 times the power of all Indian Railways, </strong>every train, every station, every signal system, all running at once.</p><p>It only gets worse if you think of Heat Density. Our brain is dense, approx <strong>1500 cubic centimeters</strong>. and running at 20W of power, That’s a power density of about <strong>0.013 watts per cubic centimeter. </strong>And blood does a good job acting as a liquid cooling system. Comparing it to Nvidia H100 (assuming Die size of 814mm², 700W TDP and 2–3 cm² for the chip) we get a power density of roughly <strong>175–230 watts per cubic centimeter. </strong>Thats <strong>15000x</strong> more☠️ and we have <strong>no known cooling technology that can handle this.</strong></p><p>There are many more reasons to why achieving a human level efficiency is almost impossible. Since curiosity is not something that shouldn’t be hidden, I have another optional analysis:<br>The costs of running this hypothetical model are insane, India’s average industrial electricity tariff of roughly <strong>₹6–8 per kWh, <br>- </strong>10 GW running continuously = <strong>87,600,000 kWh per day<br>- </strong>At ₹7/unit = approximately <strong>₹6,132 crore per day<br>- </strong>Per year = roughly <strong>₹22 lakh crore annually</strong></p><p>Our National budget for 2026–2027 is <strong>₹53.5 lakh crore, </strong>while the budget for our brain is 3 meals a day.</p><h3>Conclusion</h3><p>As much as I like to grill AI ever reaching human level, I’m an optimist for AI. The comparision I did might be biased for various reasons but the math is not. The current approach for AI, is not the only approach, there are several researchers that look at other ways to build AI. LLMs are the only ones that got famous. Industry has a long catchup to do with academia in context of AI.</p><p>some references:<br><a href="https://www.lesswrong.com/posts/7htxRA4TkHERiuPYK/parameter-vs-synapse">parameter vs synapses</a><br><a href="https://www.anthropic.com/news/claude-opus-4-6">Opus 4.6</a><br><a href="https://forum.effectivealtruism.org/posts/h7Rj8Y8YWZccYMy5J/it-takes-5-layers-and-1000-artificial-neurons-to-simulate-a">Human brain to Artifical Neuron</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd3d300b17a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Who’s at Loss?]]></title>
            <link>https://medium.com/@penadi/whos-at-loss-0b921b3e1bb4?source=rss-8cc5f069719f------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b921b3e1bb4</guid>
            <category><![CDATA[google-summer-of-code]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[ml4sci]]></category>
            <dc:creator><![CDATA[Adithya Penagonda]]></dc:creator>
            <pubDate>Sun, 29 Sep 2024 04:52:07 GMT</pubDate>
            <atom:updated>2024-09-29T04:52:07.774Z</atom:updated>
            <content:encoded><![CDATA[<p>Google Summer of Code 2024 | ML4SCI | Implementation of Quantum Generative Adversarial Networks to Perform HEP Analysis at LHC</p><p>Over summer, we’ve worked extensively to experiment and understand generative capabilities of Quantum Algorithms. But for most of them, a very fair question to ask is, “are classical systems so bad right now, that we’re looking for quantum ones?”<br>No, classical systems may actually still be better than any quantum algorithms we have, and that’s mainly because of the current state of quantum hardware available.</p><p>Quantum Algorithms are not just faster than classical ones, in a very few use cases they perform better than classical counterparts. If you ask a Quantum computer to multiply a 4 x 4-digit number, your 10-year-old phone can perform that quicker. If this is the case, what did we work on for the last few months?<br>Our goal was to experiment if there were any specific use-cases that quantum computing could do better in terms of High Energy Physics. Our previous contributors did great work in finding these, and now we work to further improve them.</p><p>Before you read further, if you are not aware of GANs or how quantum systems work, read my mid-term blog for understanding by <a href="https://medium.com/@swheatdreamz/gsoc-24-quantum-generative-adversarial-networks-for-hep-event-generation-the-lhc-4bb1fb50faba">clicking here.</a></p><h3>Lost at Loss</h3><p>For all those who’ve worked with neural networks, must have come across Loss function. To put it simply, it&#39;s a mathematical equation that defines how well the model’s predictions match the true data. If the model is bad, the value of loss is higher, telling the model to improve.<br>Here’s another good question to ask, “So if loss functions tell how good the model is doing to match real data, can it be used as a metric to measure the performance of a model?” Absolutely, we can.</p><p>Loss not just helps us to make a model better, but also controls trade-offs. During the first few weeks of our work, we implemented various classical models. (Results were shared in the <a href="https://medium.com/@swheatdreamz/gsoc-24-quantum-generative-adversarial-networks-for-hep-event-generation-the-lhc-4bb1fb50faba">mid-term blog</a>)<br>Even for classical models, it’s not easy for them to learn due to the very nature of jet images. The images are quite sparse, making them really hard for models to understand. It’s like you are given a book of 1000 pages, where most pages have just a few words and just a few pages with over 500 words.</p><p>The most basic loss, “The log loss” simply fails to work here. It leads to mode collapse. We then tested with it three different types of loss functions, let’s take some time to understand them. For more of a mathematical explanation, refer to mid-term blog or Jupyter notebooks.</p><ol><li><strong>Wasserstein GAN loss: </strong>It’s similar to traditional GAN losses, instead of using the sigmoid cross-entropy loss, it uses the Wasserstein distance to provide a meaningful measure of how far the generated data distribution deviates from the actual data distribution.</li><li><strong>Total Variation loss: </strong>Since we work with images, and images have pixels we can use that as an advantage to see how well the pixel intensities lie in the generated images as compared to real ones.</li><li><strong>Perceptual Loss: </strong>Here we use a pre-trained network to extract feature spaces of both real and generated ones, and then compare both of these spaces.</li></ol><p>We’ve used all three loss functions, kept all other parts of the pipeline same. here were the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X0sqnXLKRdqgaP3ibIr6Nw.png" /><figcaption>FID scores vs iterations</figcaption></figure><p>FID scores are computed as the Fréchet distance between the two multivariate Gaussian distributions defined by the means and covariances of the real and generated images. The lower the FID scores, the better the model performs. One of the observations we made here are, that Loss functions have a major effect on the performance of any model.</p><p>Another good observation is that loss functions that focus of image features or on comparing pixel intensities outperform standard GAN losses based on entropy.</p><h3>Who’s fully Quantum?</h3><p>In our mid-term blog, we’ve discussed about hybrid Quantum architectures. Since our current state of Quantum computers have very few qubits to work with, we have a constraint of finding ways to use them as an advantage.</p><p>In our work, we used a Hybrid Quantum model with a classical upscaler. Take a look at the architecture of the quantum generator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mg5cmP02SBP3FpFhGFgBjQ.png" /><figcaption>Quantum Generator for hybrid models</figcaption></figure><p>Well, this performs very similar to the classical model, guess why?</p><p>It’s mainly due to the amount of classical influence we have. The output of VQC is only the size of the number of qubits we use. Even for simulations we cannot go with really high numbers, ideally, we would choose something from 4 to 8 qubits. For an image, as small as 28x28 still is upscaled by classical layers. <br>The added randomness from the VQC did add some advantage, but it’s just so similar to the classical ones, there’s no real winner here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*1IwNJVkT3ptgzt3W.png" /><figcaption>FID vs Models over epochs</figcaption></figure><p>A more detailed analysis on this result was discussed in my mid-term blog. Another important detail to notice is that this hybrid model was trained on lesser data than any classical model. We followed a 1:7 ratio, and to our surprise it still performed equivalently.</p><p>Yes, we did implement a fully quantum model. But let’s explore how we got there. IQGANs, was an amazing paper that explored some really good method to make noise free outputs. We spent quite some time replicating those results. You can find the code for this in ML4SCI GitHub.<br>To our surprise, this model works great. Take a look at the circuit used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qeb6pWznOhcjTpI04fk3LQ.png" /></figure><p>We implemented this using Pennylane, probably one of the easiest libraries to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gM26fNva-v8HdZSGY6bJqQ.gif" /><figcaption>training IQGAN with jet images</figcaption></figure><p>The most surprising thing is, the training was done by providing just 10K images, that’s just 1.5% of the data we gave a classical model. Though visually similar to real data, the math doesn’t add up. We found that the FID scores of these images generated are quite high.</p><p>Leading to another important question, why are we using a classical metric for measuring how good a quantum model performs?</p><p>To understand this, lets first decipher why FID is bad when used for quantum models</p><ol><li>InceptionV3 model cannot process quantum states because it was designed for classical data.</li><li>The dimensions required by InceptionV3 is much higher than what our quantum models produce.</li><li>InceptionV3 extracts features based on classical image properties like edges, textures, and shapes. Quantum data, however, doesn’t have an analogous feature space that is directly comparable.</li></ol><p>While using FID scores, we don’t even compare the feature space of a quantum distribution by using a classical model like inception.</p><p>But aren’t there any ways to compare quantum spaces? OfCourse, we have them. State fidelity measures the difference between two different quantum states. But if we only use State fidelity, how do we even compare these quantum models to the classical ones?</p><h3>Introducing Perceptual Quantum Loss</h3><p>To solve this issue, of having both classical and quantum parts for a model, so that we know how well the quantum states do, as well as how much visual similarity does it have.</p><p>We came up with a new loss function called Perceptual Quantum Loss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PdR4HhEMVBzIeCOInsH6kQ.png" /></figure><p>It has two parts: perceptual loss and fidelity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MKWL1rGZqprf0szsEIMTcg.png" /><figcaption>Perceptual Loss</figcaption></figure><p>Perceptual loss compares two feature spaces extracted by a pre-trained model like VGG, we made this choice as VGG is comparatively smaller than models like Inception.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yw6FTNFt2YH8sBh7pCBMjw.png" /><figcaption>State Fidelity</figcaption></figure><p>The State Fidelity measure how well the generated quantum state compares to the real one. This truly shows how well the quantum model is performing. Note that the higher the fidelity, the better. hence, we use 1-fidelity in our loss function.</p><p>Classical models do not have fidelity, but perceptual loss of both provide a comparable metric. The hyperparameters alpha and beta help in balancing tradeoffs.</p><h3>Any results?</h3><p>We used the above loss function, in a fully quantum GAN model (different from the IQGAN model). Note that training these models are computationally very expensive to train. With just a 100k images, it takes more than an hour per epoch even on A100 GPU.</p><p>So, we’ve used this loss function on a classical model, trained it with both 10k and 100k images, for 30 epochs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*Xvrn8Eh25FsjeCyQvtXoIw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*Irm-WaCIqa9OL5vadSbMMg.png" /></figure><p>We similarly trained a fully quantum model with the same 10k and 100k images. here is how they performed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*a-QDzlmVgkEIG-8Zd_qvpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*R48-0lyyoHRQyvRcoMgP3g.png" /></figure><p>So, in both of them, it’s pretty clear that the more the number of images, the better they perform.</p><p>Now, let’s see how they perform with respect to each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vyCeb36YSfu0V4kIa7skUQ.png" /></figure><p>The performance of the quantum model clearly outperforms the classical model, what this means is that the quantum model learns much faster than the classical ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uH_YhgcG9tfuTKhH-r3Eew.png" /></figure><p>For larger amount of data, Quantum model provided a vary comparable performance to classical ones, but the amount of computation required for Quantum model is exponentially high and in my opinion is not worth it.</p><p>We’ve further evaluated different values of alpha and beta to look at how well it performs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*1acRrlRwsDtleOg_7izlRg.png" /></figure><p>With this, we almost come to an end of our project. A few of my suggestions for future work would be to try optimizing the fully quantum models to work of larger amounts of data. Another one would be to further improve hybrid loss functions that work for both quantum and classical ones.</p><p>Note that these results are being further analyzed and might not be final.</p><h4>Footnotes</h4><p>Link for my code: <a href="https://github.com/ML4SCI/QMLHEP/tree/main/Quantum_GAN_for_HEP_Adithya_Penagonda">Click here</a><br>Link to my slides: <a href="https://www.figma.com/proto/iMmkVXKyAnJbFkPxtYhEpi/Gsoc-meeting-slides?node-id=109-2&amp;t=WXEJ2L9zZ7Iyztez-1&amp;scaling=contain&amp;content-scaling=fixed&amp;page-id=0%3A1">Click here<br></a>Link to my mid-term blog: <a href="https://medium.com/@swheatdreamz/gsoc-24-quantum-generative-adversarial-networks-for-hep-event-generation-the-lhc-4bb1fb50faba">Click here</a></p><p>A special thanks to all the members of the QMLHEP team, mentors Abhay Kamble, Tom Magorsch, Gopal Ramesh Dahale, Rui Zhang for their valuable time and suggestions. A Special mention to Sergei V. Gleyzer, Ph.D.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b921b3e1bb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSoC 24 | Quantum Generative Adversarial Networks for HEP event generation the LHC]]></title>
            <link>https://medium.com/@penadi/gsoc-24-quantum-generative-adversarial-networks-for-hep-event-generation-the-lhc-4bb1fb50faba?source=rss-8cc5f069719f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bb1fb50faba</guid>
            <category><![CDATA[google-summer-of-code]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[generative-adversarial]]></category>
            <category><![CDATA[ml4sci]]></category>
            <dc:creator><![CDATA[Adithya Penagonda]]></dc:creator>
            <pubDate>Wed, 24 Jul 2024 17:30:20 GMT</pubDate>
            <atom:updated>2024-07-26T04:34:13.359Z</atom:updated>
            <content:encoded><![CDATA[<p>How did Gen AI start? well, it’s GANs</p><p>I’m Adithya Penagonda, one of the contributors for <a href="https://github.com/ML4SCI/QMLHEP">ML4SCI/QMLHEP</a> for Google Summer of Code 2024. Here is my project page: <a href="https://summerofcode.withgoogle.com/programs/2024/projects/OKkyXUkV">link</a><br>This is a mid-term update of my project, all links available as footnotes.</p><h3>Understanding the Problem: Jet Generation in the LHC</h3><p>A marvel today in science, the Large Hadron Collider (LHC) smashes protons together almost as quickly as light in order to simulate conditions right after the Big Bang. Jets are among the different particles produced by these high-energy collisions. Particles that are sprayed into space as a result of quark and gluon hadronization are known as jets. Because they shed light on the fundamental particles and forces that comprise our universe, these jets are essential to the study of particle physics.</p><h3>Why Use GANs for Jet Generation?</h3><p>Conventional jet simulation techniques require large computational resources and intricate algorithms. Generative Adversarial Networks, or GANs, provide a viable substitute by using data to create realistic jet images. Two neural networks make up a GAN: the discriminator, which assesses the validity of the generated data, and the generator, which produces synthetic data. GANs can generate extremely realistic jet images by iteratively improving, greatly accelerating the simulation process.</p><p>The process is similar to that of a police officer trying to catch a fake note and the thief trying to generate better and better notes similar to that of original. A classical GAN looks something like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L0YYB1qaoiV_g3O4TVS_VQ.png" /><figcaption>classical GAN architecture</figcaption></figure><h3>GANs: How They Work</h3><p>A GAN consists of two main components:</p><ol><li><strong>Generator</strong>: Takes random noise as input and generates synthetic data.</li><li><strong>Discriminator</strong>: Evaluates the generated data against real data, aiming to distinguish between the two.</li></ol><p>The discriminator’s goal in the training process is to correctly identify real and fake data, while the generator’s goal is to trick the discriminator in a minimax game. This can be stated mathematically as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*7gtw3c3XMrGsDhgk4xdaKQ.png" /></figure><p>The most important parts of the a classical GAN pipeline are</p><ol><li><strong>Data:</strong> Data is the foundation of any machine learning model, including GANs. For this project, we are using two specific datasets<br>- <strong>Electron-Photon Dataset</strong>: This dataset contains images or data points representing electron-photon interactions.<br>- <strong>Quark-Gluon Dataset</strong>: Similar to the Electron-Photon dataset, this dataset contains images or data points representing quark-gluon interactions.<br>These were explained in detail by one of the previous contributors <a href="https://salcc.github.io/blog/gsoc23">Marçal Comajoan Cara</a>, check out their blog for more details about the datasets used.</li><li><strong>Loss functions</strong>: The performance and training dynamics of GANs are greatly influenced by the selection of loss function. We experimented with the following loss functions, we will explore more about them in later sections<br>- <strong>Wasserstein GAN Loss</strong>: This loss function stabilizes GAN training by providing a smoother gradient flow. It calculates the difference between the distribution of real and generated data, which encourages the generator to create more realistic images.<br>- <strong>Total Variation</strong>: This loss function promotes smoother images by penalizing significant differences between neighboring pixels. <br>- <strong>Perceptual Loss</strong>: Perceptual loss employs pre-trained neural networks to compare the similarity of real and generated images in a feature space, rather than pixel-wise.</li><li><strong>Network Evaluation: </strong>Understanding a GAN’s effectiveness requires evaluating its performance. We use the following metrics for network evaluation:<br>- <strong>Cross Entropy</strong>: This metric measures the discriminator’s ability to distinguish between real and fake images. It will help to determining how effectively the generator fools the discriminator.<br>- <strong>Fréchet Inception Distance (FID)</strong>: FID score measures the distance between the distributions of real and generated data. It is a robust metric for evaluating the quality and diversity of generated images. A lower FID score indicates better performance. This was suggested by one of the mentors (<a href="https://www.linkedin.com/in/gopald27/">Gopal Dahale</a>) and proved to be very effective.</li><li><strong>Gradient (Optimizers): </strong>An optimizer calculates gradients, updates parameters and also controls hyperparameters like learning rate. We experimented with:<br>- <strong>RMSprop Optimizer</strong>: RMSprop adjusts the learning rate for each parameter based on the average of recent gradients, helping to stabilize training<br>- <strong>Adam Optimizer</strong>: Adam combines the benefits of RMSprop and momentum, often leading to faster convergence and more stable training dynamics.</li></ol><p>Previous contributors working on the same project have already worked on classical GANs like <a href="https://www.linkedin.com/in/amey-bhatuse-873189227/">Amey Bhatuse</a>, you can look at their work <a href="https://github.com/ML4SCI/QMLHEP/blob/main/Quantum_GAN_for_HEP_Amey_Bhatuse/Classical_GANS/ClassicalGAN_jet_mass_dataset_convolutional.ipynb">here</a>. Though GANs sound intuitive to implement they come with major issues like <a href="https://medium.com/@miraytopal/what-is-mode-collapse-in-gans-d3428a7bd9b8">mode collapse</a>, <a href="https://learning.quantum.ibm.com/course/variational-algorithm-design/optimization-loops">Barren plateaus</a> and vanishing gradients, apart from the ones that are common to neural networks like overfitting.</p><p>This year, we wanted to test the impact loss function has over training GANs. It’s obvious that every other part of the pipeline would remain same. Log loss, familiar to almost everyone who learned about neural networks would straight away lead to mode collapse. To brief what mode collapse is, it’s when the generator is not able to use a good enough distribution to produce samples that are unique. For jets, mode collapse would typically look something like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*n_Et_hPapfaiF4obyeFKvQ.png" /><figcaption>Mode collapse output</figcaption></figure><p>Can you notice how similar almost every output looks. So, after a lot of trial and errors, the following pipeline seems to work well:</p><p><strong>Generator Architecture:</strong></p><pre>class Generator(nn.Module):<br>    def __init__(self, latent_dim):<br>        super(Generator, self).__init__()<br>        self.latent_dim = latent_dim<br><br>        self.model = nn.Sequential(<br>            nn.ConvTranspose2d(latent_dim, 256, 4, 1, 0, bias=False),<br>            nn.BatchNorm2d(256),<br>            nn.ReLU(True),<br>            nn.Dropout(0.3),<br>            nn.ConvTranspose2d(256, 128, 4, 2, 1, bias=False),<br>            nn.BatchNorm2d(128),<br>            nn.ReLU(True),<br>            nn.Dropout(0.3),<br>            nn.ConvTranspose2d(128, 64, 4, 2, 1, bias=False),<br>            nn.BatchNorm2d(64),<br>            nn.ReLU(True),<br>            nn.Dropout(0.3),<br>            nn.ConvTranspose2d(64, 1, 3, 1, 1, bias=False),<br>            nn.Tanh()<br>        )<br><br>    def forward(self, z):<br>        return self.model(z)</pre><p><strong>Discriminator Architecture:</strong></p><pre>class Discriminator(nn.Module):<br>    def __init__(self):<br>        super(Discriminator, self).__init__()<br><br>        self.model = nn.Sequential(<br>            spectral_norm(nn.Conv2d(1, 64, 4, 2, 1, bias=False)),<br>            nn.LeakyReLU(0.2, inplace=True),<br>            nn.Dropout(0.3),<br>            spectral_norm(nn.Conv2d(64, 128, 4, 2, 1, bias=False)),<br>            nn.LeakyReLU(0.2, inplace=True),<br>            nn.Dropout(0.3),<br>            nn.Flatten(),<br>            spectral_norm(nn.Linear(128*4*4, 1, bias=False))<br>        )<br><br>    def forward(self, x):<br>        return self.model(x)</pre><p><strong>Network evaluation:</strong> We use FID scores, it works by passing both the real and generated images through a pre-trained Inception network (usually Inception-v3). This network extracts feature representations from images, typically from the layer before the output layer. These are high-dimensional vectors that capture important information about the images.</p><p>The FID is computed as the Fréchet distance between the two multivariate Gaussian distributions defined by the means and covariances of the real and generated images. Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*A_bOhukfe5payRxD2R1viQ.png" /></figure><pre>def calculate_fid(real_images, fake_images, batch_size=128):<br>    inception_model = models.inception_v3(pretrained=True, transform_input=False).cuda()<br>    inception_model.eval()<br><br>    def get_features(images):<br>        features = []<br>        for i in range(0, len(images), batch_size):<br>            batch = images[i:i+batch_size].cuda()<br>            batch = F.interpolate(batch, size=(299, 299), mode=&#39;bilinear&#39;, align_corners=False)<br>            batch = batch.repeat(1, 3, 1, 1)<br>            with torch.no_grad():<br>                pred = inception_model(batch)<br>            features.append(pred.cpu().numpy())<br>        return np.concatenate(features, axis=0)<br><br>    real_features = get_features(real_images)<br>    fake_features = get_features(fake_images)<br><br>    mu1, sigma1 = real_features.mean(axis=0), np.cov(real_features, rowvar=False)<br>    mu2, sigma2 = fake_features.mean(axis=0), np.cov(fake_features, rowvar=False)<br><br>    if sigma1.ndim == 0:<br>        sigma1 = np.array([[sigma1]])<br>    if sigma2.ndim == 0:<br>        sigma2 = np.array([[sigma2]])<br><br>    ssdiff = np.sum((mu1 - mu2) ** 2.0)<br>    covmean = sqrtm(sigma1.dot(sigma2))<br>    if np.iscomplexobj(covmean):<br>        covmean = covmean.real<br>    fid = ssdiff + np.trace(sigma1 + sigma2 - 2.0 * covmean)<br>    return fid</pre><p>We’ve used RMSprop for loss testing, but later also tested another model by using Adam optimizer.</p><h4>How effective are loss functions?</h4><ol><li><strong>Wasserstein GAN loss: </strong>The Wasserstein GAN takes a different approach than the traditional GAN loss. Instead of using the sigmoid cross-entropy loss, it uses the Wasserstein distance to provide a meaningful measure of how far the generated data distribution deviates from the actual data distribution. This loss function is used with a critic (rather than a discriminator) to approximate the Wasserstein distance.<br>To enforce the Lipschitz constraint, the gradient penalty is added.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W7ESKtJJzBvMsVzHJrt1Ug.png" /><figcaption>Wasserstein GAN loss</figcaption></figure><p><strong>2. Total Variation loss: </strong>Total Variation (TV) loss is used to reduce noise and improve the smoothness of generated images. It penalizes differences between adjacent pixel values. <br> <br>The TV loss minimizes the sum of absolute differences between neighboring pixel values in the generated image. This encourages the image to have areas with smooth intensity transitions, lowering noise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q1Fge21Pbb5oiHauhoiHCA.png" /><figcaption>Total Variation loss</figcaption></figure><p>3. <strong>Perceptual Loss:</strong> Perceptual loss, also known as content loss or feature loss, is the difference between high-level feature representations of real and generated images extracted by a pre-trained network, most commonly a convolutional neural network (CNN) such as VGG. <br> <br>The perceptual loss algorithm compares feature maps obtained from intermediate layers of a pre-trained network to both real and generated images. This aids in capturing perceptually relevant differences that are not adequately captured by pixel-wise losses such as L2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0dKblro32zbKg3RC01dAhg.png" /><figcaption>Perceptual loss</figcaption></figure><p>Here are the results of training, all of them were trained for 30 epochs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xLF5lBtoM3--q80CNvBNUA.gif" /><figcaption>Wasserstein GAN loss</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R3BjzmfziM8ABh8_OdiSZg.gif" /><figcaption>Total variation loss</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yS5TQv5Saf0ZBsIdFng25w.gif" /><figcaption>Perception loss</figcaption></figure><p>We can compare how well each loss function did by seeing the FID scores, lower scores mean they are close to real images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jHKUZEZ97nrk8gOtyjwGIg.png" /></figure><p>These findings suggest that loss functions <strong>do make a significant difference</strong>. Out of our testing, Total Variation Loss appears to work the best, resulting in the lowest FID scores. You can explore the project repository for all the image outputs. You can look at other plots like generator loss and discriminator loss below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*7Y8ERoBS3OdXKWQMc7JafA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*GPG95Nk9JzR_rHjD0Ld26A.png" /></figure><h3>Let&#39;s introduce Quantum</h3><p>We were working with a hybrid model rather than a fully quantum model. A hybrid model means that one of the neural networks runs on a quantum computer while the other runs on a classical one.</p><p>We usually have a Quantum generator and Classical Discriminator, and not the other way around because of a phenomenon called <a href="https://en.wikipedia.org/wiki/No-cloning_theorem">no-cloning theorem</a>, which essentially means that it’s impossible to copy a quantum state without losing information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XjL8SQNuvZBEBBFpjVOQAA.png" /><figcaption>A typical Hybrid QGAN</figcaption></figure><p>Before we understand how this works, it’s important to know what encoding and Ansatz mean.</p><ol><li><strong>Encoding: </strong>Classical data must be encoded into quantum states, for quantum machines to work on. We’ve used Angle Encoding which involves encoding classical data points into the amplitudes of the quantum state through rotation gates.</li><li><strong>PQC: </strong>A parameterized quantum circuit (PQC), also known as a quantum ansatz, is a quantum circuit with gate operations determined by a set of tunable parameters. These parameters are adjusted during training to optimize the quantum circuit’s performance for a specific task.</li></ol><p>You can create a circuit by using Pennylane:</p><pre>n_qubits = 4<br>latent_dim = n_qubits<br>dev = qml.device(&#39;default.qubit&#39;, wires=n_qubits)<br><br>def quantum_circuit(params, data, n_qubits=4):<br>    depth = len(params) // (2 * n_qubits)<br>    for d in range(depth):<br>        for i in range(n_qubits):<br>            qml.RY(data[i], wires=i)<br>            qml.RY(params[d * 2 * n_qubits + i], wires=i)<br>        for i in range(n_qubits):<br>            qml.CNOT(wires=[i, (i + 1) % n_qubits])<br>        for i in range(n_qubits):<br>            qml.RZ(params[d * 2 * n_qubits + n_qubits + i], wires=i)<br>    return [qml.expval(qml.PauliZ(i)) for i in range(n_qubits)]<br><br>qnode = qml.QNode(quantum_circuit, dev)</pre><p>What this code does is:</p><ul><li>The quantum_circuit function defines the structure of the quantum circuit.</li><li>params is an array of parameters used in the rotation gates.</li><li>data is the input data to be encoded into the quantum circuit.</li><li>The circuit consists of RY gates for data and parameter encoding, CNOT gates for entanglement, and RZ gates for additional parameterization.</li><li>The qml.QNode creates a quantum node that can be used to evaluate the circuit on a given quantum device (dev).</li></ul><p>Usually since, the number of physically available qubits are comparatively less than dimensions of the image, we use a classical upscaler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SmulpYCBygP7Gc7dJ6AZ3A.png" /><figcaption>Upscaler for MNIST dataset</figcaption></figure><pre>class QuantumGenerator(nn.Module):<br>    def __init__(self, n_qubits=4, depth=3, output_dim=16*16):<br>        super(QuantumGenerator, self).__init__()<br>        self.n_qubits = n_qubits<br>        self.depth = depth<br>        self.output_dim = output_dim<br>        self.params = nn.Parameter(torch.randn((depth * 2 * n_qubits,), requires_grad=True))<br>        self.fc1 = nn.Linear(n_qubits, 128)<br>        self.fc2 = nn.Linear(128, 256)<br>        self.fc3 = nn.Linear(256, self.output_dim)<br>        self.bn1 = nn.BatchNorm1d(128)<br>        self.bn2 = nn.BatchNorm1d(256)<br><br>    def forward(self, x):<br>        q_out = []<br>        for i in range(x.shape[0]):<br>            data = x[i].detach().cpu().numpy()<br>            result = np.array(qnode(self.params.detach().cpu().numpy(), data))<br>            q_out.append(result)<br>        q_out = torch.tensor(q_out, dtype=torch.float32).to(device)<br>        q_out = F.relu(self.bn1(self.fc1(q_out)))<br>        q_out = F.relu(self.bn2(self.fc2(q_out)))<br>        q_out = torch.tanh(self.fc3(q_out))<br>        return q_out.view(-1, 1, 16, 16)</pre><p>The idea is to use an encoder that takes input data and applies parameterized rotations and entanglements and outputs expectation values of Pauli-Z operators. then use classical fully connected layers with batch normalization to upscale the image (28x28 for MNIST). The quantum circuit is parameterized with trainable parameters to adjust during training which are optimized through classical backpropagation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ayI-TyjKd1s2DpcHJZYtCw.png" /><figcaption>The Generator circuit (CNOT gates add entanglement)</figcaption></figure><h4>So how does this work?</h4><p>It’s always a standard to test any pipeline with MNIST dataset to make sure there is no issues with the models. In our case, making sure that no mode collapse occurs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*_sp7uZGz8Vwag7lNGbWy7Q.gif" /><figcaption>Hybrid QGAN training on MNIST</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*9aSlE40t2-cLLB0LXeH_mw.png" /><figcaption>Final image after training the model</figcaption></figure><p>Looks like a good output, right? not really though the output looks noiseless it’s the loss landscape that is worrisome. Convergence during training is a very important aspect to look at, and this model did not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*Har_wttlJdeC83FlQrRQwg.png" /><figcaption>A messy loss landscape</figcaption></figure><p>On a similar note, the model didn’t perform well on jets images as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*kDIiVZDe6RpHZOCYpioVFA.png" /></figure><p>Remember earlier, we tested the importance of loss function? We put that data to use. Instead of going with random experimentation with the model we started with using Total variation as the loss function.</p><p>and well, these are the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R3BjzmfziM8ABh8_OdiSZg.gif" /><figcaption>Classical GANs (loss: Total variation)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pellH392w3DU07yJdOosQg.gif" /><figcaption>Hybrid QGANs (loss: Total variation)</figcaption></figure><p>Note that gaussian blur was applied to the output of Hybrid QGANs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*7CglpC9tPnLAiOzvyMfP-w.png" /></figure><p>The Hybrid model was trained on much lesser data than the classical models. (1:7), but still performed equivalently to the classical model.</p><h3>Final thoughts and future work</h3><p>If we thoroughly look at Hybrid QGANs, it’s truly doesn’t explore the quantum advantage. A lot of parts are still done by classical computing including upscaling. It would be interesting to see implementing a fully quantum model. That would be where I would spend time to explore.</p><p>I finally thank my mentors Abhay Kamble, Tom Magorsch, Gopal Ramesh Dahale, Rui Zhang for their valuable time and suggestions. A Special mention to Sergei V. Gleyzer, Ph.D., for the way he organizes the program.</p><p>Here is a link to my Code: <a href="https://github.com/ML4SCI/QMLHEP/tree/main/Quantum_GAN_for_HEP_Adithya_Penagonda">Click here</a><br>Link to slides: <a href="https://www.figma.com/proto/iMmkVXKyAnJbFkPxtYhEpi/Gsoc-meeting-slides?node-id=109-2&amp;t=WXEJ2L9zZ7Iyztez-1&amp;scaling=contain&amp;content-scaling=fixed&amp;page-id=0%3A1">Click here</a>.</p><p>You can also look at my proposal at <a href="https://github.com/Userfound404/GSoC-QMLHEP-Tasks/blob/main/GSOC_2024_Proposal.pdf">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bb1fb50faba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Steps to build your own café]]></title>
            <link>https://medium.com/@penadi/steps-to-build-your-own-caf%C3%A9-ea6adb285fce?source=rss-8cc5f069719f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea6adb285fce</guid>
            <category><![CDATA[business]]></category>
            <category><![CDATA[psychology]]></category>
            <dc:creator><![CDATA[Adithya Penagonda]]></dc:creator>
            <pubDate>Thu, 26 Oct 2023 09:01:59 GMT</pubDate>
            <atom:updated>2023-10-26T09:01:59.264Z</atom:updated>
            <content:encoded><![CDATA[<p>Psychology plays an essential role in bringing in and retaining customers for any business.</p><p>Meet TeX, who has graduated with a degree in psychology. He started his new café named “Brewed Illusions”. Let’s get into TeX’s mind and understand his plan to get that money in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*B_fPgmyNMn6W_OZyZdX0qQ.gif" /><figcaption>Brewed Illusions</figcaption></figure><p>Tex: Hi I’m Tex, so I’m going to tell you how I strategically planned everything out.</p><p>Let’s start out with pricing. Coffee would be the most popular seller; I’ve planned three sizes: Petite, which costs $3 for 150mL, Majestic, which costs 4.5$ for 225mL, and Grand, which costs $5 for 300mL. There is no 4$ choice, and this lack of symmetry prompts shoppers to consider value for money. The volume per dollar for Petite and Majestic is 50mL/$ and 60mL/$ for Grand.</p><p>Those that choose Petite would do so anyhow, but when it comes to Majestic, most customers would be prepared to pay an extra 0.5$ to upgrade to Grand, as they obtain 75mL more by doing so. This is known as the <strong>Decoy effect</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*uvH7cD5IPNzcSevnJS8Mmw.gif" /><figcaption>Decoy effect</figcaption></figure><p>When a third, asymmetrically dominant alternative (the decoy) is introduced, customers’ preferences between the two options change. The next best place to have tricky pricing is with snacks. Let’s say we have three items, a blueberry tart for 15$, a brownie for 12.5$ and a pastry for 10$.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*jWrFF6nvRQ9KWyziLDd-Dg.gif" /><figcaption>Anchoring Effect</figcaption></figure><p>The Blueberry tart feels quite pricey, and the pastry for $10 suddenly feels much more affordable. Though the pastry is still pricey, it appears to be a far better buy. This pertains to the <strong>anchoring effect</strong>, in which people make decisions based on the first piece of information they receive and here the tart is the anchor. When this is combined with the <strong>Scarcity principle</strong>, we have a perfect recipe for achieving high perceived value. Having some higher-priced items labelled as “limited stock” or “almost sold out” would immediately inspire shoppers to create a higher value when supplies are limited.</p><p>Including a most popular board would highlight specific things; this would be a wonderful opportunity to promote a specific item on the menu with better margins. If 5 out of 100 customers choose an expensive drink, but it is promoted as “Most Loved!” then minority opinion is given disproportionate weight, resulting to more of the following 100 customers choosing it. This is called <strong>Availability Heuristics</strong>, People overestimate the significance of information they can recall quickly, which is usually due to recent exposure.</p><p>Another clever technique to persuade consumers to spend, particularly those who are undecided, is to implement a sampling process, but not simply by providing free samples. Making little samples of 40 or 50mL for $1 and then providing a discount on the original drink if they enjoy it. Most consumers who spend that first dollar are more likely to get a drink at a lower price, such as a Grand for $4 instead of $5. This is known as the <strong>sunk cost fallacy</strong>, in which people make judgements based on cumulative prior investment (“sunk cost”) rather than the decision’s present day worth.</p><p>Retention of customers is just as crucial as gaining clients. Having a loyalty programme is the greatest way to keep customers coming back, so I’ve established a monthly membership card that is already stamped the first time they order, and instead of just having one final prize, I’ve added a mid-progress award to make it more involved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*X9JC3-dkSbB6t-JAtUqTug.gif" /><figcaption>membership card</figcaption></figure><p>If, on average, only 2 out of 10 people complete a loyalty card, providing a starting stamp might increase that rate to 4 out of 10, essentially doubling loyalty programme returns. This is called <strong>Endowment effect</strong>, where people tend to value things more once they own them.</p><p>The final crucial step would be to instill trust and brand recognition in the minds of customers. Having a more involved staff makes a difference in this situation. Giving a customer positive reinforcement validates their choices and increases the likelihood of them purchasing it again. Including phrases such as “Excellent choice” or “One of the best we have” provides the buyer greater control over their decision.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*eaHF1Qh6pb-M-BSmG5UCSg.gif" /><figcaption>confirmation bias</figcaption></figure><p>This is known as <strong>confirmation bias</strong>; offering a boost to a customer’s choice enhances the likelihood of that item being purchased again. With positive reinforcement, 6 out of 10 repeat customers ordering the same item may increase to 7 or 8 out of 10. This is only enhanced by the addition of a few prizes or publications, even if they are framed articles or fabricated awards, which would raise overall sales by instilling trust. This is known as the <strong>authority principle</strong>, in which people tend to obey those seen to be in positions of authority.</p><p>As you can see, TeX used these strategies to ensure that, while customers thought they were making independent decisions, their decisions were discreetly affected at every point. That’s how much we’re influenced by everything from shopping centres to restaurants.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea6adb285fce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quantum computers can break the internet sooner than you think]]></title>
            <link>https://medium.com/@penadi/quantum-computers-can-break-the-internet-sooner-than-you-think-3dfe699dbe30?source=rss-8cc5f069719f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dfe699dbe30</guid>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[encryption]]></category>
            <dc:creator><![CDATA[Adithya Penagonda]]></dc:creator>
            <pubDate>Fri, 08 Sep 2023 15:56:17 GMT</pubDate>
            <atom:updated>2023-09-18T14:05:46.384Z</atom:updated>
            <content:encoded><![CDATA[<p>All our digital systems that we use consist of transistors. You can consider them as tiny switches that either sends electrons or stops them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*ddzZSWrsvgT1m6w6Ciqepw.gif" /><figcaption>A graphical representation of transistor as a switch. credit — Kurzgesagt</figcaption></figure><p>In recent times, each CPU chip holds billions of transistors and all in size of an Apple watch. The sizes of each transistor differ from 7 nm to the cutting edge 5 nm(nanometers).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/0*YhhEsKy2WPg3PWHb.png" /><figcaption>Apple’s new silicon using 5nm architecture. credits — Apple Inc.</figcaption></figure><p>The sheer size of the transistor is unimaginable, each transistor is thinner than a strand of hair. This transition took more than two decades, starting from over 1000 nm to 5 nm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*eINEqLl9dYijR7pQ" /><figcaption>Intel’s silicon transistor size vs year of release. Credits — <a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0256245">link</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*fwoeXAIpyvBZtZMuQYhgxw.gif" /><figcaption>Credits — Kurzgesagt</figcaption></figure><p>So if we could decrease the size of the transistors annually, why are we still stuck at 5 nm from past 5 years?</p><p>There is a physical limit[<a href="https://www.researchgate.net/publication/231030591_Physical_limits_of_silicon_transistors_and_circuits#:~:text=The%20silicon%20used%20in%20transistors,of%20quantum%20effects.%20...">1</a>] on how small we can make our transistors, going down 3 or 2 nm isn’t viable as quantum tunneling kicks in.</p><h4>Quantum Tunneling</h4><p>It’s a phenomenon where the electrons typically teleport onto the other side of the transistor wall. Scientifically, Quantum tunneling occurs because there exists a nontrivial solution to the <a href="https://brilliant.org/wiki/schrodinger-equation/">Schrödinger equation</a> in a classically forbidden region, which corresponds to the exponential decay of the magnitude of the <a href="https://brilliant.org/wiki/wavefunctions-and-measurement/">wavefunction</a>.[2]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*fo7VctNcqMAgQ_tb-tJu-A.gif" /><figcaption>A cartoonish representation of quantum tunneling. credits — Kurzgesagt</figcaption></figure><p>What this implies is that even though a transistor of size 4 nm might exist, it loses it’s core fundamental application of stopping electrons from flowing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*t6udRJbTZRio7Qq0.gif" /><figcaption><em>Tunneling of an electron wave function through a potential barrier. credits — Brilliant.org</em></figcaption></figure><p>Scientists came up with a way to take advantage of the quantum properties of materials to come up with quantum computers.</p><p>They are fundamentally very different from classical computers, they’re just not faster than a supercomputer in every case. <em>Playing Valorant on a quantum computer will not get you 1000+ FPS.</em></p><p>The problems they solve are different from what a classical computer is good at. A 100 by 100 digit multiplication is still good on a classical computer.</p><h4>Quantum Computing</h4><p>A ‘bit’ is the most basic unit of information in computing and digital communications. It can be either a 0(low) or 1(high).</p><p>In a quantum computer, we use ‘qubits’, instead of bits. where each qubit can hold a different value of 0 and 1 at once. This is known as <strong>superposition</strong>. Meaning, a qubit can have a 0.54 probability of being 1 and 0.46 of 0. This feature introduces a new dimension of complexity.</p><p>The superposition doesn’t last in it’s happy space for long. Depending on it’s probabilities, the state collapses to either 0 or 1 the moment we measure it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*4ERql28cfij2OOzoVOsP3g.gif" /><figcaption>A graphical representation of superposition and collapse when measured. credits — Kurzgesagt</figcaption></figure><p>The fact that n qubits can store all the numbers from 0 to 2^n, while n bits can store one number between 0 and 2^n. This is where quantum computers shine. A mere 300 qubits could hold around 2300 binary strings each of size 300 bits.</p><p>A qubit takes up less memory space than a regular bit, but this is more than just space — it provides a computational space.</p><h4>Quantum Entanglement</h4><p>Quantum entanglement is this amazing, counterintuitive phenomenon which explains how two sub-atomic particles are connected or correlated to each other even when they are light years away.</p><p>This was recently visualized[3], and it looks like yin-yang.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ypPhSHCuKWxiHBfb.jpg" /><figcaption>Quantum entangled visualized</figcaption></figure><p>But what this typically means for our quantum computers is that we can measure both of our qubit states by just looking at one of them, when they’re entangled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*XPCB6CX5qpanqwmhLzfdtw.gif" /><figcaption>Quantum entanglement representation Credits — Kurzgesagt</figcaption></figure><p>Now that we know about quantum properties that enable us to build quantum computers, are you wondering how would they look?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FrsJhuxVNz3VipcQ.jpg" /><figcaption>Quantum computer Credits — MIT Technology review</figcaption></figure><p>The long chandelier is a cryogenic refrigerator, which cools qubits to 10mK(milli Kelvin), that’s colder than space!</p><p>We’re not here to discuss on how this looks or what parts does it has. Thats a topic for another blog.</p><h4>Internet Encryption(RSA)</h4><p>Most of the internet encryption works on the fact that it’s really hard to factorize two large numbers.</p><p>It is very easy for a computer to multiply two large numbers, but given any number — say 732443. It is difficult to determine all of its prime factors; the number I used as an example is simpler, but picture a number with 2048 digits — even a supercomputer may take years to factorise it!</p><p>Let’s take an analogy to understand this easily, in these 3 steps.</p><ol><li><strong>Creating the lock(key generation):<br></strong>Assume you have a rare padlock (the public key). When you close this padlock, it can only be opened with a specifically crafted key (the private key). You may offer this padlock to anyone without worry since, while they can use it to lock items, they can’t open it once they’ve locked it.<br>Consider this padlock to have a unique feature: anyone can see how it’s built (the visible mechanics, similar to the large product of two prime numbers), but recreating the specific key that opens it (factorising those numbers) is extremely difficult unless you know a secret about the original materials used to make the padlock.</li><li><strong>Locking the Treasure box(Encryption):<br></strong>Your friend has a valuable message (or treasure) they want to securely convey to you. They use your public padlock to secure a box containing the message. The message is now safe. Unless they have the unique key, no one can read the message.</li><li><strong>Unlocking the Treasure box(Decryption):<br></strong>When you receive the locked box, you use your specially designed key, which is the only key in the world capable of opening that padlock, and access the message. This action is like using the private key to decrypt a message encrypted with the public key.</li></ol><p>The fundamental idea is that while multiplying two prime numbers together is simple (even for computers), determining which two prime numbers were multiplied to make a huge number is extremely difficult, especially as these numbers grow larger and larger. In our instance, giving someone the locked box (encrypted communication) does not provide them with an easy means to unlock (decrypt) it without the special key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*rlou0OPjs-JQglxTH3rMcw.gif" /><figcaption>RSA Algorithm</figcaption></figure><h4>Shor’s Algorithm</h4><p>Enter Shor’s algorithm, it can factorize large numbers in polynomial time making it exponentially faster than any known classical algorithm.</p><p>Instead of explicitly attempting to factor numbers, Shor’s technique logically uses quantum mechanics’ principles to identify the period of a certain function connected to the number to be factored. Once this period is known, the factorization is relatively simple to derive.</p><p>Given any period <em>r</em>, our two factors would be (<em>a^r</em>/2 −1) and (<em>a^r</em>/2 +1). And by making more probable guesses we can identity our two numbers.</p><p>Let’s go through the algorithm by factoring 15. Though 15 is a simple number to factor traditionally, it serves as a manageable example for our needs.</p><p><strong>Step 1: Choose a Random Number</strong><br>Pick a number <em>a</em> randomly such that 1&lt;<em>a</em>&lt;15. For our purposes, let’s choose <em>a</em>=7.</p><p><strong>Step 2: Check if <em>a</em> shares a factor with <em>N</em></strong><br>Compute the greatest common divisor (GCD) of 7 and 15. If GCD is neither 1 nor 15, we’ve found a non-trivial factor. In this case, GCD(7,15) = 1, so we continue.</p><p><strong>Step 3: Find the Period of the Function</strong><br>We want to find the smallest <em>r</em> such that:<br><em>a^r </em>mod 15=1<br>For <em>a</em>=7, the sequence is:<br>7^1 mod 15 = 7,<br>7^2 mod 15 = 49 mod 15 = 4,<br>7^3 mod 15 = 343 mod 15 = 13,<br>7^4 mod 15 = 1</p><p>Here, the period <em>r </em>= 4.</p><p>The quantum part of Shor’s algorithm is mainly used for efficiently finding this period <em>r</em>.</p><p><strong>Step 4: Calculate Factors</strong><br>Now, we have the period <em>r</em>=4, which is even. We compute:<br>(<em>a^r</em>/2 −1) and (<em>a^r</em>/2 +1).<br>So, for our example, (7^4/2 −1) = 48 and (7^4/2+ 1) = 50.<br>Finding the GCD of 48 and 15 gives us 3, and finding the GCD of 50 and 15 gives us 5. So, 15 can be factored into 3 and 5.</p><p>The quantum advantage is this ability of a quantum system to exist in a superposition of states.</p><p>Shor’s algorithm’s actual beauty resides in its brilliant use of quantum physics to change a problem that is difficult for classical computers to solve (i.e., identifying the period) into a problem that quantum computers can solve effectively.</p><p>Shor’s algorithm requires at least twice the number of qubits as the number of digits in the number being factored. For example, if the number being factored is a 1024-bit number, then it would require at least 2048 qubits.</p><p>Most estimates say that a quantum computer will need around 1,000 physical qubits to represent just one logical qubit. However, in practice, you’ll need a lot more for error correction.</p><p>Shor’s algorithm can break asymmetric encryption with twice as many qubits as the key size. For example, breaking AES-128 encryption should require a quantum computer with around 2,953 logical qubits, while breaking AES-256 would need around 6,681 qubits.</p><p>Looking at IBM’s roadmap[4]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6i3vJCpK-fpP3BmX.png" /><figcaption>IBM quantum roadmap</figcaption></figure><p>We would almost have 4000+ working qubits, so just in the next decade we can look at breaking encryption.</p><h4>References</h4><p>[1] — <strong>Tunable electronic properties of germanene and two-dimensional group-III phosphides heterobilayers(physical limits of silicon transistors) — </strong><a href="https://www.researchgate.net/publication/231030591_Physical_limits_of_silicon_transistors_and_circuits#:~:text=The%20silicon%20used%20in%20transistors,of%20quantum%20effects.%20...">link</a><br>[2] — <strong>Quantum tunneling</strong> — <a href="https://brilliant.org/wiki/quantum-tunneling/">link</a><br>[3] —<strong> Entanglement visualization</strong> —<a href="https://forum.lowyat.net/topic/5405133">link</a><br>[4] — <strong>IBM Quantum</strong> —<a href="https://www.ibm.com/quantum/roadmap">link</a></p><h4>Further Resources</h4><p>Quantum Computers Explained — Limits of Human Technology — <strong>Kurzgesagt(</strong><a href="https://www.youtube.com/watch?v=JhHMJCUmq28"><strong>link</strong></a><strong>)<br></strong>How Quantum Computers Break Encryption — <strong>MinutePhysics(</strong><a href="https://www.youtube.com/watch?v=lvTqbM5Dq4Q"><strong>link</strong></a><strong>)<br></strong>What is quantum computing? —<strong> IBM(</strong><a href="https://www.ibm.com/topics/quantum-computing"><strong>link</strong></a><strong>)<br></strong>RSA Algorithm — <strong>Brilliant(</strong><a href="https://brilliant.org/wiki/rsa-encryption/"><strong>link</strong></a><strong>)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dfe699dbe30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How ChatGPT took chatbots to a new Realm]]></title>
            <link>https://blog.gopenai.com/how-chatgpt-took-chatbots-to-a-new-realm-28e0c7459502?source=rss-8cc5f069719f------2</link>
            <guid isPermaLink="false">https://medium.com/p/28e0c7459502</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[langchain]]></category>
            <dc:creator><![CDATA[Adithya Penagonda]]></dc:creator>
            <pubDate>Mon, 12 Jun 2023 13:58:40 GMT</pubDate>
            <atom:updated>2023-06-16T14:55:43.671Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s no surprise that ChatGPT has taken the world by storm. Although it was the first mainstream language model to support human-like conversations, it was not the first. Google’s LaMDA, which was announced at Google I/O 2021, was integrated into Google Assistant (dubbed Google Duplex) and could take calls on your behalf. Take a look at the video below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJvbHu_bVa_g%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJvbHu_bVa_g&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJvbHu_bVa_g%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/89d8574fbb65596caf35533b23fc1ea1/href">https://medium.com/media/89d8574fbb65596caf35533b23fc1ea1/href</a></iframe><p>They never made it public because of the potential ethical implications, as well as the controversy that it became sentient. You can check out their original blog over <a href="https://blog.google/technology/ai/lamda/">here</a>. Fast forward a year we have ChatGPT, which stands for generative pretrained transformers.</p><p>Most readers are likely already aware of it, if not using it. We’re not here to discuss how ChatGPT changed the world, but rather what it means for developers.</p><p>At the time of writing, almost every major corporation had chosen to provide some form of chatbot interaction. But how did they limit the data available to the chatbot so that it only showed the content they wanted to show?</p><p>before answering this question, let’s understand a few concepts</p><h4>Vectorization</h4><p>Since computers aren’t great at understanding textual data, we try to convert it into some numerical vectors, vectors typically represent continues numerical values. This is crucial for machine learning models to understand the semantic meaning. The model will never know the meaning of the word given either new or old. It always compares the vectors that a word or sentence has to understand context.</p><p>There are various ways vectorizing works like Bag-of Words, Term Frequency-Inverse Document Frequency and word embeddings. We’re more interested in word embeddings.</p><p>Word embedding represent words as dense, low-dimensional vectors in a continues vector space. these vectors are formed by capturing semantic and syntactic relationship. i.e. by capturing the meaning and order of words. The following image is how each data point is captured and arranged based on semantic meaning. learn more about it <a href="https://www.geeksforgeeks.org/word-embeddings-in-nlp/">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*-XwdriibC92Z5xpD.png" /><figcaption>image by <a href="https://medium.com/@george.pearse?source=post_page-----65cb6cc70b3f--------------------------------">George Pearse</a>.</figcaption></figure><p>This seems too complex to understand, let’s create a simple analogy. For simplicity assume a 3D space. here is where our vectors should lie.</p><p>Let’s say we have a vector which holds the information about my name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*brZMVsd789_IDSU8uo18zQ.png" /><figcaption>A text represented as vector</figcaption></figure><p>The vicinity of the vector represents the similarity or the correlation of the vectors that might occupy that space. Let’s say we make two search queries.</p><ol><li>Where do you live?</li><li>What is your name?</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*32FdMhx-LsLVFuGKw0DtJg.png" /><figcaption>all the vectors represented in the space.</figcaption></figure><p>As we said the vicinity of our original vector matters the most, so we would choose the answer based on that right? but when there are more than 1 vector, how do we measure the vicinity?</p><p>Remember Euclidean distance from your algebra class, the distance formula. It can find distance between any two points in the space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*Z7wCyWOgWacZ4F0mB1Vs7w.png" /><figcaption>Euclidean distance</figcaption></figure><p>However, because the length of the vector varies, raw distance is not a good measurement metric in general. We use cosine similarity, which is basically the angle between any two vectors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*pZ5qVelLuMxIBlQyBN1XSQ.png" /><figcaption>cosine Similarity</figcaption></figure><p>The smaller the angle, the more similar the meaning is to the original text. This is how Vector Databases operate. This straightforward concept underpins large databases that employ vector-based indexing. Pinecone and other powerful organisations provide these services.</p><h4>Langchain</h4><p>This open-source framework has been making headlines recently, and it’s a great tool. It’s core functionality is to help developers build Large Language models (LLMs).</p><p>It combines multiple APIs, like openAI, Hugging Face which helps in developing multimodal solutions. the main advantage of this framework is Agents, Templates and Chaining.</p><p>Agents — An agent is a component that has access to tools and can decide which tool to use based on the user’s input. It can do complete actions for you based on the prompt. Agents help models to access the data on the internet like Google and Wikipedia.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pE4eRmdWBMf5DtPA_1Frpw.png" /><figcaption>how agents work</figcaption></figure><p>Templates — A template exploits the power of prompt engineering. Most model can take a role, i.e. it tries to mimic that role and give output according to it. This was one of the prompt given when I wanted to learn about data science.</p><blockquote>you are a highly knowledgeable data scientist and worked in Google and other top FAANG companies. You also have worked with many deep learning models, especially audio and emotion analysis. after working in the field for more than 40 years, you wish to retire. and now teach to young adults like me. You teach a complete course starting from basics and ending it with 2 amazing projects with complete details step by step. The basics should involve everything I need as a Engineer. You are a great teacher as well and you change your teaching style by asking for constant feedback. You can take as much long as it takes to make it your responsibility to make sure I understand everything. You are great at storytelling, so go ahead to add some personal experiences to make this journey much more fun.</blockquote><p>you can read the complete chat over <a href="https://chat.openai.com/share/d19ef566-9aa3-4df9-a274-1fc75c81a190">here</a>. What templates do is they allow for a pre-made prompt with blank spaces for the user to fill in.</p><p>Chaining — Chaining helps with creating a flow of data that moves through various models. This is a exceptionally great because it let’s you create high level applications using multiple models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*j6_KV5FNQqDzMcIcyspicg.png" /><figcaption>chaining</figcaption></figure><p>There are a few more features that make Langchain one of the best platform to built applications.</p><h4>Fine-Tuning</h4><p>A pre-trained model can be modified using the fine-tuning technique in machine learning and neural network models to execute a particular task or dataset. After being first trained on a larger, general-purpose dataset, a model is fine-tuned by undergoing additional training on a smaller, task-specific dataset. This helps in reduced training time, improved performance, mitigation of overfitting.</p><p>The major benefit is that a fine-tuned model is restricted to the data we provide, which makes it ideal for many use cases. As we discussed above, this is how many companies or organizations restrict their chatbot to specific data.</p><h4>Building a fine-tuned chatbot</h4><p>Leveraging all the power we have with large language models we can build custom chatbots by training it on out own data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aj5WPM74G094rdkWSkZ8QQ.png" /><figcaption>ref- langchain</figcaption></figure><p>The image above show exactly how our application can be created. We divide our data into chunks and utilise text embedding to store distinct vectors in a database. Now, whenever a user enters a query, the text embedding is used to retrieve the closest datapoint. Our LLM specialises in comprehending context, including earlier conversations. The model then returns the relevant database answer.</p><p>Remember we’re not exactly changing the architecture of the model for fine-tuning but are leveraging the contextual understanding of the LLM.</p><p>I’ve created a similar chatbot for my college. It was trained on very limited data though, but it works wonders.</p><p>you can test it <a href="https://askvnrvjiet.streamlit.app/">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*bSW-BL_NzC3pYvhbXaWlhg.png" /><figcaption>chatbot for VNRVJIET</figcaption></figure><p>you can look at the code over <a href="https://github.com/Userfound404/VNRVJIET-Chatbot">here</a>. Thanks a ton for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28e0c7459502" width="1" height="1" alt=""><hr><p><a href="https://blog.gopenai.com/how-chatgpt-took-chatbots-to-a-new-realm-28e0c7459502">How ChatGPT took chatbots to a new Realm</a> was originally published in <a href="https://blog.gopenai.com/">GoPenAI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Samsung’s Lunar Lie]]></title>
            <link>https://medium.com/@penadi/samsungs-lunar-lie-dcb9e5af687c?source=rss-8cc5f069719f------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcb9e5af687c</guid>
            <category><![CDATA[samsung-galaxy]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Adithya Penagonda]]></dc:creator>
            <pubDate>Wed, 15 Mar 2023 17:26:39 GMT</pubDate>
            <atom:updated>2023-03-15T17:51:29.710Z</atom:updated>
            <content:encoded><![CDATA[<p>The extreme-zoom moon shot on Samsung’s new Galaxy S23 ultra was faked, according to a Reddit user named <a href="https://www.reddit.com/user/ibreakphotos">ibreakphotos</a>.</p><p>This generated a lot of attention.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vUwqSu-3fqTIME_sVELaIw.png" /><figcaption>src — The verge</figcaption></figure><h4>But how did he find out?</h4><p>The claim was that an AI could identify a similar photo to that of the moon and then process it with pre-trained images of the moon. To test this he took a stock image of the moon, reduced the quality to 170 x 170 pixels and applied gaussian blur to it.</p><p>This means that it’s not recoverable as it is digitally blurred and there is very less information in the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/217/1*vY1fG_TxSDGYfq4wsgCc4g.jpeg" /><figcaption>Image of the blurred moon with a superimposed gray square on it, and an identical gray square outside of it — <a href="https://imgur.com/PYV6pva">https://imgur.com/PYV6pva</a></figcaption></figure><p>He then took the photo of the blurred image with his Galaxy S23 Ultra on a monitor and this was the result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hEvxIlL4NGU6pwWJSzTHnA.jpeg" /><figcaption>The same blurred image taken on a moniter by the S23 ultra src — <a href="https://imgur.com/bXJOZgI">https://imgur.com/bXJOZgI</a></figcaption></figure><p>It’s introducing information that wasn’t there. It’s not deconvolution, sharpening, or even “multiple frames or exposures,” nor is it anything like super resolution. It’s generating data.</p><p>Here is a comparison of the digitally blurred image and captured image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HtEq8qr3dHecOiuRBFz-4A.jpeg" /><figcaption>src — <a href="https://imgur.com/ULVX933">https://imgur.com/ULVX933</a></figcaption></figure><p>Therefore, it was evident that some processing was taking place and that the optics were not the ones working their magic. The user later discovered that a texture of the moon was being added to images that resembled the moon primarily thanks to Samsung’s scene optimizer.</p><p>Let’s put ethics aside and concentrate on how this was accomplished.<br>Samsung has been working on this for a while, and a Korean blog detailed their process for doing so.</p><h4>How was this achieved?</h4><p>In order to help users take better photos, Samsung has incorporated AI technology into its Galaxy S10 and all newer models. AI is used by the Scene Optimizer feature to identify the subject being photographed and deliver the best results. From the Galaxy S21, the AI can even identify the moon as the target and use deep learning-based technology and multi-frame synthesis to enhance details and create a clearer image.</p><p>In their blog, Samsung makes it clear that this was just a feature and that it could be disabled by the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*5zRf4kgOnx57e6l6XeRp3A.png" /><figcaption>src — Samsung’s blog(Korea)</figcaption></figure><p>Samsung was attempting to enhance the moon image by synthesising more than 10 images under conditions of high magnification, which allowed it to take low resolution images and turn them into high resolution images. They were calling it <strong>Super Resolution Technology</strong>.</p><p>While they could achieve better results with just the Super Resolution technology, they paired it with a deep learning model to improve the quality drastically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*8zmYDUZVDfUHt8NC6Q7-oQ.png" /><figcaption>src — camcyclopedia(Samsung’s blog) and translated to English by Google lens</figcaption></figure><p>As you can see optimal shooting was making it much better. The model they were using was a Convolutional neural network, the best for images.</p><p>Samsung’s moon recognition engine uses an AI deep learning model that was created by learning various moon shapes from full moon to crescent moon based on real-life images that people actually see with their eyes on Earth. The engine can detect the presence of the moon in an image and create a square box around it. The AI model has been trained to detect lunar regions even when presented with lunar images that were not used for learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*p_OCptM-hH3kGqg-9lVqpw.png" /><figcaption>model description src — Samsung’s Blog</figcaption></figure><p>If the moon was covered by clouds or other objects, non-lunar objects it failed to detect it.</p><p>Moon photography is only possible at zoom levels of 25x or more because it is difficult to detect small moons in AI moon photography.</p><p>Once the moon has been identified using a high magnification zoom, the screen brightness is regulated to dim so that the moon can be seen clearly on the camera screen, and the ideal brightness is maintained.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*LENHEWWIC-HKWpz4D28uUQ.png" /><figcaption>src — camcyclopedia(Samsung’s blog) and translated to English by Google lens</figcaption></figure><p>The focus is changed to infinity when the moon is found to keep it in focus.</p><h4>How Does the phone detect the moon?</h4><p>Before applying the moon detail improvement engine with AI technology, they first run the <strong>moon recognizer</strong> to reconfirm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*9PSlxjDRl_yA5TMF4x_eiA.png" /><figcaption>src — camcyclopedia(Samsung’s blog) and translated to English by Google lens</figcaption></figure><p>The image is fed into a convolution neural network, which produces a binary output indicating whether or not it is a moon.</p><p>If the user is attempting to capture a moon, several pictures are taken and combined into a clear, noise-free image of the moon using multi-frame processing.</p><p>Due to the vast distance from the moon and the lack of light, the moon shooting environment has physical restrictions, making the high-magnification actual image output from the sensor insufficient to provide the best quality experience even after composite numerous shots.</p><p>To get around this, the Galaxy Camera uses a deep learning-based AI detail improvement engine (<strong>Detail Enhancement technology</strong>) at the very end of the process to efficiently reduce noise and optimize the details of the moon, resulting in a complete and vivid image of the moon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*Ufm_D5szWcmNafzk2CuYXw.png" /><figcaption>src — camcyclopedia(Samsung’s blog) and translated to English by Google lens</figcaption></figure><p>the model takes in low resolution image of the moon, then it uses Detail enhancement engine (Convolutional Neural Network) to produce a improved image which is then compared with a reference image from learning data and might update accordingly.</p><p>And VOILA there is your AI enhanced moon image.</p><p>To conclude image processing(Computational photography) is being used by every other smartphone, It’s not always the lens that gets the magic. The reason why Samsung is facing this situation is due their deceptive marketing. While some people mistakenly believe that Samsung can add a texture of the moon to your moon photos using ML, this is not a feature of your camera or lens to be specific.</p><p>Therefore, there is no sharpening or augmentation of detail from additional frames in this experiment because the level of detail in each picture is the same. The real issue was with it’s promotion.</p><p>Samsung responded to all of this chaos by stating that it’s not just a overlay.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7nL4eVnpoQTHaRG4V_lb-A.png" /><figcaption>src — The Indian Express</figcaption></figure><p>Thank you for reading!</p><p>here are the sources:</p><ol><li>Samsung’s official Korean blog — <a href="https://r1.community.samsung.com/t5/camcyclopedia/%EB%8B%AC-%EC%B4%AC%EC%98%81/ba-p/19202094">here</a></li><li>Official reddit post —<a href="https://www.reddit.com/r/GalaxyS23Ultra/comments/11nsbw4/samsung_moon_shots_are_fake_and_here_is_the_proof/"> here</a></li><li>Indian Express article —<a href="https://indianexpress.com/article/technology/tech-news-technology/samsung-fake-moon-photo-8499530/#:~:text=In%20the%20viral%20post%2C%20Reddit,blur%20to%20remove%20all%20details."> here</a></li><li>The Verge article — <a href="https://www.theverge.com/2023/3/14/23640006/samsung-s23-moon-photo-controversy-space-zoom-computational-photography">here</a></li><li>MrWhoseTheBoss(YouTube) — <a href="https://www.youtube.com/watch?v=EKYJ-gwGLXQ">here</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcb9e5af687c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What if money grew on trees?]]></title>
            <link>https://medium.com/@penadi/what-if-money-grew-on-trees-23c66bd1add?source=rss-8cc5f069719f------2</link>
            <guid isPermaLink="false">https://medium.com/p/23c66bd1add</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[biology]]></category>
            <category><![CDATA[fantasy]]></category>
            <dc:creator><![CDATA[Adithya Penagonda]]></dc:creator>
            <pubDate>Sun, 15 Jan 2023 04:49:29 GMT</pubDate>
            <atom:updated>2023-01-16T08:20:00.997Z</atom:updated>
            <content:encoded><![CDATA[<p>Well It’s complicated.</p><p>Most notes in various currencies are made up of paper and either cotton or linen is added. Leaves on the other hand is made of cellulose, proteins and complex carbohydrates that provide structural integrity. They also have various lipids, minerals and pigments that help in photosynthesis i.e. conversion of CO₂ to O₂.</p><h4>It is physically impossible for leaves to be converted into the same materials as notes, but what would happen if all of the leaves were suddenly replaced by money?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LYoxdkqTCNCFExXgjeTu3w.png" /><figcaption>Trees growing money, credits — OpenAI</figcaption></figure><p>A mature tree approximately can absorb 22 kg of Carbon dioxide which is equivalent to burning 5300 Liters of gasoline. 85% of world’s oxygen is produced by forests and trees which is around 260 Billion tonnes per year.</p><p>An average adult human takes in 438L of oxygen per hour, that is around 4.1 million Liters per year. The total consumption by humanity is —</p><p><em>4.1 million * 7.9 billion(world population) = 32 * 10¹² L of O₂</em></p><p>Trees losing all leaves would be a disaster and could lead to the loss of the entirety of humanity and wildlife population. We would quickly run out of oxygen and would also increase the carbon dioxide concentrations in the atmosphere.</p><p>Humans consume 91 trillion Liters of oxygen each day, which would leave us with a very rough estimate of around 285 years.</p><p><em>(current oxygen content)/(daily oxygen consumption) = 260 * 10¹⁵ / 91 * 10¹² = 285 years</em></p><p>Not only oxygen would be depleting, CO₂ content will also increase and it being a green house gas would rapidly increase global temperatures. According to IPCC doubling of pre- industrial concentration of carbon dioxide would lead to average global warming to around 1.5 to 4.5 degree Celsius.</p><p>By calculating the concentrations an increase in 134ppm would increase the temperature by 3<strong>° </strong>C. If we aren’t pushing any oxygen in atmosphere the change in CO₂ concentrations would be as follows:</p><p><em>Time taken for increase in 1</em><strong><em>° </em></strong><em>C =</em><strong><em> (</em></strong><em>CO₂ increase) / (total volume of atmosphere)</em></p><p><em>37 * 10⁹ * 10⁶ / 5.148 * 10¹⁸ = 7.17 ppm</em></p><p>That means it will take roughly 6 years to climb by 1° C; the increase will not be linear because concentrations will continue to rise in the absence of a nullifying effect. Just around in 100 years the temperatures would increase by 17 ~ 18<strong>° </strong>C.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kp5bz4kMtWzlLeWQcrKJFA.png" /><figcaption>wildlife dying due to high temperatures, credits — OpenAI</figcaption></figure><h4>This means WE ALL WILL DIE in one generation itself.</h4><p>Also considering the quick decline in wildlife, the food chain would be disrupted and wildlife would go extinct and we would not only die due to hunger but also due to a famine or disease outbreak.</p><p>Assuming that notes can do anything that leaves can do.<br>We can’t have so many different denominations of multiple currencies when there are about 60,000 different species. If the same tree grows in two separate nations, having various exchange rates makes little sense.</p><h4>Let’s First understand How Money Works</h4><p>The concept of money is just a belief by individuals and organizations that money is valuable and can be used a medium of exchange for goods and services. Additionally the stability and trust in the issuing governments or institutions also contributes.</p><p>The purchasing power of money is what gives it’s value, which represents the amount of goods and services that can be brought with a unit of currency. This is determined by the supply and demand of money and overall level of prices in an economy.</p><p>Now that money is available everywhere and available to everyone it just isn’t anymore valuable. The rarity of something makes a thing valuable like rare earth metals such as gold and silver.</p><p>Why would a person work for another if they would get the same thing that’s available so abundantly in nature. ATM’s would not make any sense too. Governments would regularize and would stop using these tree grown money or else the whole economy would just collapse.</p><p>You would anyways end up not getting any money.</p><p><strong>Let’s say we just have one specie of tree that grows money</strong></p><p>The main issue we’d have to deal with if we only had one species is its scarcity. We cannot have a species that only grows in one place, such as deserts or rain forests. We must also ensure that money specific to that region grows. Assuming all of this occurs, we will go ahead.</p><p>Most trees produce a fruit with a seed that helps in reproduction. If the rate of regrowth does not match the rate of consumption, that species will soon become extinct.<br>There would be vast scale agricultural fields that would grow these trees, and because an average tree takes 5 to 10 years to grow, it would be a long term investment. Also, knowing that leaves dry up and fall off throughout the fall season, some good financial planning is required.</p><p>These trees will not be offered in public since it would cause havoc; instead, they will be grown in secure areas. The wealthy would become more wealthier as they acquired more land and make more money.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jeIV4MBGBwqvkcschxUifA.png" /><figcaption>rich getting richer credits — OpenAI</figcaption></figure><p>If the government so chooses, they can simply make all money useless, and anyone who own this type of money will lose all of their value at once.</p><blockquote>In summary, the idea of money growing on trees may seem intriguing, but it is not a practical or sustainable solution for currency production. Replacing all leaves with money would have dire consequences for the environment, as trees play a crucial role in absorbing carbon dioxide and producing oxygen. Additionally, the abundance of money would lead to inflation and a collapse of the economy, as the value of money is based on its scarcity and purchasing power. The idea of money growing on trees is a fanciful concept, but in reality, it would not work and would ultimately lead to the downfall of human civilization.</blockquote><p>At the end of the day, none of this would happen. So the next time your parents tell you that money doesn’t grow on trees, STOP spending and start saving.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23c66bd1add" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Detect Spam]]></title>
            <link>https://medium.com/@penadi/how-to-detect-spam-114ebfdcadae?source=rss-8cc5f069719f------2</link>
            <guid isPermaLink="false">https://medium.com/p/114ebfdcadae</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Adithya Penagonda]]></dc:creator>
            <pubDate>Sun, 25 Dec 2022 15:03:53 GMT</pubDate>
            <atom:updated>2022-12-25T15:08:13.602Z</atom:updated>
            <content:encoded><![CDATA[<p>Spam detection is an important aspect of modern online communication, as it helps to identify and filter out unwanted or unsolicited emails, texts, and other forms of messaging. This is especially important for businesses, as spam can not only be annoying for employees, but it can also be a security risk and a drain on resources.</p><p>The consequences of falling victim to a spam attack can be severe. Spam emails and texts often contain malicious links or attachments that can infect a computer or device with malware or ransomware, which can compromise sensitive data and disrupt operations. Additionally, spam can consume valuable time and resources, as employees may need to spend time sorting through and deleting unwanted messages.</p><p>Let’s see how I built a machine learning model to classify.</p><pre>!pip install nltk<br>!pip install wordcloud<br>from wordcloud import WordCloud<br>from sklearn.preprocessing import LabelEncoder<br>import numpy as np<br>import pandas as pd<br>import nltk<br>import string<br>import matplotlib.pyplot as plt<br>from nltk.stem.porter import PorterStemmer<br>from nltk.corpus import stopwords <br>from sklearn.model_selection import train_test_split</pre><p>Lets also import required scikit-learn modules</p><pre>from sklearn.linear_model import LogisticRegression<br>from sklearn.svm import SVC<br>from sklearn.naive_bayes import MultinomialNB<br>from sklearn.tree import DecisionTreeClassifier<br>from sklearn.ensemble import AdaBoostClassifier<br>from sklearn.ensemble import BaggingClassifier<br>from sklearn.neighbors import KNeighborsClassifier<br>from sklearn.ensemble import RandomForestClassifier<br>from sklearn.ensemble import ExtraTreesClassifier<br>from sklearn.ensemble import GradientBoostingClassifier<br>from xgboost import XGBClassifier</pre><p>Now let’s choose our dataset — <a href="https://www.kaggle.com/datasets/uciml/sms-spam-collection-dataset">https://www.kaggle.com/datasets/uciml/sms-spam-collection-dataset</a></p><p>For building a model we have to do the following:</p><ol><li>Data cleaning</li><li>Exploratory Data Analysis</li><li>Text pre-processing</li><li>Model building</li><li>Evaluation</li><li>Improvement</li><li>Website</li><li>Deployment</li></ol><pre>df.info()<br>df.rename(columns={&#39;v1&#39;:&#39;target&#39;,&#39;v2&#39;:&#39;text&#39;},inplace=True)<br>df.drop(columns=[&#39;Unnamed: 2&#39;,&#39;Unnamed: 3&#39;,&#39;Unnamed: 4&#39;],inplace=True)<br>encoder = LabelEncoder()<br>df[&#39;target&#39;] = encoder.fit_transform(df[&#39;target&#39;])<br>df.head()</pre><p>Lets see how our data looks like now —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*25jujnw5TJ5MLZq8vFmMXA.png" /><figcaption>1 represents a spam and 0 is ham</figcaption></figure><p>Now lets check for null and duplicate values and remove them</p><pre>df.isnull().sum()<br>df.duplicated().sum()<br>df = df.drop_duplicates(keep=&#39;first&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*cuwCU_uGPdpbV89oRf4qIA.png" /><figcaption>we got 409 duplicate values</figcaption></figure><p>After droping the values we can perform some data analysis.</p><pre>plt.pie(df[&#39;target&#39;].value_counts(), labels=[&#39;ham&#39;,&#39;spam&#39;],autopct=&quot;%0.2f&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*2J6L-M84HCa0z1BxfsjNrg.png" /><figcaption>data is imbalanced</figcaption></figure><p>Let’s now count the number of words, characters and sentences and see which can correlate the most for our model to analyze.</p><pre># num of words, characters and sentences<br>df[&#39;num_words&#39;] = df[&#39;text&#39;].apply(lambda x:len(nltk.word_tokenize(x)))<br>df[&#39;num_characters&#39;] = df[&#39;text&#39;].apply(len)<br>df[&#39;num_sentences&#39;] = df[&#39;text&#39;].apply(lambda x:len(nltk.sent_tokenize(x)))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*QvP3ADRFA5qkEezod7kE2w.png" /><figcaption>description</figcaption></figure><p>Now let’s decide the correlations</p><pre>#correlations<br>sns.heatmap(df.corr(),annot=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*vtTDYluYcictD6fM2exXhQ.png" /><figcaption>heatmap of correlations</figcaption></figure><p>Based on the heatmap we can find highest correlations of words with it being spam or not.</p><p>Now that we decided that we’ll process using words, Lets pre process it for the model to understand.</p><h4>Data pre-processing</h4><p>this involves</p><ol><li>lowercasing of all words</li><li>Tokenization</li><li>Removing special characters</li><li>Removing stop words and unnecessary punctuation</li><li>Stemming</li></ol><p>Lowercasing of all words: Lowercasing involves converting all words in a text to lowercase letters. This is often done as a pre-processing step in natural language processing (NLP) tasks in order to make the text easier to process and analyze. By converting all words to lowercase, words that are the same except for their case are treated as the same word. For example, “The” and “the” would both be converted to “the,” which allows them to be more easily processed and analyzed as a single word.</p><p>Tokenization: Tokenization is the process of breaking a piece of text into smaller units called tokens. These tokens can be words, phrases, or even individual characters, depending on the task at hand. Tokenization is often used as a pre-processing step in NLP tasks, as it allows the text to be more easily processed and analyzed by breaking it down into smaller units.</p><p>Removing special characters: Removing special characters involves removing any non-alphabetic or non-numeric characters from a piece of text. This is often done as a pre-processing step in NLP tasks in order to make the text easier to process and analyze. Special characters can include punctuation marks, symbols, and other non-alphabetic or non-numeric characters.</p><p>Removing stop words and unnecessary punctuation: Stop words are common words that are often removed from text as a pre-processing step in NLP tasks. These words, such as “a,” “an,” and “the,” do not convey much meaning on their own and can often be removed without significantly impacting the meaning of the text. Removing unnecessary punctuation involves removing any punctuation marks that do not significantly impact the meaning of the text.</p><p>Stemming: Stemming is the process of reducing inflected (or sometimes derived) words to their base form, known as the stem. This is often done as a pre-processing step in NLP tasks in order to make the text easier to process and analyze. By reducing words to their stem form, words that have the same basic meaning but are inflected differently can be more easily processed and analyzed as a single word. For example, the words “jumps,” “jumping,” and “jumped” can all be stemmed to the word “jump,” which allows them to be more easily processed and analyzed as having the same basic meaning.</p><pre>ps = PorterStemmer()<br>def transform_text(text):<br>    text = text.lower()<br>    text = nltk.word_tokenize(text)<br>    #removing special symobols and only using alpha_num<br>    y = []<br>    for i in text:<br>        if i.isalnum():<br>            y.append(i)<br>    <br>    text = y[:]<br>    y.clear()<br>    #removing stopwords<br>    for i in text:<br>        if i not in stopwords.words(&#39;english&#39;) and i not in string.punctuation:<br>            y.append(i)<br>            <br>    text = y[:]<br>    y.clear()<br>    #stemming<br>    for i in text:<br>        y.append(ps.stem(i))<br>    <br>            <br>    return &quot; &quot;.join(y)<br><br>#converting all texts<br>df[&#39;transformed_text&#39;] = df[&#39;text&#39;].apply(transform_text)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKqGSnDWOEcWB_VKt8lt0g.png" /><figcaption>here is how it looks</figcaption></figure><h4>Model Building</h4><p>Vectorization is the process of converting text data into numerical vectors that can be used as input to machine learning models. In natural language processing (NLP), vectorization is an important step in the pre-processing of text data, as many machine learning algorithms require numerical input and are not able to process text data directly.</p><p>There are several different techniques that can be used for vectorization in NLP, including one-hot encoding, n-grams, and word embeddings.</p><p>Here I used TD-IDF vectorizer.</p><p>Count Vectorizer is a method of vectorizing text data that represents each document as a vector of word counts, with each element of the vector corresponding to a specific word in the vocabulary. The value of each element represents the number of times that word appears in the document. In contrast, tf-idf (term frequency-inverse document frequency) is a method of vectorizing text data that represents each document as a weighted vector, where the weight of each element is calculated based on the frequency of the word in the document and the inverse document frequency of the word across all documents.</p><p><strong>The goal of tf-idf is to assign higher weights to words that are more important or relevant to a particular document, and lower weights to words that are less important or less relevant.</strong></p><p>learn more <a href="https://medium.com/@cmukesh8688/tf-idf-vectorizer-scikit-learn-dbc0244a911a">here</a>.</p><pre>from sklearn.feature_extraction.text import TfidfVectorizer<br>tfidf = TfidfVectorizer(max_features=3000)<br>X_2 = tfidf.fit_transform(df[&#39;transformed_text&#39;]).toarray()</pre><p>Let’s try out all the classification algorithms and see which performs best</p><pre><br>#renaming them<br>svc = SVC(kernel=&#39;sigmoid&#39;, gamma=1.0)<br>knc = KNeighborsClassifier()<br>mnb = MultinomialNB()<br>dtc = DecisionTreeClassifier(max_depth=5)<br>lrc = LogisticRegression(solver=&#39;liblinear&#39;, penalty=&#39;l1&#39;)<br>rfc = RandomForestClassifier(n_estimators=50, random_state=2)<br>abc = AdaBoostClassifier(n_estimators=50, random_state=2)<br>bc = BaggingClassifier(n_estimators=50, random_state=2)<br>etc = ExtraTreesClassifier(n_estimators=50, random_state=2)<br>gbdt = GradientBoostingClassifier(n_estimators=50,random_state=2)<br>xgb = XGBClassifier(n_estimators=50,random_state=2)<br><br># get all the values to a dictionary<br>clfs = {<br>    &#39;SVC&#39; : svc,<br>    &#39;KN&#39; : knc, <br>    &#39;NB&#39;: mnb, <br>    &#39;DT&#39;: dtc, <br>    &#39;LR&#39;: lrc, <br>    &#39;RF&#39;: rfc, <br>    &#39;AdaBoost&#39;: abc, <br>    &#39;BgC&#39;: bc, <br>    &#39;ETC&#39;: etc,<br>    &#39;GBDT&#39;:gbdt,<br>    &#39;xgb&#39;:xgb<br>}</pre><p><strong>Training the data</strong> —</p><pre>def train_classifier(clf,X_train,y_train,X_test,y_test):<br>    clf.fit(X_train,y_train)<br>    y_pred = clf.predict(X_test)<br>    accuracy = accuracy_score(y_test,y_pred)<br>    precision = precision_score(y_test,y_pred)<br>    <br>    return accuracy,precision<br><br>#training all the algorithms <br>accuracy_scores = []<br>precision_scores = []<br><br>for name,clf in clfs.items():<br>    <br>    current_accuracy,current_precision = train_classifier(clf, X_train,y_train,X_test,y_test)<br>    <br>    print(&quot;For &quot;,name)<br>    print(&quot;Accuracy - &quot;,current_accuracy)<br>    print(&quot;Precision - &quot;,current_precision)<br>    <br>    accuracy_scores.append(current_accuracy)<br>    precision_scores.append(current_precision)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NQrH1GE6QZBYn0v0_VMgAA.png" /><figcaption>list of all algorithms sorted based on precision</figcaption></figure><p><strong>Let’s try Voting Classifier</strong></p><p>A Voting Classifier is a machine learning model that uses an ensemble of multiple models to make predictions. It works by aggregating the predictions made by each individual model, and selecting the class with the highest majority of votes as the final prediction. There are two types of voting that the Voting Classifier can use: hard voting and soft voting.</p><p>In hard voting, the final prediction is based on the class with the highest number of votes. In soft voting, the final prediction is based on the average probability of each class, with the class having the highest average probability being selected as the final prediction. The Voting Classifier is useful because it allows multiple models to be used together to make more accurate predictions, and it can be used with a variety of different types of models.</p><p>learn more <a href="https://www.geeksforgeeks.org/ml-voting-classifier-using-sklearn/">here</a>.</p><pre># Voting Classifier<br># chose the first 3 best performing algorithm<br>svc = SVC(kernel=&#39;sigmoid&#39;, gamma=1.0,probability=True)<br>mnb = MultinomialNB()<br>knc = KNeighborsClassifier()<br><br>from sklearn.ensemble import VotingClassifier<br>voting = VotingClassifier(estimators=[(&#39;svm&#39;, svc), (&#39;nb&#39;, mnb), (&#39;kn&#39;, knc)])<br>voting.fit(X_train,y_train)<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*zVj1OM4uWHGec8ibfLilYw.png" /><figcaption>We got our best performance</figcaption></figure><p>We can export our trained model to build a web based app using streamlit.</p><p>Here is the final output-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p6Xz2kHb2--WsjKOoNybsQ.png" /><figcaption>Predicted as spam</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*2wdRS6R-tQNqJY0h_eEWiA.png" /><figcaption>Predicted as not a spam(ham)</figcaption></figure><p>Though I’ve observed how spammers dodge this algorithm, even in advanced algorithms that’s used by our phones.</p><p>By adding random alphabets in the end is confusing the algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*-NPrI0Ieg46IKoX51V22WQ.png" /><figcaption>this is a spam</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*gFUWHo8Be7efNvmJPWKJmw.png" /><figcaption>adding a “vl” at the end changed the output</figcaption></figure><p>The above message was on my phone and was not tagged as spam by google messages, so there is a scope of improvement. Having a diverse and bigger data set might solve this to some extend.</p><p>Here is the complete code — <a href="https://github.com/Userfound404/SMS-Spam-Checker">Github.</a></p><p>Thanks a ton for reading check out my LinkedIn too — <a href="https://www.linkedin.com/in/adithya-penagonda-0b4404231/">https://www.linkedin.com/in/adithya-penagonda-0b4404231/</a></p><p>this project was a guided project and none of this works fully represents originality. credits- CampusX</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=114ebfdcadae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Privacy- A Myth?]]></title>
            <link>https://medium.com/@penadi/privacy-a-myth-19d4fa26ca83?source=rss-8cc5f069719f------2</link>
            <guid isPermaLink="false">https://medium.com/p/19d4fa26ca83</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[privacy]]></category>
            <dc:creator><![CDATA[Adithya Penagonda]]></dc:creator>
            <pubDate>Tue, 06 Dec 2022 17:49:58 GMT</pubDate>
            <atom:updated>2022-12-06T17:57:04.649Z</atom:updated>
            <content:encoded><![CDATA[<h3>Finally, Ending The Privacy Rant!</h3><p>we are generating over 2.5 quintillion or 2.5 exabytes of data!</p><blockquote>Data security and privacy are becoming increasingly important topics in the business world. Businesses now have more access to personal data than ever before thanks to the rise of digital technology.</blockquote><p>This information can be used to gain new insights, improve the customer experience, and boost efficiency. However, greater access comes with increased responsibility.</p><p>Companies must ensure the security and privacy of their customers’ personal data. To do so, they must understand the significance of data management and the need for privacy protection. Understanding the importance of privacy protection is critical for businesses seeking to provide a safe and secure environment for their customers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6kovOL-TXbP34U6BDbCYfA.png" /><figcaption>Google&#39;s privacy guide (1/4)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hk5eN8KSM9owmTLeN9Ny7w.png" /><figcaption>Google’s privacy guide (2/4)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p1_Ecu44l6QT3PrC92QK9g.png" /><figcaption>Google’s privacy guide (3/4)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OJ1nhd5Xsptah3zxEDalUg.png" /><figcaption>Google’s privacy guide (4/4)</figcaption></figure><h4>Definition of data management</h4><p>Data management is the process of gathering, analyzing, storing, and safeguarding data to ensure its safety and accessibility. Businesses rely on data to improve performance and achieve goals more than ever before.</p><p>Data management entails ensuring that all employees follow data protection rules and procedures in order to secure the privacy of client data. Businesses acquire a wide range of data for a variety of purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qCSGAOfqRWlfemR33rLGAA.png" /><figcaption>source — Google’s browser settings</figcaption></figure><p>Data can include information about clients such as contact information, <strong>financial information</strong>, and <strong>internet behavior.</strong> Data can also include information about personnel, such as <strong>income</strong> and <strong>job history</strong>. Although organizations use this data to perform efficiently, it is critical that it is maintained correctly.</p><h3>What is browsing data?</h3><p><strong>Browsing data</strong> is information that is often stored in your browser when you interact with websites. It allows anybody else who uses your PC to view your search history and see which websites you have visited. In addition, browsing data allows websites to automatically complete forms and keep you logged in to your accounts after you close a browsing session</p><h3>What Are Cookies?</h3><p><strong>Cookies</strong> are text files with small pieces of data — like a username and password — that are used to identify your computer as you use a computer network. Data stored in a cookie is created by the server upon your connection. This data is labeled with an ID unique to you and your computer.</p><p>When the cookie is exchanged between your computer and the network server, the server reads the ID and knows what information to specifically serve to you. learn more <a href="https://www.kaspersky.com/resource-center/definitions/cookies">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5cV3mqLhLXI2FIjwd4oC6g.png" /><figcaption>consent for cookies</figcaption></figure><h3>What is privacy protection?</h3><p>Privacy protection is the act of preventing unauthorized access to customer data to ensure it is safe and secure.</p><p>Data privacy rules have been in effect for decades, but in the digital age, they have developed and become increasingly vital. Customer data protection is critical for organisations to remain comply with privacy laws and secure their reputation. Customers expect businesses to respect their privacy and safeguard it entirely. By safeguarding client data and lowering the danger of data breaches, privacy protection also aids in the prevention of cyber assaults.</p><h3>privacy protection</h3><p>Businesses must have strong privacy standards in place in order to protect themselves from data breaches and maintain their reputation. Consumer data security is crucial for preserving customer trust and avoiding reputational harm. Customers may be hesitant to make purchases from a company if they believe their data is not safe. Data breaches may also result in significant fines from regulators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qCkHrMlsoixsBH-IjBdpoQ.png" /><figcaption>Privacy Act’s based on location</figcaption></figure><p>Businesses collect and use many sorts of data to improve their performance. This can include consumer information such as <strong><em>demographics, contact information, and financial information</em></strong>. It may also include employee information such as<strong><em> pay and work history.</em></strong> Businesses can acquire data directly from their customers or through third-party sources such as social media platforms and marketing agencies.</p><p>An Android device installed with a Chrome browser sends the device’s location data to Google <strong>340 times in 24 hours</strong>. When you think about it, Google has a massive amount of data that is completely overwhelming. Google, Microsoft, Amazon, and Facebook have an estimated 1,200 petabytes of data saved among them. That’s <strong>1.2 million gigabytes</strong> of data.</p><blockquote>Although it may sound alarming, Google deserves credit for properly gathering and organizing data. The firm has made it feasible for you to pick through a massive mound of hay to discover the needle in the haystack you’re looking for in a matter of seconds.</blockquote><p>Data management, privacy protection, and data protection rules are all critical in business. They enable businesses to run correctly and acquire the data they require. To ensure the safety of customer data, they must adhere to tight rules and safeguard it.</p><p>Google AdSense may supply so much information that it can precisely target the user with the Ad you want to show.</p><h3>Be SAFE!</h3><p><strong><em>At the end of the day, it is our user’s choice whether or not to provide information. So, the next time you click the accept privacy policy button, be cautious. Using secure browsers such as Brave, Chromium, or search engines such as DuckDuckGo.<br>Sign up for accounts exclusively on genuine websites, then log out when you’re done. Clear your browsing history frequently to safeguard your privacy, and shop on encrypted websites.</em></strong></p><p><a href="https://www.wikihow.com/Be-Safe-on-the-Internet">here</a> are more tips to stay safe online.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19d4fa26ca83" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>