<?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 Krishan Kant Sharma on Medium]]></title>
        <description><![CDATA[Stories by Krishan Kant Sharma on Medium]]></description>
        <link>https://medium.com/@krishnakantvdjs10tha?source=rss-776444ac99d8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*yOOQW0dtRqLD-wNo</url>
            <title>Stories by Krishan Kant Sharma on Medium</title>
            <link>https://medium.com/@krishnakantvdjs10tha?source=rss-776444ac99d8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:46:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@krishnakantvdjs10tha/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[Amazon Sales Predictor using Pytorch]]></title>
            <link>https://medium.com/@krishnakantvdjs10tha/amazon-sales-predictor-using-pytorch-f57d26bd8692?source=rss-776444ac99d8------2</link>
            <guid isPermaLink="false">https://medium.com/p/f57d26bd8692</guid>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[matplotlib]]></category>
            <dc:creator><![CDATA[Krishan Kant Sharma]]></dc:creator>
            <pubDate>Wed, 25 Feb 2026 13:11:59 GMT</pubDate>
            <atom:updated>2026-02-26T09:24:18.041Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello people, I am Krishan Kant Sharma and I am back with another project which I made while learning pytorch to enhance my understanding of pytorch.</p><p>Let’s begin with how this project was made:</p><ol><li><strong>Importing Dataset</strong>: I downloaded karkavelrajaj/amazon-sales-dataset for my project from kaggle and used kagglehub library in python to get data in csv format.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*xuflAka4zDD_JKFvFUso3w.png" /></figure><p>2.<strong> Data Engine</strong>: Pytorch can’t traverse a csv file so next step I did was to make a dataframe of rating, discounted_percentage, discounted_price, catgeory_id and clean my data by removing rupee,commas and non numeric values because it was a mess before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OnlvDI_gUzv9lyF0iyhmow.png" /></figure><p>3. <strong>Normalization:</strong> What’s normalization in this project? Well when we scale using min-max Scaler to make prices in terms of 0 to 1 for neurons(which we will understand in later steps) because 50,000 as a price is very large than rating as 4.5 which can lead to explosion of model. Furthermore, I used log normalization because normal normalizing data was leading to values as 0.00035 so i used log to bring it to 0.35.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*0AZWoo9f9guOQJkCP0_x0w.png" /></figure><p>4.<strong> Scaling: </strong>I scaled rating between 1 to 5 and discounted_percentage between 1 to 100%. Converted category text to category_id to know maximum categories basically got category ids from a text file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*hB9BrZEiN49tn3_9mUHsFQ.png" /></figure><p>5.<strong> Tensors:</strong> Remember how I said Pytorch can’t traverse a csv file so I made dataframe into tensors. Tensors are multidimensional array for manipulating data in pytorch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*kfYqqFtAOu94xCEE8u6RWQ.png" /></figure><p>6. <strong>Train/Test Split:</strong> This model is splited into 80–20 ration of Train-Test for testing and understand if our model can work on random and value outside the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*_yH19xt489BKsXg_6pmsEQ.png" /></figure><p>Final Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*Xuf2EtkkVo_0IpK3PXntgg.png" /></figure><p>Now let’s move on to how it works:</p><ol><li><strong>Neural Network: </strong>why we use neural networks again? oh yeah because our data is non linear… we can find relation between linear data easily y=mx+c slope but for non linear data we use layers of neurons. I used nn.sequential which stacks layers and our first layer/Input linear layer(input_size,64) of input_size as input feature and 64 neurons as output feature; then second layer/hidden layer for complex data with (64,64) as both input and output feature. Last layer/Output Layer which finally condeses all values into 1 single value so (64,1). Also, an activation function… Why activation function? well ReLu adds non linearity in our data so that it could work for more complex data because the relu function is y=max(0,x) it turns negative values to 0 and positive values as it is. Then I forward pass which makes our layers work in order.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*vLIXTISlToafMras4DtYBw.png" /></figure><p>2. <strong>Training and Validation Phase:</strong> Furthermore, I added Mean Squared loss function which tells how far our prediction from actual data. I added an Adam Optimizer also which helps to update weights according to learning rate. Then after that I made a training loop of 300 epochs which consists of 4 step cycle:</p><p>a. Forward Pass: The model takes X_train and makes a guess (predictions).</p><p>b. Compute Loss: It compares that guess to the real answer (Y_train) to see how wrong it was.</p><p>c. Backward Pass:</p><ul><li><strong>optimizer.zero_grad()</strong>: Clears the memory of the previous error so we don&#39;t accidentally accumulate old mistakes.</li><li><strong>loss.backward()</strong>: Uses calculus to calculate exactly how much each weight contributed to the error.</li></ul><p>d. Update weights: <strong>optimizer.step()</strong> nudges the weights in the direction that will make the error smaller next time.</p><p>Finally model evaluation using model.eval() which tells test loss after training loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*ibSwNoaSf7a3Z7pKTnzyGQ.png" /></figure><p>Plotted Graph using matplotlib</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*yPJA5VYfLvrM__nOKRibyw.png" /></figure><p>FINAL STEP/ INFERENCE ENGINE</p><p>Lets call it a bridge between all those mathematical stuff and real value stuff. In this step you can give your input and it will tell you the fair price of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*gd0nxY3UvTkdFqGa-wbbug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A64VxMCmDKOsrsN9JnSihg.png" /><figcaption>Final Image of my project(generated using ai ofc)</figcaption></figure><p>Thanks Stranger who have read it till end. If you have any queries related to this you can contact me on my linkedin. <a href="https://www.linkedin.com/in/krishan-kant-sharma-278068258/">https://www.linkedin.com/in/krishan-kant-sharma-278068258/</a></p><p>Here’s the GITHUB REPO for the project, feel free to fork,explore and star it if you find it good.</p><p><a href="https://github.com/pydevkrishna/Amazon-Sales-Predictor/">https://github.com/pydevkrishna/Amazon-Sales-Predictor/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f57d26bd8692" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Visualizing Quantum Mechanics: Particle in a Box with Python”]]></title>
            <link>https://medium.com/@krishnakantvdjs10tha/visualizing-quantum-mechanics-particle-in-a-box-with-python-8acb84c163dc?source=rss-776444ac99d8------2</link>
            <guid isPermaLink="false">https://medium.com/p/8acb84c163dc</guid>
            <dc:creator><![CDATA[Krishan Kant Sharma]]></dc:creator>
            <pubDate>Sun, 20 Apr 2025 14:26:12 GMT</pubDate>
            <atom:updated>2025-04-20T14:28:22.687Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧠 Introduction (What &amp; Why)</h3><p><strong>Quantum mechanics</strong> describes how particles behave on very small scales, like electrons in atoms. One of its foundational equations is the <strong>Schrödinger Equation</strong> — a differential equation that tells us the <em>allowed energies</em> and <em>shapes of wavefunctions</em> for quantum systems.</p><p>In this blog, we’ll solve the <strong>Time-Independent Schrödinger Equation (TISE)</strong> for a simple 1D system: the <strong>particle in an infinite potential well</strong> (also called “particle in a box”). We’ll also visualize the quantum wavefunctions using Python.</p><h3>🧮 The Physics: Particle in a 1D Box</h3><ul><li>The potential V(x) is defined as:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*fqRxjRRxGZRmx7ll6ORngQ.png" /></figure><ul><li>The particle is <strong>trapped</strong> between x=0 and x=L, and the wavefunction must be zero at the boundaries.</li><li>The <strong>TISE</strong> becomes:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*hZI-yIqlY5mCbA-p8tHVmg.png" /></figure><ul><li>Analytically, the solutions are:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*uCQpGvvvUL-zKfEj0gWm5w.png" /></figure><p>We’ll now solve this numerically using the <strong>finite difference method</strong>.</p><h3>🧑‍💻 The Code: Solving with Python</h3><p><strong>Tools used:</strong></p><ul><li>numpy for numerical operations</li><li>scipy.linalg.eigh for solving the eigenvalue problem</li><li>matplotlib for plotting the wavefunctions</li></ul><h3>🧱 Steps:</h3><ol><li><strong>Discretize space</strong> using np.linspace()</li></ol><p><strong>2. Build the Hamiltonian matrix</strong> using finite differences</p><p><strong>3. Solve the eigenvalue problem</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/138/1*_GgwqoXeAj3oijcY1-NYag.png" /></figure><p><strong>4. Plot</strong> the first few wavefunctions and energy levels</p><p>✅ You’ll get beautiful sine waveforms and quantized energy levels, just like theory predicts.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from scipy.linalg import eigh<br><br># Constants<br>hbar = 1<br>m = 1<br>L = 1.0<br>N = 1000<br>x = np.linspace(0, L, N)<br>dx = x[1] - x[0]<br><br># Discard first and last point to apply boundary condition ψ(0)=ψ(L)=0<br>x_inner = x[1:-1]<br>N_inner = len(x_inner)<br><br># Kinetic energy operator (finite difference, second derivative)<br>coeff = -hbar**2 / (2 * m * dx**2)<br>main_diag = -2 * np.ones(N_inner)<br>off_diag = np.ones(N_inner - 1)<br>H = coeff * (np.diag(main_diag) + np.diag(off_diag, k=1) + np.diag(off_diag, k=-1))<br><br># Solve eigenvalue problem<br>energies, wavefuncs = eigh(H)<br><br># Normalize wavefunctions<br>wavefuncs = wavefuncs / np.sqrt(dx)<br><br># Plot first 3 eigenfunctions<br>plt.figure(figsize=(10, 6))<br>for n in range(3):<br>    psi = np.zeros(N)<br>    psi[1:-1] = wavefuncs[:, n]  # Add boundary zeros<br>    plt.plot(x, psi, label=f&#39;n={n+1}, E={energies[n]:.4f}&#39;)<br>plt.title(&quot;Wavefunctions for Particle in a 1D Box&quot;)<br>plt.xlabel(&quot;x&quot;)<br>plt.ylabel(&quot;ψ(x)&quot;)<br>plt.legend()<br>plt.grid(True)<br>plt.show()</pre><h3>📊 What You See</h3><ul><li>The <strong>wavefunctions</strong> have increasing complexity with higher nnn</li><li>The <strong>energy levels</strong> grow as n²</li><li>Boundaries are respected:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*773dtuaxLwbi73xJmriNtg.png" /></figure><ul><li>The wavefunctions are <strong>orthogonal</strong> and <strong>normalized.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DdzqNoUfRqb627xk4-mA2g.png" /></figure><h3>🔁 What’s Next?</h3><ul><li>Try other potentials: <strong>finite well</strong>, <strong>harmonic oscillator</strong></li><li>Animate a <strong>wave packet</strong> inside the well</li><li>Extend to <strong>2D or 3D systems</strong></li></ul><h3>✨ Conclusion</h3><p>With just a bit of Python and some linear algebra, you can simulate fundamental quantum systems. It’s a beautiful example of how <strong>code can bring physics to life</strong>.</p><h3>📂 GitHub Repository</h3><p>You can find the full Python code and instructions on GitHub:</p><p>👉 <a href="https://github.com/pydevkrishna/schrodinger-particle-in-a-box"><strong>schrodinger-particle-in-a-box</strong></a></p><p>It includes:</p><ul><li>A Python implementation of the time-independent Schrödinger equation using the finite difference method</li><li>Plots of wavefunctions for the first few energy levels</li><li>A detailed README with setup instructions and background physics</li></ul><p>Feel free to star ⭐ the repo if you find it useful, or fork 🍴 it to build your own version!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8acb84c163dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>