<?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 Karan Chahal on Medium]]></title>
        <description><![CDATA[Stories by Karan Chahal on Medium]]></description>
        <link>https://medium.com/@karanchahal?source=rss-af4494376c50------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IpO36RaF-EyqtW9LZfMV3Q.png</url>
            <title>Stories by Karan Chahal on Medium</title>
            <link>https://medium.com/@karanchahal?source=rss-af4494376c50------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:01:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@karanchahal/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[The Mathematics Behind Machine Learning]]></title>
            <link>https://karanchahal.medium.com/the-mathematics-behind-machine-learning-1e316845941e?source=rss-af4494376c50------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e316845941e</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[Karan Chahal]]></dc:creator>
            <pubDate>Tue, 08 Aug 2023 17:04:59 GMT</pubDate>
            <atom:updated>2024-05-16T13:14:51.646Z</atom:updated>
            <content:encoded><![CDATA[<p>On a daily basis, we use machine learning (ML) whether that be when we are asking ChatGPT a question or typing a search query into Google. But, <em>how do these human-like algorithms actually work under the hood?</em></p><p>Well, that is the question I asked myself after I had spent some time building machine learning models in PyTorch(<a href="https://medium.com/@karanchahal/diagnosing-mental-health-conditions-using-deep-learning-cba61c6f6964?source=your_stories_page-------------------------------------">Diagnosing Mental Health Conditions Using Deep Learning</a> and <a href="https://medium.com/@karanchahal/creating-a-cnn-in-pytorch-for-the-cifar10-dataset-25458d499946">Creating a CNN in PyTorch for the CIFAR10 Dataset</a>). It is pretty interesting how easily accessible ML programming has become and how all it takes for an individual to create a ML model is just the programmatic understanding of the frameworks: whether that be PyTorch or TensorFlow.</p><p>This accessibility and democratization is great for increasing the use of ML throughout society, however it causes many individuals to undermine the under the hood processes that allow ML to work. Having a lack of understanding of the basics of ML limits developers from innovating new ML techniques or using the ML approaches introduced in research papers. Thus, to take advantage of ML’s full potential and become an expert in the field, it is important to understand the underlying concepts behind ML.</p><p>So let’s get into unraveling the concepts that cause ML to be so powerful…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j3UkdInbk7GDTHoMTd_rOA.png" /><figcaption><em>ML Model Predicting Pneumonia based on a Chest Radiograph</em></figcaption></figure><h3>Approach to how to Think of a Machine Learning Model</h3><p>A Machine Learning (ML) model predicts outcomes (or in other words outputs) based on given inputs. Inputs to a model can be anything (images, videos, audio files, numerical data, etc), similar to how the outputs can be anything.</p><p>Now with this in mind, it is important to recognize that every form of data whether it be an image, video, etc can be boiled down to numbers. For instance, an image is just a matrix of pixel data. Recognizing this, we can see that a ML model is just predicting numbers (outputs) based on numbers (inputs). As a result, a ML model is just like any other mathematical function (f(x), g(x), etc) and it is purely driven by the language of math.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MCAS_Y496QgIvobHUAyBIA.png" /><figcaption><em>Image showing a ML Model as a Mathematical Function</em></figcaption></figure><h3><strong>Taking a Look at a Perceptron and “Learning”</strong></h3><p>Now that we understand that a ML model is a mathematical function, let’s take a look at one of the simplest ML models that can be created, a perceptron. It is multiple perceptrons chained together that create complex deep learning neural networks (a type of advanced ML model) (for more information about the structure of neural networks and understanding the perceptron, please visit my article: <a href="https://medium.com/@karanchahal/artificial-intelligence-and-medicine-6d215add34f7">Artificial Intelligence and Medicine</a>).</p><p>A perceptron consists of weights (w1 to wn ) for each input, a bias (b) and an activation function. In the case of the perceptron below, it has one weight (w1), a bias (b1) and the tanh activation function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iPSoKfzl1ZsDh1sWpJuWyg.png" /><figcaption><em>Diagram of a Perceptron with One Input</em></figcaption></figure><p>The output (f) of the perceptron above can be modeled with the following equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*aQ6weWkTFDXabI5MvBil3w@2x.png" /></figure><p>Thinking of the perceptron as a function of input1, w1 and b1 (which it is), we can model the output of the perceptron mathematically as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*uaFpUnF1hNcxg0B5w4K3uQ@2x.png" /></figure><p>Within machine learning problems, our ML model (our function) is supposed to “learn” from given labeled data which contains inputs and corresponding correct outputs. Then using this learning, the model (our function) should be able to predict outputs to a pretty high degree of accuracy based on new inputs.</p><p>The concept of “learning” in ML, involves tuning the weights and biases based on labeled data. This tuning is done in a way so that the accuracy of the model increases.</p><p>Recognizing this, let’s attempt to make the perceptron learn to predict the probability of someone getting cancer based on age using the following data (this data is not accurate and is generated by a computer algorithm):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc4d60e8ca5d51c0853637b83d0160e4/href">https://medium.com/media/cc4d60e8ca5d51c0853637b83d0160e4/href</a></iframe><p><strong>Graphing the Data:</strong></p><pre>x = [21, 57, 23, 75, 15, 90, 39, 46, 10, 26, 77, 36, 16, 19]<br>y = [0.16257491909664504, 0.4498912027529245, 0.17450833117876016, 0.531685242634573, 0.1862944760997236 ,0.5723139374289526, 0.33334961096655963, 0.3442800291772686, 0.1450107473774238, 0.19879042910822511, 0.5717675652170906, 0.3285269754996645, 0.16914684898481053, 0.12500664046884424]<br><br>fig = plt.figure(facecolor=&#39;white&#39;)<br>ax = fig.add_subplot()<br><br>ax.set_xlabel(&#39;Age&#39;, color=&#39;black&#39;)<br>ax.set_ylabel(&#39;Probability of Individual Getting Cancer&#39;, color=&#39;black&#39;)<br><br>plt.scatter(x,y)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*ATkG-ovB83ga4WSL-zOEig@2x.png" /><figcaption><em>Scatterplot of Age versus Probability of Individual getting Cancer</em></figcaption></figure><p>The output (i.e. the prediction) of the perceptron for our first sample’s age value (input) can be modeled as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*BODNhYpVR41LBhUASt9_OQ@2x.png" /></figure><p>Simple right… But, <em>do you notice a problem in this way of representing output?</em></p><p>Well if you do, you have a great career in mathematics ahead of you. If you don’t, do not worry about it. The problem that arises in this representation is that age (which is between 10 to 90) is large causing the input ((Input1)(w1) + b1) to the tanh function to be great. With this, the value of the output to the perceptron is mostly just one at all age values due to the nature of the tanh function (see the graph below), no matter the changes in w1 or b1. This makes the perceptron impossible to train as it will always output 1 no matter the changes in w1 and b1.</p><p><strong>Graphing the Tanh Function:</strong></p><pre>x = np.linspace(-10,10,100).tolist()<br><br>def tanh(inp):<br>    return (math.exp(inp) - math.exp(-1*inp))/(math.exp(inp) + math.exp(-1*inp))<br><br>y = [tanh(i) for i in x]<br><br>plt.figure(facecolor=&#39;white&#39;)<br><br>plt.plot(x,y) <br><br>#The equation was added in through photoshop</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*6ghoD4B6Q0399sz3hu-Prw@2x.png" /><figcaption><em>Graph of the Tanh Function</em></figcaption></figure><p>Therefore, for the perceptron to actually be trained from the data, the age values will need to be normalized (made smaller). In this way, the output to the perceptron will deviate based on the w1 and b1 and will not always just be one.</p><p>Normalization is a technique which involves calculating the number of standard deviations each data point is away from the mean. By doing this, the data values becomes smaller, but their significance is kept.</p><p>The first step in normalization is to calculate the mean(µ) and standard deviation(σ):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*FodGVIDmhH1pvC0LY74QYQ@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*BPvBr-G7QnxrGeW5eXz_EQ@2x.png" /></figure><p>From here we can calculate the number of standard deviations each age value is away from the mean age value (z-score):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*qQSAMbzRjNxf14uuzYT2pg@2x.png" /></figure><p>Next, we can replace each age value with its z-score. This normalizes the age data:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a102e901a243097ee33bb6d8a0b4721/href">https://medium.com/media/6a102e901a243097ee33bb6d8a0b4721/href</a></iframe><p>Having the age data normalized, the perceptron can now be trained. The first step in training any ML model is to randomly set the weights and biases. In the case of our perceptron, the w1 value is randomly initialized at 0.3 and the b1 value is randomly initialized at -0.7.</p><p>With w1 and b1 set, the output of the perceptron for the first sample’s normalized age value of -0.729 can be calculated as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*yem6bSgCGQmHLcDvz2HpoQ@2x.png" /></figure><p>This prediction of the model is far off from the actual probability that should have been given (0.163). To make the model now learn from this first sample, we need to adjust w1 and b1 so that the model’s output becomes closer to 0.163 (becomes more accurate).</p><p>A method used for accomplishing this task involves measuring the inaccuracy of the model’s output (done mostly through a loss function) and then moving the weights and biases in a specific direction to decrease that inaccuracy (gradient descent). By doing so, the model’s output gets closer to the wanted value (becomes more accurate) and it “learns” from the sample.</p><p>Applying this method to our perceptron, we can calculate the inaccuracy of our model’s output through the mean squared error (MSE) loss function (it is the most appropriate loss function to use in this case). The MSE loss function squares the difference between the predicted value and the actual target value. In this manner, it provides a numerical value (loss) that measures the inaccuracy of the model (the higher the loss, the higher the inaccuracy). The MSE loss of the perceptron’s output for the first normalized age value can be calculated as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*HnJ_bEaRIu2VPfTrQaTWfQ@2x.png" /></figure><p>With the MSE loss calculated, we can now go ahead to adjust the w1 and b1 values of our network to lower this loss. But, <em>how do we do this exactly?</em></p><p>Well we can do this by thinking of our MSE loss as a function of our w1 and b1 (which it is):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*7a6guVsWwIkzbRUlqzATAQ@2x.png" /></figure><p>Graphing this function, we can see that as our w1 and b1 change, the values of MSE loss change. Moreover, we can see how currently we are at the point (w1 = 0.3, b1 = -0.7, MSE loss = 0.788) on this loss function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eUoJUT93CTMsEimsTLZoDg.png" /><figcaption>3-Dimensional Graph of the MSE Loss Function Plotted in MatLab</figcaption></figure><p>Just analyzing the graph, we can see that to decrease the MSE Loss, we have to decrease our w1 and increase our b1.</p><p>However, in ML, it is inefficient for us to plot our loss function for every sample and then decide in which direction to adjust the weights and biases to lower the loss (increase accuracy). Therefore, in ML, to adjust the weights and biases correctly, we use a mathematical approach. In this approach, we calculate the gradients (i.e. the slopes) of the weights and biases with respect to the loss function (called back-propagation). The gradient of a weight or bias with respect to the loss function tells us how much the loss changes when there is a change in the weight or bias (i.e. the rate of change). The weights and biases are then subtracted by their corresponding gradients multiplied by a learning rate (called gradient-descent). This subtraction causes the weights and biases to move in the direction of decrease on the loss function resulting in new adjusted weights and biases that have a lower loss (higher accuracy). An example of a weight being adjusted can be seen below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*FicRA9vnxndPNDow6Feaug@2x.png" /></figure><p>The learning rate is part of the expression as it makes sure the weights and biases aren’t adjusted too much to the point where they may lead to higher losses (overshooting).</p><p>Coming back to our perceptron, to calculate the gradient of w1 and b1 with respect to the MSE loss, we can use the concepts of derivative (which involves calculating the slope of a tangent line at a specific point on a function | watch this <a href="https://www.youtube.com/watch?v=N2PpRnFqnqY&amp;t=2s">video</a> to learn more) and partial derivative (involves calculating the derivative of a multi-variable function with respect to a single variable | watch this <a href="https://www.youtube.com/watch?app=desktop&amp;v=AXqhWeUEtQU&amp;t=567s">video</a> to learn more and watch this <a href="https://www.youtube.com/watch?v=hFvBZf-Jx28&amp;t=2s">video</a> to truly understand the multivariable chain rule) from calculus:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*AHId2lBU6ktgvC84oFWJIw@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*brBN0tzjSN2d8g9TiFgRCw@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*2-CVY1YzghUakqZfN8MWmw@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*b1iEVNGO5MF4vOtXMnDCJw@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*jWwdRPCMAw8JThruREyM0A@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*HeL80xi6FCjW-vKFL_9fjw@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*STOQNkudMBDx_CiDi42xqQ@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*SMpmwMRc2KUNMuqkWx_66Q@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*J9JqMAyI-BPACQSwRgFuSA@2x.png" /></figure><p>Now that the gradients of w1 and b1 have been calculated with respect to the MSE loss, we can adjust them as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*AZpSq1Yxbklwnu28_D4EeA@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*tN88Vyra-_-Ic66yfRvx4A@2x.png" /></figure><p>The adjusted w1 and b1 lead to a lower loss value which can be seen graphically (meaning the model is now more accurate and has learned from the first sample):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iXTKqIHQFJZLKJKG4gPGbA.png" /><figcaption>3-Dimensional Graph Depicting effect of w1 and b1 Being Adjusted</figcaption></figure><p>There we go! The perceptron has “learned” from the first sample. The process of conducting this “learning” can be summarised as follows:</p><ol><li>Forward propagation (getting the output/prediction of the model based on the sample’s input value and then calculating the loss of the output)</li><li>Backward propagation (calculating the gradients of the weights and biases with respect to the loss function)</li><li>Gradient descent (adjusting the weights and biases by subtracting them by their corresponding gradients → causing them to move in the direction of decrease on the loss function)</li></ol><p>Moving on, to fully train the perceptron, all we have to do is conduct the process detailed above with all of the other samples of the dataset and then repeat over the dataset until we start getting high accuracy. Doing this by hand would be tedious, therefore I have written a python program that trains our perceptron by looping over the dataset 10 times:</p><pre>#Ages data that will be used for training<br>age = [21, 57, 23, 75, 15, 90, 39, 46, 10, 26, 77, 36, 16, 19]<br><br>#Probability of getting cancer data that will be used for training<br>prob = [0.16257491909664504, 0.4498912027529245, 0.17450833117876016, 0.531685242634573, 0.1862944760997236 ,0.5723139374289526, 0.33334961096655963, 0.3442800291772686, 0.1450107473774238, 0.19879042910822511, 0.5717675652170906, 0.3285269754996645, 0.16914684898481053, 0.12500664046884424]<br><br>#Function that normalizes an array of data and returns that array<br>def normalize(array):<br>    avg = sum(array)/len(array)<br>    stddev = math.sqrt(sum([(i-avg)**2 for i in array])/len(array))<br>    <br>    normalized = [(l-avg)/stddev for l in array]<br>    <br>    print(&#39;----&#39;)<br>    print(&#39;avg:&#39;,avg)<br>    print(&#39;stddev:&#39;,stddev)<br>    print(&#39;----&#39;)<br>    <br>    return normalized<br><br>#Function that calculates the gradient of w1 with respect to the loss function<br>def gradw1(w1, b1, inp, label):<br>    return 2*(tanh((inp)*(w1)+b1)-label)*(1-(tanh((inp)*(w1)+b1))**2)*inp<br><br>#Function that calculates the gradient of b1 with respect to the loss function<br>def gradb1(w1, b1, inp, label):<br>    return 2*(tanh((inp)*(w1)+b1)-label)*(1-(tanh((inp)*(w1)+b1))**2)<br><br>#Function that calculates what the value is when input is put into tanh --&gt; tanh(inp) =?<br>def tanh(inp):<br>    return (math.exp(inp) - math.exp(-1*inp))/(math.exp(inp) + math.exp(-1*inp))<br><br>#Function that returns an ordered array with values going from smallest to biggest<br>def order(array):<br>    for i in range(len(array)):<br>        if(i &lt; len(array)):<br>            for h in range(i+1, len(array)):<br>                j = array[i]<br>                if(array[i]&gt;array[h]):<br>                    array[i] = array[h]<br>                    array[h] = j<br>                    <br>                    <br>    return array<br><br>#Normalize the age data<br>agen = normalize(age) <br><br>#Inititalize the weights and biases (w1 and b1)<br>w1 = 0.3<br>b1 = -0.7<br><br>#Initialize the learning rate<br>l_rate = 0.05<br><br>#Conduct training<br>for x in range(10): #loop for the number of times to train over the dataset (loop for epochs)<br>    for i in range(len(agen)): #looping over the entire dataset<br>        w1 += -1*l_rate*gradw1(w1,b1,agen[i],prob[i]) #adjusting w1<br>        b1 += -1*l_rate*gradb1(w1,b1,agen[i],prob[i]) #adjusting b1<br><br>#printing the w1 after training<br>print(&#39;w1 =&#39;, w1)<br>#printing the b1 after training<br>print(&#39;b1 =&#39;, b1)<br><br>#Creating a plot with a white-background color and setting the figure variable<br>figure = plt.figure(facecolor=&#39;white&#39;)<br><br>#Setting the axes labels<br>ax = figure.add_subplot()<br>ax.set_xlabel(&#39;Age&#39;, color=&#39;black&#39;)<br>ax.set_ylabel(&#39;Probability of Individual Getting Cancer&#39;, color=&#39;black&#39;)<br><br>#Adding a scatter plot to the previously created plot of the normalized age values vs the corresponding probability of getting cancer<br>plt.scatter(agen, prob)<br><br>#Ordering the normalized age values<br>agen = order(agen)<br><br><br>g = []<br><br>#Calculating the model&#39;s ouputs for the ordered normalized age values<br>print(&#39;-----&#39;)<br>for y in range(len(agen)):<br>    g.append(tanh(agen[y]*w1+b1))<br><br><br>#Drawing a line on the previously created plot of the model&#39;s outputs based on the normalized age value<br>plt.plot(agen,g)</pre><p>After training, we plot a scatter plot of the dataset with the normalized age values (blue dots) and the outputs of the model for each of the normalized age values (blue line). Through this plot, we can see that our model has fit the training data very well:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*qwsRm2jXH8lLLkUh3nBEoA@2x.png" /><figcaption>Scatter Plot of Training Dataset and Line Plot of the Model’s Predictions</figcaption></figure><p>To use this model in practice, we have to just save the w1 &amp; b1 values of the trained model as well as the average &amp; standard deviation values used to normalize the training dataset’s age values. For instance, given an age value of 30, we will first normalize it as follows using the average and standard deviation values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*aIRXQGT--2HECPqvjNed9w@2x.png" /></figure><p>Next, we can input this normalized value into our trained model to get a prediction on the probability of the individual getting cancer based on his/her age.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*Iy56z-JSQC0RMudqhYGgjA@2x.png" /></figure><p>To conduct predictions in python using the trained model, the following code can be implemented after you have already executed the code block above.</p><pre>#Saving the average and standard deviation of the training dataset<br>avg = 39.285714285714285<br>stddev = 25.095328453799556<br><br>#Function that normalizes input based on the training dataset&#39;s average and standard deviationn<br>def norm(inp, avg, stddev): <br>    return (inp-avg)/stddev<br><br>#New input<br>inp = 30<br><br> #Normalize input before feeding into the model<br>inp = norm(inp, avg, stddev)<br><br>#Get the model&#39;s prediction on the input (using the trained w1 and b1)<br>modelpred = tanh(inp*w1+b1)<br><br>#Print the prediction<br>print(tanh(inp*w1+b1))</pre><h3>Applying our Knowledge on how a Perceptron “Learns” to a Neural Network:</h3><p>Up till now, we have discussed the mathematical basis for training a perceptron (a type of basic ML model) and have also algorithmically (in python) implemented this training. In this section, we look to apply our knowledge to a more advanced and also very popular ML model, the neural network.</p><p>As stated before, the neural network is just layers of perceptrons attached together (to learn more about structure, read my previous <a href="https://medium.com/@karanchahal/artificial-intelligence-and-medicine-6d215add34f7">article</a>). Due to this structure, the actual training of a neural network is very similar to that of a perceptron and it applies the same mathematical concepts.</p><p>So let’s dive into it! Below is the structure of an example neural network that takes the inputs of Age, Monthly Alcohol Intake and Biological sex (0 for female, 0.5 for intersex and 1 for male) to predict the probability of an individual getting cancer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xYXPVbK4N9GVdLyXZXmlpw.png" /><figcaption>Neural Network with 2 Hidden Layers that Predicts the Probability of an Individual Getting Cancer Based on Certain Characteristics</figcaption></figure><p>The output (i.e. prediction or pred) of the model can be modeled by the following function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*Drd_821C-Mv2mXnapdB-tw@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*DEcLD95iV08I0rXwItPAhQ@2x.png" /></figure><p>To train this model and adjust all the weights and biases that are contributing to the output, similar to a perceptron, we need to have a loss function calculate the loss after the model makes a prediction. In this scenario, the mean squared error (MSE) loss function suites the neural network the best.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xx_Jg16xNB2NQYNiUHGs6w.png" /><figcaption>Diagram Emphasizing the Step of Calculating the Loss after the Model Makes a Prediction</figcaption></figure><p>Following the calculation of the loss, to make the network learn from a given sample, the gradients of the weights and biases with respect to the loss function will need to be calculated (back-propogation). Then, the gradients multiplied by some learning rate will be subtracted from the weights and biases, adjusting them (gradient descent). Sound familiar… Well it should as this process is the same way that a perceptron is trained. The only difference that arises is that our neural network’s loss function and the gradients exist in more than 3-dimensional space.</p><p>Recognizing this, lets go ahead and algebraically show how we would adjust w1 in the model based on some given sample (see below). During actual training, we would have numerical values for each of the variables in the equations below. Additionally, we would do this process of adjusting with all the weights and biases, not just with w1. Finally, our model would loop through the dataset and the weights and biases would be adjusted after each sample, not just once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*ULGbtVpYkHIET8RhoNLitg@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*09ynWY33FyXw9EvVN2drfg@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*_Y-4_O0iauvy4mVBbbwW2Q@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*4VIrpQoE8gdzqBAya9RqfA@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*MBcxg51M0fMPGQvNZG2CSw@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*83WyhtAr4cYY0PCZEFbD-A@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*gUSZgHLTDt5sA26J347ErA@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*XAMrQfLa_Z5iyBKa0nNKow@2x.png" /></figure><p>And that’s it… It’s is so spectacular how we everything in ML relies on mathematics and it really sheds light on how powerful the language of math truly is.</p><p>Overall, I hope you enjoyed reading through this (pretty lengthy) article and you gained insight into how ML models truly “learn”.</p><p>Give this article a clap 👏 so it can reach more people :)</p><h3>Stay in Touch 💬</h3><p>I am an 18-year old machine learning researcher at the University of Toronto and I am working on building various projects in ML. To get updates on my projects and my personal life, follow my <a href="https://medium.com/@karanchahal">Medium</a> and connect with me on <a href="https://www.linkedin.com/in/karan-chahal-49554320a/">LinkedIn</a>.</p><p>Have an amazing day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e316845941e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Diagnosing Mental Health Conditions Using Deep Learning]]></title>
            <link>https://karanchahal.medium.com/diagnosing-mental-health-conditions-using-deep-learning-cba61c6f6964?source=rss-af4494376c50------2</link>
            <guid isPermaLink="false">https://medium.com/p/cba61c6f6964</guid>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[mental-health]]></category>
            <dc:creator><![CDATA[Karan Chahal]]></dc:creator>
            <pubDate>Sun, 16 Oct 2022 00:34:13 GMT</pubDate>
            <atom:updated>2024-05-16T13:11:45.216Z</atom:updated>
            <content:encoded><![CDATA[<p>According to John Hopkins Institute, 1 in 4 US adults suffer from a diagnosable mental health disorder. This statistic alone just goes to show how widespread mental health conditions are in our modern day society. Although these conditions are widespread, doctors and medical professionals still do not have tools that can accurately test for mental health conditions. For example, if a patient suffering from a mental health condition goes to a medical professional, the professional will perform various physiological examinations and tests on the patient. After these tests have been conducted, the medical professional will make a diagnosis. Statistically speaking, psychiatric diagnosis accuracy ranges from 60% to 0% depending on the type of disorder. Overall, that is a very low accuracy and it showcases how many individuals suffering from a mental health condition are diagnosed incorrectly 😢</p><p>Fortunately, we aren’t the only ones that can diagnose mental health conditions as Deep Learning models can as well. In this article, we will be creating a Deep Learning model in PyTorch that can diagnose mental health conditions.</p><h3><strong>What is Deep Learning?</strong></h3><p>Deep learning is a subsection of machine learning which uses ANNs (Artificial Neural Networks). These networks are based on the brain’s architecture and are very powerful when it comes to performing certain tasks. If you want to learn more about how a Deep Learning model works, you can go check out my other article named <a href="https://karanchahal.medium.com/creating-a-cnn-in-pytorch-for-the-cifar10-dataset-25458d499946?source=your_stories_page-------------------------------------">Creating a CNN in PyTorch for the CIFAR10 Dataset</a></p><p>To create a deep learning model that can diagnose mental health conditions, the first thing that needs to be done is figuring out what type of data can be used for diagnosis. My initial thoughts involved using audio recordings. However, I soon realized that it would be difficult to get that type of data. Eventually, I stumbled upon quantitative electroencephalogram (qEGG) data.</p><h3><strong>What is an EEG?</strong></h3><p>An electroencephalogram (EEG) is a device that measures brain waves in the brain and allows medical professionals to diagnose several types of brain disorders. A qEEG is created when complex mathematical and statistical analysis is performed on those measured brain waves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aclvDki7YLLbpluj" /><figcaption>Image of an EEG From Medical News Today</figcaption></figure><p>After researching, I found that qEEG findings can point to a specific diagnosis of psychiatric syndromes and that qEEG has been previously used to diagnose depression. With this new knowledge on qEEG’s accuracy, I decided on using qEEG data for training the Deep Learning model.</p><h3>About the Dataset:</h3><p>The dataset that I used in this project came from Kaggle and is named<a href="https://www.kaggle.com/datasets/shashwatwork/eeg-psychiatric-disorders-dataset"> EEG Psychiatric Disorders Dataset</a>. This dataset includes data from a qEEG (quantitative EEG) and the features of the dataset are mostly qEEG parameters. Moreover, the qEEG data in the dataset was recorded when the patient was in the resting-state. When it comes to size, the dataset has approximately 1000 features and about 1140 samples. In terms of the background of the dataset, it was made by scientists from Seoul, South Korea for a study named “Identification of Major Psychiatric Disorders From Resting-State Electroencephalography Using a Machine Learning Approach”.</p><p><strong>Now that we have went over the details of the dataset let’s go through the code 🚀</strong></p><h3><strong>Step 1: Importing all the Libraries</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b0ddd930b890b6b04cc72952e33729f/href">https://medium.com/media/2b0ddd930b890b6b04cc72952e33729f/href</a></iframe><p>Before we begin programming the Deep Learning model, it is important that we import all the libraries and API needed for the project.</p><h3><strong>Step 2:</strong> <strong>Define the Disorder Classes that will be Diagnosed</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19d7a2f3ea8857f10444f849504bee2e/href">https://medium.com/media/19d7a2f3ea8857f10444f849504bee2e/href</a></iframe><p>The Deep Learning model will be able to diagnose various mental health conditions from qEEG data. The mental health conditions it will be able to diagnose are included in the array above. This array can be used to better understand the predictions made by model. It is important that you list your names for the mental health conditions in this sequence. The reason for this is because the Label Encoder labelled them in this way. For instance, ‘Acute stress disorder ’ corresponds to a 0 in column 8 in the dataset.</p><h3><strong>Step 3: Define the Deep Learning Model’s Parameters</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b10f038871a4ee81c3da95075c3c047/href">https://medium.com/media/5b10f038871a4ee81c3da95075c3c047/href</a></iframe><p>Here we define the number of epochs, the batch size and the learning rate. To determine the batch size, the number of epochs and the learning rate, I just used trail and error. These parameters can be changed based on what you think works best.</p><h3>Step 4: Label Encoding and Removing Columns that Contain Unnecessary Data</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa807fb9ff7f150625704d74a222a1c4/href">https://medium.com/media/fa807fb9ff7f150625704d74a222a1c4/href</a></iframe><p>In this step, we first read the csv file containing the qEEG data and then convert it to a pandas dataframe. Next, the label encoder from sklearn.preprocessing converts the string values in columns 2 and 8 to numerical values. This makes the gender data in column 2 as well as the specific disorder data in column 8 machine readable. On top of label encoding, specific columns containing data on the date, age, education, IQ and main disorder are removed from the dataframe. After this, the dataframe’s index is reset to the default (0, 1, 2, etc). By reseting the index, the dataframe will be more easier to navigate in the following steps.</p><h3>Step 5: Removing Column with Null Values</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff8fd96b31a495518ada3d03fb094258/href">https://medium.com/media/ff8fd96b31a495518ada3d03fb094258/href</a></iframe><p>In the current dataframe, there can still be data values that have a value of NaN (Not a Number) or None. These values can cause the loss to become a NaN preventing the deep learning model from getting trained properly. Due to this, it is important to remove the rows containing the NaN (Not a Number) and None values. To do this, I employed the algorithm above which returns two arrays:</p><ul><li>deletearrayrow → contains the row numbers of all the rows with NaN and None values</li><li>deletearraycol→ contains the column numbers of all the columns with NaN and None values</li></ul><p>In this specific case, I analyzed the arrays and realized that this dataset has just one column with NaN values. Therefore, in the end, I just dropped this column to get rid of all the NaN and None values from the dataframe.</p><h3>Step 6: Scaling the Data with Min-Max Normalization and Creating Two Separate Dataframes (One for Samples and One for Labels)</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4005dad4d9b8173c02d1f38ab9337237/href">https://medium.com/media/4005dad4d9b8173c02d1f38ab9337237/href</a></iframe><p>In this step, the original dataframe is split into two dataframes where one contains the samples (x) and the other contains the corresponding labels (y). In addition to this, the data in the samples dataframe is scaled between 0 and 1 using Min-Max normalization. By employing this normalization technique, the data in the samples dataframe is transformed to a similar scale. This will improve the performance of the deep learning model as it will consider all features to be of equal importance.</p><h3>Step 7: Splitting the Dataset and Creating the Neural Network</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ebbf9d057abf9a2fde98fa5f79e414d/href">https://medium.com/media/1ebbf9d057abf9a2fde98fa5f79e414d/href</a></iframe><p>Here we split the dataset (contains tensor for samples and tensor for labels) into two datasets. These two datasets are the train dataset and the test dataset. The train dataset will be used to train the model, while the test dataset will be used to test the accuracy of the model. After splitting the dataset and creating the corresponding data loaders, I created the neural network class. This class defines the neural network’s architecture as well as how the neural network will conduct forward propagation.</p><h3>Step 8: Training the Model</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b94927d5ad55905b6ef1b7ce9d043ce/href">https://medium.com/media/8b94927d5ad55905b6ef1b7ce9d043ce/href</a></iframe><p>In this step, the model is repeatedly going over the train loader for the specific number of epochs and is calculating its loss. Once the loss is calculated, the model conducts backward propagation and changes its weights to reduce its loss. In this manner, the neural network “learns” from the qEEG data. For more information on backward propagation, check out this <a href="https://karanchahal.medium.com/creating-a-cnn-in-pytorch-for-the-cifar10-dataset-25458d499946">article</a>.</p><h3>Step 9: Accuracy Calculations</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b9ce52373d13f59c5cfb55d3c17cc56/href">https://medium.com/media/5b9ce52373d13f59c5cfb55d3c17cc56/href</a></iframe><p>In this step, we calculate the accuracy of the model on the train dataset and the test dataset.</p><h3>The Results!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*6hNcHQzMUZCaxrXgnVfZGg.png" /></figure><p>As you can see above, the model achieved a 92% accuracy for the training dataset, while a 26% accuracy for the test dataset. This indicates that possibly the model is overfitting on the training dataset, therefore it may be possible to improve accuracy on the test dataset by lowering the number of epochs. Another reason for such a low accuracy on the test dataset can be the model’s architecture.</p><p>Overall, I hope you learned a lot from building this ANN because I know I did!</p><p>If you have any questions or concerns feel free to contact me 🖥</p><p>LinkedIn: <a href="https://www.linkedin.com/in/karan-chahal-49554320a/">https://www.linkedin.com/in/karan-chahal-49554320a/</a></p><p>Email: karanchahal2005.1@gmail.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cba61c6f6964" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a CNN in PyTorch for the CIFAR10 Dataset]]></title>
            <link>https://karanchahal.medium.com/creating-a-cnn-in-pytorch-for-the-cifar10-dataset-25458d499946?source=rss-af4494376c50------2</link>
            <guid isPermaLink="false">https://medium.com/p/25458d499946</guid>
            <category><![CDATA[cifar-10]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[convolutional-neural-net]]></category>
            <dc:creator><![CDATA[Karan Chahal]]></dc:creator>
            <pubDate>Sun, 03 Apr 2022 23:27:14 GMT</pubDate>
            <atom:updated>2022-04-03T23:32:40.709Z</atom:updated>
            <content:encoded><![CDATA[<p>Many new phones in the modern era are capable of performing facial recognition. Due to this capability, you are able to conveniently unlock your phone without having to type the password every time. However, have you ever wondered how a computer can perform this task?</p><p>If you think about it… 🤨 Coding a program that can do face detection would be very complex and it would not be possible through simple, if and else statements.</p><p>So how is it done? Well, these types of technologies all take advantage of deep learning.</p><h3>What is deep learning?</h3><p>Deep learning is a subset of machine learning that uses an artificial neural networks (ANN). Artificial neural networks are based on the brain’s neuronal arrangement and are highly effective at carrying out complex functions like image classification.</p><h3><strong>What is the architecture of an ANN?</strong></h3><p>In an ANN there are three types of layers:</p><ol><li><em>Input Layer → Containing the input data (only one)</em></li><li><em>Hidden Layer(s) → Responsible for conducting the computation (can be multiple)</em></li><li><em>Output Layer → Gives the final output (only one)</em></li></ol><p>Each layer has a specific number of nodes. Every node is connected to the nodes in the previous and next layer. The connections between the nodes in different layers have specific weights and biases. These weights and biases are what is used to determine the value of the node. For instance if we have two nodes of the same layer connected to 1 node in the next layer, the value of the node in the next layer would be calculated as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*TnL2qhSvbrDkVpcrVSwyPA.png" /><figcaption>Perceptron</figcaption></figure><p>Now with this type of arrangement, the neural network is a linear model that can solve problems involving linear patterns. However this makes the network incapable of performing higher-level tasks like classifying images. Thus, to make the network have the ability to do higher-order tasks, the neural network also contains activation functions for each node. Activation functions are similar to how some neurons in the brain send a pulse and others don’t. The most commonly used activation function is the rectified linear activation function (ReLU).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ly4mXGRxXeE4Ah-0mdls1A.png" /><figcaption>ReLU Activation Funciton</figcaption></figure><p>As you can see in the diagram, the ReLU function takes the output generated by the node and if the output is positive then the ReLU will output the same value, while if the output is below 0 then the ReLU will output 0.</p><p>Activation functions like ReLU are applied to the value calculated by the net input function. The activation function is the last step and it gives the output of the node. This output of each of the nodes will then act as input for the next layer and the process continues until the output layer is reached. In the following diagram, it can be clearly seen where the activation function is placed for every single node in an ANN:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/0*l46a3PafuiRLxMTS" /><figcaption>Single node in an ANN</figcaption></figure><h3><strong>How does training work?</strong></h3><p>You might have heard of the word “learning” a lot in the machine learning industry and might have wondered how an ANN “learns”? Well technically this process is called training and it how it works is by adjusting the weights and biases present in the ANN.</p><p>To adjust the weights and biases appropriately, there needs to be a training dataset with input data and the corresponding labels (correct outputs for the input data). In the training process, the first step is to conduct forward propagation through the network with an input from the training dataset. Then when we get the prediction made by our network based on the given input, we compare this prediction to the actual label of the input to derive a loss (this tells the network how inaccurate it is). This comparison is done by using a loss function like cross entropy. Now once the loss has been derived, the gradient of the loss to the weights and biases in the network is calculated (step: backward propagation). The negative of this gradient is then multiplied by an appropriate learning rate. This product is then added to the weights biases to adjust them (step: adjustment). The ANN trains in this way continuously for each of the inputs and may go over the dataset multiple times. This way of training results in an ANN that can provide predictions on input data that it hasn’t seen before.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FbfmFfD2RIcg%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DbfmFfD2RIcg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FbfmFfD2RIcg%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/d59ec15dd9abb851d8a19c0c85b36d0c/href">https://medium.com/media/d59ec15dd9abb851d8a19c0c85b36d0c/href</a></iframe><h3><strong>Specific deep learning neural networks for image classification: CNNs</strong></h3><p>Now the basic neural network in deep learning can perform a multitude of complex tasks. However, for specific situations like image classification, the neural network architecture can be adjusted and modified to maximize accuracy. In the world today, there are more than 25 different types of neural networks where each is designed to conduct a specific task.</p><p>For image classification, the specific neural network that has been created is a convolutional neural network (CNN). In terms of architecture, a convolutional neural network has additional layers called convolutional layers that fall between the input and hidden layers of the network. These convolutional layers act as filters for images and are able to capture important parts of the image. A convolutional layer works by using a kernel which is a n by n matrix (where this n can be anything and is decided by the programmer) with weights and it slides over the image. As it slides over the image, the pixels of the image under the filter are multiplied by the corresponding weights and then all those products are added to give us a pixel in the new image being created. The following gif accurately demonstrated how a kernel filters an image:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fi4NjAwytgIRDW%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fi4NjAwytgIRDW%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExMmMwZmF5YmlpZDQzb2JrOTZwMDk4emk3OWxpc3Uzc3J2dWZnaThzMCZlcD12MV9naWZzX2dpZklkJmN0PWc%2Fi4NjAwytgIRDW%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="318" frameborder="0" scrolling="no"><a href="https://medium.com/media/80da7dc38393e3ddcc99714e95cb5691/href">https://medium.com/media/80da7dc38393e3ddcc99714e95cb5691/href</a></iframe><p>In addition to the convolutional layers for CNNs, there are also pooling layers involved which reduce the number of features of the image and make the training process faster as less computing power is required. Pooling layers work similar to kernels and basically filter the image into a smaller image.</p><p>As the CNN is trained, the weights of the filters are adjusted. Once trained, the convolutional layers extract important features in the images . This causes the network to become more accurate.</p><h3><strong>Implementation of CNNs through PyTorch for the CIFAR10 dataset:</strong></h3><p>As a teenager that is very curious about deep learning and how neural networks are implemented in the real world, I have started to create networks through PyTorch. One of my newest networks is a CNN that can classify images into one of 10 classes. The classes include a plane, car, bird, cat, deer, dog, frog, horse, ship and truck. After training with 11 epochs and a batch size of 10, this CNN had an accuracy of 75.14% on the train data set. This network was trained on the CIFAR10 dataset.</p><h4>Walk-through of the PyTorch code:</h4><p><strong>STEP 1:</strong> The first step was importing all the necessary libraries for the project as well as configuring the device on which the computation of the network would be performed. Preferably, it would be faster to run the computations of the network on the GPU, but in my macbook, I do not have a GPU available so the CPU was used. Next, the hyper-parameters like the number of epochs, batch size and learning rate are set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*yhAXXtaaxLkuY0BUVntmiA.png" /></figure><p><strong>STEP 2: </strong>The second step is creating the appropriate transformations for the train dataset and the test dataset. Next, the train dataset and test dataset are loaded in and the data loaders for both the datasets are created. After this, the classes that the network will classify images into are created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*oWMzyo3qw0tbEHnvuY_hmw.png" /></figure><p><strong>STEP 3: </strong>The convolutional neural network architecture is created with 3 convolutional layers and 1 hidden layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*CEUXxp7vf7VdVMLDk9bu3w.png" /></figure><p><strong>STEP 4: </strong>The model is set equal to the ConvNet() object creating the model. Next, the criterion (loss function) and optimizer variables are created and they will be very crucial for backward propagation. After this, the training loop is created where first a forward propagation and then a backward propagation is conducted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*Rfjh_GvBF9KfMwZLKsV2Gg.png" /></figure><p><strong>STEP 5: </strong>Then the accuracy of the network on the test dataset is calculated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*L8wPjBTNZdFPrjuun36yOQ.png" /></figure><p><strong>STEP 6: </strong>The following console is obtained after running the CNN.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*YIlxQf-egwIpEpV3JoCMPA.png" /></figure><h4><strong>Challenges and Accuracy:</strong></h4><p>Initially, the CNN had an accuracy of 45% with 2 convolutional layers, 2 pooling layers and 2 hidden layers. To better improve this accuracy, I tried to add more hidden layers. At one point, I had added 6 hidden layers causing the accuracy to fall to 27%. After realizing that adding more hidden layers makes the network more ineffective, I decided to reduce the hidden layers to just one.</p><p>After this adjustment, the accuracy rose to 50%. To increase the accuracy more, I added more convolutional layers and made the kernel size 3 rather than 5. By reducing the filter size and by having 3 convolutional layers present, the accuracy of the network rose to 70%. Finally, to further increase accuracy, the hyper-parameters were adjusted giving the model a final accuracy of 75.14%.</p><h3><strong>Shoutout to Python Engineer!</strong></h3><p>Before I finish this article, I really wanted to thank <a href="https://www.youtube.com/c/PythonEngineer">Python Engineer</a> as he is the real reason that I have been able to learn so much about programming neural networks in PyTorch. Make sure to go check him out!</p><p>To conclude, deep learning is a very powerful technology and personally, I look forward to learning about how to implement it through PyTorch.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fh8zbGMyMiUE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dh8zbGMyMiUE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fh8zbGMyMiUE%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/c5e4457ff7dd3d74156ecaa8eff3c01c/href">https://medium.com/media/c5e4457ff7dd3d74156ecaa8eff3c01c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25458d499946" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Artificial Intelligence and Medicine]]></title>
            <link>https://karanchahal.medium.com/artificial-intelligence-and-medicine-6d215add34f7?source=rss-af4494376c50------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d215add34f7</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[medicine]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Karan Chahal]]></dc:creator>
            <pubDate>Mon, 22 Nov 2021 00:14:55 GMT</pubDate>
            <atom:updated>2021-11-24T21:49:58.045Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZVfsL8w7B4yVnM5fsKHPw.jpeg" /><figcaption>Image by Economic Times</figcaption></figure><p>Artificial Intelligence (AI) is an emerging technology that almost everyone has heard of. This technology is already having a huge impact on the world from voice to speech bots all the way to the algorithm which detects faces in your phone. Now due to its significance in our everyday life, it is important to understand what this technology is and to not get confused by the huge amount of words involved in this area of technology like deep learning or machine learning which are mostly thrown around as synonyms of artificial intelligence. Thus in this article, I will teach you about AI and its subsets. On top of this, we will look at neural networks and the medical applications of artificial intelligence.</p><p><strong>Artificial Intelligence (AI):</strong></p><p>In 1955, John McCarthy coined the term “Artificial Intelligence” and is recognized throughout the world as the founder of this technology. Personally, he described this technology as “the science and engineering of making intelligent machines, especially intelligent computer programs”. AI is a computer program which can do things that normal programs cannot do. Generally, AI can be coded using a complex statistical model or a lot of if-then statements. The latter method of programming AI is normally referred to as Weak AI as it is not able to carry out very complex processes as it is constrained by an if-then architecture. The utilization of complex statistical models is referred to as Strong AI and it is mostly the way to go, as these systems can perform a wide variety of tasks in an intelligent way, depending on how they are trained. Now within this broad area of AI, there is a subset of AI called machine learning (ML).</p><p><strong>Machine Learning (ML):</strong></p><p>Machine learning is a technology that has the ability to learn from data and can adapt its methods when exposed to higher volumes of data. This aspect of having a computer system “learn” without any human intervention is very efficient and can be used in a variety of ways. The huge category of machine learning can even be further divided into supervised learning, unsupervised learning and reinforcement learning.</p><p>Supervised Learning:</p><p>Supervised learning is where a computer system learns from a dataset that has been accurately labeled. A labeled dataset is one which has a list of inputs and the correct outputs for each of those inputs. With these labeled datasets, machine learning algorithms identify the patterns in the dataset and use these patterns in order to predict outputs for new input data. This type of learning is very powerful and can make the computer system exceptionally accurate for predicting the correct output.</p><p>Unsupervised Learning:</p><p>Unsupervised learning is a machine learning method that is programmed to identify patterns and structures in unlabeled data. In order to organize and analyze unlabeled data, many of the unsupervised learning algorithms cluster the data into many different categories making complex data very easy to analyze. In general, unsupervised learning is strong for organizing and identifying patterns in unlabeled data. The magnitude of data that can be provided to unsupervised learning models is infinite as almost all data is unlabeled.</p><p>Reinforcement Learning:</p><p>Reinforcement learning is when a machine learns by reacting with its environment repeatedly until it is able to come up with the best possible algorithm for the task provided. Specifically, the computer system is encouraged to improve its strategy through a reward system where if it does good it is rewarded while if it does bad, it is penalized. In this way, the machine continually strives to maximise rewards by changing its strategy based on past experience.</p><p><strong>Deep Learning:</strong></p><p>Deep learning is a subset of machine learning and in a broader sense, it is a technique that is predominantly based on the human brain. Systems based on this method can scale up their performance with access to more volume of data making them highly useful in commercial applications. Explicitly, Deep learning uses a layered structure of algorithms called an Artificial Neural Network (ANN) which is based on the biological neural network in the human brain.</p><p><strong>Neural Network:</strong></p><p>A neural network is the foundation of deep learning and it is based on the brain’s biological neuron arrangement. In a neural network we have different layers which include the input, hidden and output layer. Keep in mind that a neural network can only have 1 input/output layer, while it can have multiple hidden layers.</p><ul><li><em>Input Layer</em> — contains the initial data</li><li><em>Hidden Layer(s)</em> — responsible for all the computation</li><li><em>Output Layer </em>— produces the final result for the initial data</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uDwgYRno6mw-s5gaaVWADg.png" /><figcaption>Diagram of a neural network with the input layer, hidden layers and the output layer clearly shown</figcaption></figure><p>In each of the layers, there are nodes which act like neurons and are responsible for the computation we see in AI algorithms. When going from one layer to the next, each node in the previous layer is connected to every single node in the next layer. These connections have specific weights and the value of a node is the weights of it’s connections multiplied by the values of all their corresponding nodes, added together. For instance, if we consider a part of a neural network where one node is connected to 3 nodes of the previous layer, we compute value in the following way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*RakM-fs9j3gtDP-3hnnxhA.png" /><figcaption>Diagram of a section of a neural network showing how the value of a node is calculated</figcaption></figure><p>You might notice that in the above diagram, there is also a constant “b” being taken into account when calculating the value of each node. This “b” represents the bias for the node y0 and in general, biases help neural networks better fit the data they have been given. Now in this way, as we compute the values for nodes in each layer, they directly impact the values of the nodes for the next layer. At the end of the neural network, depending on the values of the second-last layer’s nodes, an output will be computed by the output layer.</p><p><strong>Training a Neural Network:</strong></p><p>With the neural network design, you might wonder how a neural network is trained by data to give accurate outputs. Well, a neural network’s accuracy is all dependent on the weights and biases in the network. Thus, the training or so called “learning” a neural network performs is simply the action of tweaking the weights and biases so that the network becomes accurate. This tweaking involves using a cost function and back-propagation which is a huge topic and I plan to discuss it in another article. For now here are some sources that you can use to learn about training a neural network:</p><ul><li><a href="http://neuralnetworksanddeeplearning.com/chap2.html">Chapter 2 of “Neural Networks and Deep Learning” by Micheal Nielsen</a>: Discusses back propagation and how this so-called “learning” algorithm works</li><li><a href="https://towardsdatascience.com/machine-learning-fundamentals-via-linear-regression-41a5d11f5220">“Machine learning fundamentals (I): Cost functions and gradient descent” By Conor Mc</a>: Discusses cost functions and gradient descent</li></ul><p><strong>Medical Applications:</strong></p><p>There are a variety of applications of AI in many different industries. However, one industry which will be massively impacted by AI in the coming years is the field of medicine. Current applications of AI in the medical industry include the following:</p><p>Diagnosis of Diseases:</p><p>Through the utilization of a deep learning method known as a convolutional neural network (CNN), doctors are able to input medical images into Deep Learning algorithms to get an accurate diagnosis. For example, Deep Learning algorithms which take MRI scans of the brain to diagnose Alzheimer’s have been developed and due to the continual advancement of technology, these algorithms are becoming more accurate every single day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BSBlKYG4NOU6MBi4KRJo8A.jpeg" /><figcaption>Image by Euronews</figcaption></figure><p>Drug Discovery:</p><p>In 2020, the MIT laboratory was able to leverage AI in order to discover new viable antibiotic drugs. The usage of AI in drug discovery is very impactful as it makes the process of discovering drugs way more efficient and easy. In terms of how AI can discover drugs, it uses a dataset of effective drugs against a certain disease and then the algorithm is trained on this dataset. After training has taken place, thousands of compounds are tested to see whether they have drug-like properties against the disease. With this method of drug discovery, the process becomes much more efficient and allows researchers to discover new drugs at a much faster pace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*85CWObEOMMUndK-mVctrGA.jpeg" /><figcaption>Image by CNET</figcaption></figure><p><strong>Final Remarks:</strong></p><p>Overall, this is a brief overview about AI, it’s subsets, neural networks and finally the applications of this technology in the medical field.</p><p>Sources to Learn More:</p><p><a href="https://www.ibm.com/cloud/learn/what-is-artificial-intelligence">What is Artificial Intelligence (AI)?</a></p><iframe src="https://drive.google.com/viewerng/viewer?url=https%3A//mml-book.github.io/book/mml-book.pdf&amp;embedded=true" width="600" height="780" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f92edbaacb4d34f723f5c67ff21a7ea/href">https://medium.com/media/9f92edbaacb4d34f723f5c67ff21a7ea/href</a></iframe><p><a href="https://towardsdatascience.com/everything-you-need-to-know-about-neural-networks-and-backpropagation-machine-learning-made-easy-e5285bc2be3a">Everything you need to know about Neural Networks and Backpropagation — Machine Learning Made Easy…</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d215add34f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gene Editing Technologies]]></title>
            <link>https://karanchahal.medium.com/gene-editing-technologies-3bf525da91f5?source=rss-af4494376c50------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bf525da91f5</guid>
            <category><![CDATA[gene-editing]]></category>
            <category><![CDATA[crispr-cas9]]></category>
            <category><![CDATA[prime-editing]]></category>
            <category><![CDATA[dna]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Karan Chahal]]></dc:creator>
            <pubDate>Sat, 16 Oct 2021 21:49:37 GMT</pubDate>
            <atom:updated>2021-10-16T21:49:37.376Z</atom:updated>
            <content:encoded><![CDATA[<p>Gene editing is the process of editing genes that is utilised to either study the genome or fix a genetically inherited disease. Around the world, many scientists are working to advance genetic editing technologies so that they could be applied in the real world setting since almost 60% of humans have certain health conditions as a result of their genes. Now with many scientists working on this area of science, many genetic editing techniques have been invented like TALEN editing, CRISPR Cas9 and Prime Editing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*WsH8-qgxRMPX7nDIoLS3Ew.png" /><figcaption>TALEN Editing, CRISPR Cas 9 and Prime Editing are the main ways to edit genes today</figcaption></figure><p>TALEN editing is an older gene editing method and it stands for transcription activator-like effector nucleases. This method utilises the TAL protein which is a customisable protein where each of its amino acids recognizes a specific letter in the DNA sequence of A’s, C’s, G’s and T’s. This ability of the TAL protein (also known as a TAL effector) to recognize and even bind to certain DNA sequences dependent on the composition of itself allows scientists to create different TAL proteins that recognize different genetic sequences. Now having this TAL protein doesn’t fully enable gene editing since by recognizing certain genes doesn’t mean you are actually modifying the sequence. Thus, scientists use the TAL protein in combination with endonucleases which are enzymes that are able to cut DNA strands in a double order fashion. In this way, the genetic sequence that the TAL protein recognizes is cut out, allowing for either the cell to put in a new genetic sequence in its place or giving scientists an opportunity to put a specifically edited piece of DNA in that location. In general, the TALEN editing method is able to cut and paste genes allowing for the editing of the genomic sequence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*6TKgLNRR6so02oPNFH8aew.png" /><figcaption>TALEN Editing works by using the TAL protien as a navigator and the endonucleuse as scissors</figcaption></figure><p>Although the TALEN editing method sounds pretty straightforward and accurate, it is known to be pretty inaccurate, making it unusable in the real world. Now with this problem of inaccuracy, scientists were still on the lookout for a new gene editing technology that can allow for the precise editing of the genome. This is when the editing method of CRISPR Cas9 was discovered. CRISPR Cas9 is one of the newer gene editing technologies which stands for clustered regularly interspaced short palindromic repeats and crispr associated protein 9. Within the CRISPR system it works by using a “short” guide RNA that is able to bind to a specific location on the DNA as well as an attached Cas9 enzyme. Both these components locate specific sequences of DNA and cut the DNA in the designated location using the Cas9 which acts like a piece of scissors. By cutting the sequence of DNA, the genetic edit will occur either through the body’s own DNA repair system or a modified DNA segment from the lab will be placed in the specific location causing a precise genetic edit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*bFaZczXQA1FND-Qjt07IAA.png" /><figcaption>Diagram from Vox showing how CRISPR Cas 9 performs gene editing</figcaption></figure><p>Now the way of editing the genome using CRISPR Cas9 is pretty efficient, however there is still a lot more room to improve. Thus, a new method known as Prime editing has also been invented and it is basically an add-on to the method employed by CRISPR Cas9. Prime editing utilises four main components which include the Cas-9 enzyme, the reverse transcriptase enzyme, theRNA template and the pegRNA. When the method is being employed, the pegRNA leads the whole complex(including the Cas-9 enzyme, the reverse transcriptase enzyme, the RNA template and the pegRNA) to the target DNA strand. When the target DNA strand is reached, the Cas-9enzyme nicks the DNA and then to support the DNA the pegRNA attaches to both strands of the DNA. Next, the reverse transcriptase enzyme uses the RNA template to create a modified DNA sequence. This sequence is then placed where the previous DNA was nicked. This allows for the genetic edit of one strand, but the other strand is still remaining so in order to edit the other strand, the Cas9 enzyme also nicks the certain part of the other strand. Then the system relies on the body’s DNA repair system to create the complementary DNA to the edited sequence that is already part of the genome. In the end this process of editing leaves both strands of DNA precisely edited.</p><p>Amazing Infographic showing how the prime editing process works: <a href="https://www.the-scientist.com/news-opinion/new-prime-editing-method-makes-only-single-stranded-dna-cuts-66608">https://www.the-scientist.com/news-opinion/new-prime-editing-method-makes-only-single-stranded-dna-cuts-66608</a></p><p>Now with these various techniques of editing the human genome, the future of genetically editing humans for curing diseases is likely to come soon. Additionally, many scientists are looking to develop more techniques for making the genetic editing process efficient and also possible in large organisms with trillions of cells, each of them having their own set of chromosomes (learn more about the human genome: <a href="https://karanchahal.medium.com/what-are-genes-82c4e64dc42b">https://karanchahal.medium.com/what-are-genes-82c4e64dc42b</a> ). Overall this is a brief overview of the genetic editing technologies we use today and also how genetic editing technology has progressed over the years.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bf525da91f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Proteins Play a Major Role In Our Body]]></title>
            <link>https://karanchahal.medium.com/how-proteins-play-major-roles-in-our-bodies-78be540a8d2a?source=rss-af4494376c50------2</link>
            <guid isPermaLink="false">https://medium.com/p/78be540a8d2a</guid>
            <category><![CDATA[dna]]></category>
            <category><![CDATA[lactose-intolerant]]></category>
            <category><![CDATA[gene]]></category>
            <category><![CDATA[protien]]></category>
            <category><![CDATA[biology]]></category>
            <dc:creator><![CDATA[Karan Chahal]]></dc:creator>
            <pubDate>Sat, 16 Oct 2021 21:42:56 GMT</pubDate>
            <atom:updated>2021-10-16T22:14:11.879Z</atom:updated>
            <content:encoded><![CDATA[<p>As we discussed in our previous 2 articles, genes are sequences built up of amino acids which play huge roles towards developing proteins within the body. From alzheimer’s disease to lactose intolerance, many diseases within the body are caused as a result of the malfunctioning of a specific protein in a specific group of cells in a specific region of the body. The reason for this is because proteins are the most significant parts of cells as they conduct biochemical reactions, move around certain compounds needed within the cell as well as maintain the structure of the cell. Now in order to be more specific and to learn more about specific proteins and how they influence us, down below are three different proteins and how they function within our bodies in order to keep us alive. They include the proteins: Globulins, Kinases and Lactases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q7cYUTIyY9BdbEMiy_UQVA.png" /><figcaption>Kinase, Lactase and Globulin proteins all serve different purposes</figcaption></figure><p>Globulins is a major classification of proteins which can be further classified into three categories of globulins. These include alpha, beta and gamma globulins which all play a role towards a specific task within the body. The alpha globulins are a group of proteins which are found in the blood and produced by the liver. In the realm of alpha globulins, we can further classify into alpha 1 and alpha 2 globulins which only have slight chemical composition differences. When it comes to the alpha globulin and what it does within the body, it is responsible for carrying hormones, cholesterol and copper throughout the bloodstream and also acts as an enzyme for certain biochemical reactions. Also alpha globulin can act as an enzyme which stops the actions of other enzymes. For instance, when thrombin starts to convert fibrinogen to fibrin, this causes a blood clot to occur so in order to stop thrombin from doing that conversion, is where an alpha globulin comes into play.</p><p>Another type of globulin is beta globulin which are also blood proteins with similar chemical structures to alpha globulins. Beta globulins have two types: beta 1 globulins and beta 2 globulins which are structurally different slightly, however they both perform the same task of carrying lipids, hormones and cholesterol through the bloodstream and assisting immune cells in creating an immune response against invading pathogens as well as bacteria.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wvpyqm_A-z3be9Ubkarv6w.png" /><figcaption>Alpha and Beta Globulin proteins are found in the blood</figcaption></figure><p>The last type of globulins that we have discovered to this day is gamma globulines and they are blood proteins within the body that serve to help the immune system fight against bacteria and pathogens. They are commonly referred to as immunoglobulins or antibodies. Gamma globulins have three different types which include IgM(immunoglobulin M), IgA(immunoglobulin A) and IgG(immunoglobulin G). In specific to IgM, they are the largest of the immunoglobulins and are produced the first time a virus, bacteria or antigen tries to invade the body basically acting as the first line of defense for the immune system. Next is IgG which is highest in amount throughout the body in comparison to other immunoglobulins and is found in every fluid within the body. IgG is produced by plasma cells and helps in identifying invading bacteria, viruses and antigens, overall playing a crucial role in mounting an immune response. Finally we have IgA which is produced within the mucus membranes inside of plasma cells in order to help protect the respiratory and digestive tracts. Additionally, IgA is able to prevent bacteria, viruses and other antigen types from attaching to surfaces within the body and getting into the bloodstream as it is able to neutralize invading compounds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8h4OABgbNYTYIdwdC4YCYw.png" /><figcaption>Immunoglobulins help to defend our body and serve a variety of purposes in the immune system</figcaption></figure><p>Kinases are enzymes(large and complex proteins) which add phosphate groups (PO4–3) to other molecules which is an important step in many biochemical reactions. When it comes to the human genome, over 500 kinase-encoding genes exist within it, as kinase enzymes come in many different types and have a lot of significance to the human body. In terms of phosphate group addition (phosphorylation) for kinases, their targets include proteins, lipids and even nucleic acids which make up our DNA as within the structure of DNA a phosphate group is required. For protein targets, kinases can only phosphorylate the amino acids of serin, threonine and tyrosine. This phosphorylation in proteins plays a major role in cell signaling due to phosphorylated and unphosphorylated of the protein that is being targeted can have different levels of activity. Moving on, phosphorylation of lipid molecules is important for controlling the molecular composition of membranes within cells as the phosphorylation helps to specify physical and chemical properties of the membranes. Lastly, the process we call glycolysis (metabolism of dietary sugars) involves different steps of phosphorylation by unique kinases which ultimately lead to ATP(adenosine triphosphate) which is a high energy compound used by the body.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQEzOsCagj39lO9MLrgKsQ.png" /><figcaption>Kinases phosphorylate compounds helping with things like cell signalling</figcaption></figure><p>Lactase enzymes are transmembrane proteins located in the lipid bilayer membrane in the intestinal epithelial cells. In specific to the function of this enzyme, this enzyme binds to double sugar lactose and cleaves it in ways where glucose and galactose is formed. This glucose and galactose are then absorbed by the intestinal epithelial tissue from where they are transported into the bloodstream. Lactase is an essential enzyme needed when digesting any dietary product since with low quantities of it which is the case in lactose intolerance, lactose is not broken down and travels into the large intestine where multiple issues from diarrhea to dehydration are caused. In all mammals and 65% of humans, the lactase enzyme stops to be created within the body at massive rates after weaning as it is inefficient for the body to create an enzyme that will not be used since adult humans as well as mammals most often stop eating dairy products.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MTafTCI9NCMfQy5BLOUswQ.png" /><figcaption>The lactase enzyme serves an important purpose for digesting certain dietary foods</figcaption></figure><p>To conclude, after exploring three types of proteins within the human body and how much of a significant role they play, it is evident that proteins are very important biological molecules and play many roles within our bodies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78be540a8d2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Role of Genes in Protein Synthesis]]></title>
            <link>https://karanchahal.medium.com/the-role-of-genes-in-protein-synthesis-da4d1f18d37b?source=rss-af4494376c50------2</link>
            <guid isPermaLink="false">https://medium.com/p/da4d1f18d37b</guid>
            <dc:creator><![CDATA[Karan Chahal]]></dc:creator>
            <pubDate>Sat, 19 Jun 2021 19:22:28 GMT</pubDate>
            <atom:updated>2021-06-19T19:22:28.256Z</atom:updated>
            <content:encoded><![CDATA[<p>Protein synthesis is the basis for molecular biology and is the name that represents the process which creates proteins within a living organism. Now you might wonder, what do proteins have to do with anything? They are just a substance that bodybuilders drink in order to get stronger. However as unusual as it sounds, proteins are very important within living organisms as they are the compounds which make up the structure of the cell and run biochemical reactions within the cell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yK5BggqnnBgM54hLPNMyZA.png" /><figcaption>Created by Karan Chahal</figcaption></figure><p>As you can see in the diagram above, proteins like collagen proteins form structures within the cell and proteins like chaperone proteins assist the mitochondria in creating energy. Due to this involvement and everything almost being built by them in a living thing, we can see how proteins are essential in any living organism. When it comes to how proteins look in terms of composition, they are made of amino acids linked together in a chain structure. The amino acids that are part of this chain structure include the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HbP2omaZ-hyW1QYQqrS1Fw.png" /><figcaption>Created by Karan Chahal</figcaption></figure><p>By looking at the diagram above, we can observe that there are 20 different types of amino acids with each of them having unique properties. These unique properties are what influence the proteins to do certain things within an organism. When it comes to the protein synthesis and how these proteins are originally created within the body using amino acids all comes down to genes. Genes are mostly codes for proteins and although each cell has the same genetic information as others in a multicellular organism, dependent on its type, it has unique sets of catalysts which express specific portions of the genetic sequence, meaning every type of cell creates a specific set of proteins:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v3Aw5A4Ol4ykWIca1DKCfQ.png" /><figcaption>Created by Karan Chahal</figcaption></figure><p>The synthesising of proteins overall is a complex process that can be split into two sections which are known as transcription and translation. Both of these two sections together are known as gene expression. Transcription is the first step and it involves decoding the cell’s genetic information. During this phase of transcription, enzymes known as helices split the DNA double helix structure down the middle by breaking the bonds between the nitrogen bases. After this process of splitting the DNA double helix structure is done, the enzyme known as RNA polymerase starts to create a mRNA strand. In protein synthesis, mRNA acts as a recipe for creating proteins as each amino acid within the protein structure is represented by a unique three nucleotide codon and mRNA contains sequences of these codons. For example, the 3 nucleotide codon of AGC represents the amino acid serine. The enzyme creates the mRNA strand accurately by using the template already presented by the DNA when cut in half with the addition of the complementary base pairing rule. In terms of the complementary base pairing rule, it is essentially a rule that states that adenine can only combine with thymine or uracil(For RNA strands) and that guanine can only combine with cytosine. So for instance if a DNA strand when split into two has one side that consists of AGGTACCAGGTCAAAG, the complementary RNA strand will be UCCAUGGUCCAGUUUC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-SMJP_hNvEpJmtFwSusuWw.png" /><figcaption>Created by Karan Chahal</figcaption></figure><p>After the transcription phase is complete, the mRNA strand leaves the nucleus and finds a ribosome(an organelle which creates proteins using mRNA) beginning the process of translation. The subunits of the ribosome assemble together like a sandwich on the strand of mRNA and starts to pull the mRNA strand in. Later, this leads to the attraction of tRNA molecules. tRNA is known as transfer RNA and it is responsible for carrying amino acids needed for building a protein to the ribosome. Each tRNA molecule has two distinct ends with one being there for binding to an amino acid and the other being there for binding to a corresponding codon on the mRNA strand. When translation is going on, the tRNAs automatically carry the amino acids respective to the codons presented on the mRNA to the ribosomes. With this, the ribosome rRNA(these are the molecules that form the core of all ribosomes and are known as ribosomal RNA) binds the amino acids as they come in according to their sequence. Overall this results in a huge chain of amino acids which can now either fold into a simple protein or can combine with another chain in order to build the structure for a more complex protein.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3IEJ382xKGJdQ9YsL_0DzQ.png" /><figcaption>Created by Karan Chahal</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da4d1f18d37b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What are Genes?]]></title>
            <link>https://karanchahal.medium.com/what-are-genes-82c4e64dc42b?source=rss-af4494376c50------2</link>
            <guid isPermaLink="false">https://medium.com/p/82c4e64dc42b</guid>
            <dc:creator><![CDATA[Karan Chahal]]></dc:creator>
            <pubDate>Sun, 14 Mar 2021 20:22:11 GMT</pubDate>
            <atom:updated>2021-03-14T20:22:11.970Z</atom:updated>
            <content:encoded><![CDATA[<p>Through the Human Genome Project, it can be stated that humans have 20,000 to 25,000 genes. Now you might be wondering what are genes in the first place? Well, genes are structures located within every eukaryotic cell’s nucleus, tightly packed into chromosomes which each contain hundreds to thousands of genes each. Specific to humans, there are 46 chromosomes within each cell. These chromosomes when compared from cell to cell within the human body are completely identical. The reason for this congruency is because whenever a human offspring is created, 23 chromosomes come from the male and another 23 come from the female which conjoin to form a single cell containing 46 chromosomes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*drLlN04jjnmkKl7V0cI4aQ.png" /><figcaption>Designed by Karan Chahal</figcaption></figure><p>This single cell multiplies and multiplies to create a baby which grows into an adult human composed of trillions of cells. Now due to the fact that all the cells in our body came from a single cell our genes are identical to that of the single cell giving reason to why the chromosomes throughout our cells are the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKvvnMOGjBTr9I-8RuyKKg.png" /><figcaption>Designed by Karan Chahal</figcaption></figure><p>Now this ability for cells to divide in rapid amounts and still keep the genes given by their predecessor intact is due to the structure of the chromosome in which our genes are stored. Chromosomes are made of proteins known as histones and a single molecule of deoxyribonucleic acid. Inside the chromosome, the deoxyribonucleic acid is wrapped tightly around the histones allowing for 3 meter long DNA molecules to fit in the cell’s nucleus with ease. Additionally, the chromosome structure contains a constricted region which we call the centromere. The centromere is responsible for keeping the chromosomes aligned and also serves as an attachment site for the two replicated chromosomes during the complex process of cell division. Another component of chromosomes are the telomeres which are repetitive stretches of DNA located at the ends of linear chromosomes. These components prevent the DNA from getting damaged and unraveled. Everytime the cells within an organism divide, they lose a little bit of their telomere and when this part of the chromosome is lost completely, the cell has no other option but to die. However, telomeres in some cells like white blood cells are repaired by special enzymes known as telomerase which overall allows for white blood cells and other cells of the same kind to multiply way more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*YTKmIfsAXvPFMmHgvv6UBQ.png" /><figcaption>Designed by Karan Chahal</figcaption></figure><p>As you can see in the structural diagram above, you may notice that everything boils down to what we call deoxyribonucleic acid (DNA). DNA is the blueprint of our body and it contains information that tells our body what to do. The significance of DNA is huge as without it no living thing would be able to survive. In terms of the building blocks of this magical material, it is nucleotides. A nucleotide is a compound consisting of a nucleoside linked to a phosphate group; this structure forms the basic structural unit of nucleic acids such as DNA. The nucleoside part of the nucleotide is a compound consisting of a purine or pyrimidine nitrogen base linked to a sugar molecule. The purines have a double ringed structure with a six membered ring fused to a five membered ring. While pyrimidines are smaller in size having a single six membered ring structure. In terms of the sugar component of the nucleoside, it is the sugar chemically known as deoxyribose. Below is an examples of one nucleotide which consists of the pyrimidine base thymine(T), the 5-carbon sugar: deoxyribose and a phosphate group:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*XA8TAvlvdWoBbUwp7oY7jg.png" /><figcaption>Designed by Karan Chahal</figcaption></figure><p>Looking at this nucleotide, you might be confused how this forms the double helix DNA structure we see everywhere. Well when we take a look at DNA it has four nucleotides which are adenine(A), thymine(T), cytosine(C) and guanine(G). These four nucleotides when combined in accordance with complementary base pairing format where adenine can only link with thymine and cytosine can only pair with guanine, we get the DNA double helix structure. And when DNA is broken down into sections based on purpose, we get different genes. Overall genes are the blueprints for life and serve many purposes within an organism. One of the major purposes is the role they play in protein synthesis which is the basis of creation for anything in the human body.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82c4e64dc42b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>