<?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 Prashanth A N on Medium]]></title>
        <description><![CDATA[Stories by Prashanth A N on Medium]]></description>
        <link>https://medium.com/@prashanthnagaraj98?source=rss-143ed7903137------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fKDJ-7-0j-GaURMbZWdTGQ.jpeg</url>
            <title>Stories by Prashanth A N on Medium</title>
            <link>https://medium.com/@prashanthnagaraj98?source=rss-143ed7903137------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 20:21:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prashanthnagaraj98/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[Finding Spring Constant Using Linear Regression]]></title>
            <link>https://medium.com/techtrends-digest/why-linear-regression-is-just-hookes-law-in-disguise-42b535a61058?source=rss-143ed7903137------2</link>
            <guid isPermaLink="false">https://medium.com/p/42b535a61058</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[stem-education]]></category>
            <category><![CDATA[mechanical-engineering]]></category>
            <category><![CDATA[linear-regression]]></category>
            <dc:creator><![CDATA[Prashanth A N]]></dc:creator>
            <pubDate>Tue, 16 Dec 2025 15:05:08 GMT</pubDate>
            <atom:updated>2025-12-17T19:12:14.432Z</atom:updated>
            <content:encoded><![CDATA[<h3>Finding the Spring Constant Using Linear Regression</h3><h4>A simple engineering example to understand linear regression</h4><figure><img alt="Mechanical Spring" src="https://cdn-images-1.medium.com/max/1024/0*L5g2OFTOjA4slYAY" /><figcaption>Photo by <a href="https://unsplash.com/@introspectivedsgn?utm_source=medium&amp;utm_medium=referral">Erik Mclean</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>During my mechanical engineering labs, finding the spring constant was a fun and simple experiment. We would hang weights, measure the displacement, plot weight versus displacement, and the slope of the graph would give the spring constant.</p><p>Years later, when I started learning machine learning, I was told that linear regression learns parameters by minimising a cost function using gradient descent. It felt far more complicated than the spring experiment I had easily understood.</p><p>In this article, I want to show how linear regression can be used to find the spring constant, while simplifying the underlying machine learning concepts.</p><p><a href="https://en.wikipedia.org/wiki/Hooke%27s_law">Hooke’s Law</a> states that force needed to extend or compress a spring is directly proportional to the displacement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*yMKFoGx5UeNPGorL6iu4Og.png" /><figcaption>Hooke’s Law</figcaption></figure><p>In traditional methods, the displacement of the spring is measured for different values of the applied force. Then, a displacement vs. force graph is plotted, and the slope of this graph gives the spring constant.</p><p><a href="https://en.wikipedia.org/wiki/Linear_regression">Linear Regression</a> is a model that estimates the relationship between dependent and independent variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*bpC2DVmVn9RO0hpZoGcJeQ.png" /></figure><p>A linear regression model tries to estimate the slope and intercept to obtain the best fit that establishes the relationship between the independent and dependent variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*DLPSyCxHoB199RMtHiFIXQ.png" /></figure><h3>Finding Spring Constant Using Linear Regression</h3><p>Let’s consider sample values of applied force and displacement and load them into a pandas DataFrame.</p><pre># importing library<br>import pandas as pd<br>from sklearn.linear_model import LinearRegression<br><br># loading the data<br>data = pd.DataFrame({<br>    &quot;displacement&quot;: [2, 5, 8, 15, 22, 30],<br>    &quot;force&quot;: [14, 35, 56, 105, 154, 210]})</pre><p>From the displacement vs. force plot, we can calculate the slope of the line to obtain the spring constant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*rI3X3dX_hsEEI8gvMjHBxw.png" /></figure><p><strong>Spring Constant (slope) </strong>= 7 N/m, as obtained from the plot.</p><p>Next, we train a linear regression model by considering displacement as the independent variable and force as the dependent variable.</p><pre>#Model<br>model = LinearRegression()<br><br>X = data[[&quot;displacement&quot;]]<br>y = data[&quot;force&quot;]<br><br>model.fit(X, y)<br><br>print(&quot;Slope (k):&quot;, model.coef_[0])<br>print(&quot;Intercept (b):&quot;, model.intercept_)</pre><p>The linear regression model estimates:</p><ul><li><strong>Slope (k)</strong> = 6.9999999999999964 N/m</li><li><strong>Intercept (b)</strong> ≈ 0</li></ul><p><strong>The intercept is effectively zero, which perfectly matches Hooke’s Law. And the slope is the same spring constant we found using the traditional physics approach.</strong></p><h4><strong>This article is one example of how machine learning is fundamentally about finding patterns and fitting data to variables, and how ML and DL can be used to solve many mechanical engineering problems.</strong></h4><p>If this article resonated with you as an engineer, I’d love to connect and exchange ideas. You can find me on <a href="https://www.linkedin.com/in/prashanth-a-n-852a50140/">LinkedIn</a>.</p><p>And before you go, don’t forget to <strong>clap</strong> and <strong>follow</strong> me!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42b535a61058" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techtrends-digest/why-linear-regression-is-just-hookes-law-in-disguise-42b535a61058">Finding Spring Constant Using Linear Regression</a> was originally published in <a href="https://medium.com/techtrends-digest">Coffee☕ And Code💚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Heart Attack Prediction — Machine Learning]]></title>
            <link>https://medium.com/@prashanthnagaraj98/heart-attack-prediction-machine-learning-38ec01fe36a8?source=rss-143ed7903137------2</link>
            <guid isPermaLink="false">https://medium.com/p/38ec01fe36a8</guid>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Prashanth A N]]></dc:creator>
            <pubDate>Sun, 14 Dec 2025 03:07:40 GMT</pubDate>
            <atom:updated>2025-12-16T18:34:39.868Z</atom:updated>
            <content:encoded><![CDATA[<p>In today&#39;s world, machine learning is extensively being used in the healthcare industry. Machine learning is the science of getting computers to act without being explicitly programmed. To be simple computer builds an algorithm with the given train data and predicts the test data. If we are trying to do the same by writing code we might need to use an infinite number of ‘if else’ conditions to get the output.</p><p>A heart attack occurs when the flow of blood to the heart is reduced or completely blocked. Another name for a heart attack is myocardial infarction.</p><p>In this blog, we will see how to build an ML model to predict the chances of heart attack provided the following information about the person-</p><ol><li>Age of the person(in years).</li><li>Sex (In data 1 = male; 0 = female).</li><li>Chest pain type (In data 1 = typical angina; 2 = atypical angina; 3 = non-anginal pain; 0 = asymptomatic).</li><li>Resting blood pressure (in mm Hg on admission to the hospital).</li><li>Serum cholesterol in mg/dl.</li><li>Fasting blood sugar &gt; 120 mg/dl (In data 1 = true; 0 = false).</li><li>Maximum heart rate (In data 1 = normal; 2 = having ST-T wave abnormality; 0 = hypertrophy).</li><li>Maximum heart rate achieved.</li><li>Exercise-induced angina (1 = yes; 0 = no).</li><li>ST depression induced by exercise relative to rest.</li><li>The slope of the peak exercise ST segment (2 = upsloping; 1 = flat; 0 = downsloping).</li><li>Number of major vessels (0–3) colored by fluoroscopy.</li><li>Thalassemia normal = 2; fixed defect = 1; reversible defect = 3.</li><li>Output (1 = True; 2 = False).</li></ol><h3>Table of contents</h3><ol><li>Data loading &amp; cleaning.</li><li>Logistic regression.</li><li>Decision tree.</li><li>Random forest.</li><li>XGBoost.</li><li>Final results.</li></ol><blockquote>Data loading &amp; cleaning.</blockquote><h4>Importing required libraries.</h4><pre>import matplotlib.pyplot as plt<br>import seaborn as sns<br>import plotly.express as px<br>import plotly.graph_objs as go<br>from plotly.subplots import make_subplots<br>from sklearn import tree<br>from sklearn.metrics import accuracy_score, confusion_matrix, r2_score<br>import itertools<br>import warnings<br>warnings.filterwarnings(&#39;ignore&#39;)</pre><h4>Loading the dataset (<a href="https://www.kaggle.com/datasets/rashikrahmanpritom/heart-attack-analysis-prediction-dataset">link</a>).</h4><pre>data=pd.read_csv(&#39;/kaggle/input/heart-attack-analysis-prediction-dataset/heart.csv&#39;)<br>data.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*Loqwr8Wx1DXGl9uFUcXIrw.png" /></figure><h4>Checking for null values and improper data types.</h4><pre>data.info()<br>df=data</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*tVcszH-UuCPvXyntSUpnTQ.png" /></figure><p>Data doesn’t contain any null values.</p><h4>Renaming column names for easy understanding.</h4><pre><br>df.rename(columns = {&#39;age&#39;:&#39;Age&#39;, &#39;sex&#39;:&#39;Sex&#39;,&#39;cp&#39;:&#39;Chest pain type&#39;,&#39;trtbps&#39;:&#39;Resting blood pressure&#39;,<br>                        &#39;chol&#39;:&#39;Serum cholestoral&#39;,&#39;fbs&#39;:&#39;Fasting blood sugar&#39;,<br>                       &#39;restecg&#39;:&#39;Resting electrocardiographic results&#39;,&#39;thalachh&#39;:&#39;Maximum heart rate&#39;,&#39;exng&#39;:&#39;Exercise induced angina&#39;,<br>                        &#39;oldpeak&#39;:&#39;ST depression&#39;,&#39;slp&#39;:&#39;slope of the peak exercise ST segment&#39;,<br>                       &#39;caa&#39;:&#39;No.of major vessels colored by flourosopy&#39;}, inplace = True)</pre><h4>Correlation matrix</h4><pre>corr=df.corr()<br>mask=np.triu(np.ones_like(corr,dtype=bool))<br>f,ax = plt.subplots(figsize=(15,12))<br>cmap = sns.diverging_palette(230,20, as_cmap=True)<br>sns.heatmap(corr,cmap=cmap,mask=mask,linewidth=0.5,square=True,center=0)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*TduZY8F3Nw_uWLNgWj3Vlg.png" /></figure><h4>Data distribution</h4><pre>color = &#39;#a9cce3&#39;<br>df.hist(bins=15,figsize=(25,15),color=color)<br>plt.rcParams[&#39;font.size&#39;] = 18<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*gm6ZXCi4QjLr9Sja5HtwtQ.png" /></figure><h4>Dividing the data into train and test data using stratified shuffle split</h4><pre>from sklearn.model_selection import StratifiedShuffleSplit<br><br>split=StratifiedShuffleSplit(n_splits=1,test_size=0.33,random_state=42)<br><br>for train_index, test_index in split.split(df, df[&#39;output&#39;]):<br>    strat_train_set=df.loc[train_index]<br>    strat_test_set=df.loc[test_index]</pre><h4>Function to transform the data</h4><pre>def data_transformations(data):<br>        if &#39;output&#39; in data.columns:<br>            labels=data[&#39;output&#39;]<br>            data=data.drop(&#39;output&#39;, axis=1)<br>        else:<br>            labels=None<br>    <br>        <br>        from sklearn.preprocessing import StandardScaler<br>        scaler=StandardScaler()<br>        data_scaled=scaler.fit_transform(data.select_dtypes(include=[np.number]))<br>        <br>        #output=np.hstack([data_scaled,data_cat_1hot])<br>        output=np.hstack([data_scaled,data.select_dtypes(exclude=[np.number])])<br>        <br>        return output, labels</pre><h4>Transforming the data</h4><pre>train_data, train_labels = data_transformations(strat_train_set)<br>test_data, test_labels =data_transformations(strat_test_set)</pre><h4>Function to plot confusion matrix</h4><pre>from sklearn.metrics import classification_report, confusion_matrix<br>import itertools<br>def plot_confusion_matrix(cm, classes,<br>                          normalize=False,<br>                          title=&#39;Confusion matrix&#39;,<br>                          cmap=plt.cm.Blues):<br><br>    if normalize:<br>        cm = cm.astype(&#39;float&#39;) / cm.sum(axis=1)[:, np.newaxis]<br>        print(&quot;Normalized confusion matrix&quot;)<br>    else:<br>        print(&#39;Confusion matrix, without normalization&#39;)<br><br>    print(cm)<br><br>    plt.imshow(cm, interpolation=&#39;nearest&#39;, cmap=cmap)<br>    plt.title(title,fontsize=20)<br>    plt.colorbar()<br>    tick_marks = np.arange(len(classes))<br>    plt.xticks(tick_marks, classes, rotation=45,fontsize=15)<br>    plt.yticks(tick_marks, classes,fontsize=15)<br><br>    fmt = &#39;.2f&#39; if normalize else &#39;d&#39;<br>    thresh = cm.max() / 2.<br>    for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):<br>        plt.text(j, i, format(cm[i, j], fmt),<br>                 horizontalalignment=&quot;center&quot;,<br>                 color=&quot;white&quot; if cm[i, j] &gt; thresh else &quot;black&quot;)<br><br>    #plt.tight_layout()<br>    plt.ylabel(&#39;True label&#39;,fontsize=15)<br>    plt.xlabel(&#39;Predicted label&#39;,fontsize=15)</pre><blockquote>Logistic regression.</blockquote><pre>from sklearn.linear_model import LogisticRegression<br>from sklearn.metrics import confusion_matrix<br>LR = LogisticRegression(C=0.01, solver=&#39;liblinear&#39;).fit(train_data,train_labels)<br>yhat_lr = LR.predict(test_data)<br>LR</pre><pre><br><br># Compute confusion matrix<br>cnf_matrix_LR = confusion_matrix(test_labels, yhat_lr, labels=[1,0])<br>np.set_printoptions(precision=2)<br><br><br># Plot non-normalized confusion matrix<br>plt.figure()<br>plot_confusion_matrix(cnf_matrix_LR, classes=[&#39;Heart attack=1&#39;,&#39;Heart attack=0&#39;],normalize= False,  title=&#39;Confusion matrix&#39;)<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*IxyGe0CP55ekfzx5TsHZ_A.png" /></figure><blockquote>Decision tree.</blockquote><pre>from sklearn.tree import DecisionTreeClassifier<br><br>tree_clf=DecisionTreeClassifier(criterion=&#39;entropy&#39;,max_depth=2,random_state=1)<br>tree_clf.fit(train_data,train_labels)<br><br>yhat_dectree = tree_clf.predict(test_data)</pre><pre># Compute confusion matrix<br>cnf_matrix_DT = confusion_matrix(test_labels, yhat_dectree, labels=[1,0])<br>np.set_printoptions(precision=2)<br><br><br># Plot non-normalized confusion matrix<br>plt.figure()<br>plot_confusion_matrix(cnf_matrix_DT, classes=[&#39;Heart attack=1&#39;,&#39;Heart attack=0&#39;],normalize= False,  title=&#39;Confusion matrix&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*NjaWdjhLyzcVX8QEe7JAbA.png" /></figure><blockquote>Random forest.</blockquote><pre>from sklearn.ensemble import RandomForestClassifier<br><br>rnd_clf=RandomForestClassifier(n_estimators=100,criterion=&#39;entropy&#39;)<br>rnd_clf.fit(train_data,train_labels)<br><br>y_pred_rf=rnd_clf.predict(test_data)</pre><pre><br><br># Compute confusion matrix<br>cnf_matrix_RF = confusion_matrix(test_labels, y_pred_rf, labels=[1,0])<br>np.set_printoptions(precision=2)<br><br><br># Plot non-normalized confusion matrix<br>plt.figure()<br>plot_confusion_matrix(cnf_matrix_RF, classes=[&#39;churn=1&#39;,&#39;churn=0&#39;],normalize= False,  title=&#39;Confusion matrix&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*2LUPTdALxUfKCzAOZJreYg.png" /></figure><blockquote>XGboost.</blockquote><pre>from sklearn.model_selection import RandomizedSearchCV<br>import xgboost<br><br>classifier=xgboost.XGBClassifier(tree_method=&#39;gpu_hist&#39;)<br><br>params={<br>    &quot;learning_rate&quot;:[0.05,0.10,0.15,0.20,0.25,0.30],<br>    &quot;max_depth&quot;:[2,3,4,5,6,8,10,12,15],<br>    &quot;min_child_weight&quot;:[1,3,5,7],<br>    &quot;gamma&quot;:[0.0,0.1,0.2,0.3,0.4],<br>    &quot;colsample_bytree&quot;:[0.3,0.4,0.5,0.7]}<br><br>clf =RandomizedSearchCV(classifier,param_distributions=params,n_iter=5,scoring=&#39;roc_auc&#39;,cv=5,verbose=3)<br>clf.fit(train_data,train_labels)</pre><pre><br>clf.best_params_</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*7dEzRfyXB5CnIU8spXAcTQ.png" /></figure><pre>best_model=clf.best_estimator_<br><br>best_model.fit(train_data,train_labels)<br>Y_pred_xgboost = best_model.predict(test_data)</pre><pre># Compute confusion matrix<br>cnf_matrix_XG = confusion_matrix(test_labels, Y_pred_xgboost, labels=[1,0])<br>np.set_printoptions(precision=2)<br><br><br># Plot non-normalized confusion matrix<br>plt.figure()<br>plot_confusion_matrix(cnf_matrix_XG, classes=[&#39;churn=1&#39;,&#39;churn=0&#39;],normalize= False,  title=&#39;Confusion matrix&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*xsKjd0MqCBpKpxb0Alrf8w.png" /></figure><blockquote>Final results.</blockquote><pre>fig = go.Figure(data=[go.Table(<br>                                <br>                                header=dict(values=[&#39;Model&#39;,<br>                                                    &#39;Precision&#39;,&#39;Recall&#39;,&#39;Accuracy&#39;],<br>                                line_color=&#39;#010101&#39;,<br>                                fill_color=&#39; #2980b9&#39;,line_width=3,<br>                                align=&#39;center&#39;,<br>                                font=dict(color=&quot;black&quot;, size=20)),<br>    <br>                                cells=dict(values=[(&#39;Logistic Regression&#39;,&#39;Decision Tree&#39;,&#39;Random Forest&#39;,&#39;XGboost&#39;),<br>                                                   (&quot;{:.2f}&quot;.format(metrics.precision_score(test_labels, yhat_lr, pos_label=1)),<br>                                                    &quot;{:.2f}&quot;.format(metrics.precision_score(test_labels, yhat_dectree, pos_label=1)),<br>                                                   &quot;{:.2f}&quot;.format(metrics.precision_score(test_labels, y_pred_rf, pos_label=1)),<br>                                                   &quot;{:.2f}&quot;.format(metrics.precision_score(test_labels, Y_pred_xgboost, pos_label=1))),<br>                                                  <br>                                                  (&quot;{:.2f}&quot;.format(metrics.recall_score(test_labels, yhat_lr, pos_label=1)),<br>                                                  &quot;{:.2f}&quot;.format(metrics.recall_score(test_labels, yhat_dectree, pos_label=1)),<br>                                                  &quot;{:.2f}&quot;.format(metrics.recall_score(test_labels, y_pred_rf, pos_label=1)),<br>                                                  &quot;{:.2f}&quot;.format(metrics.recall_score(test_labels, Y_pred_xgboost, pos_label=1))),<br>                                                  <br>                                                  (&quot;{:.2f}&quot;.format(metrics.accuracy_score(test_labels, yhat_lr)),<br>                                                   &quot;{:.2f}&quot;.format(metrics.accuracy_score(test_labels, yhat_dectree)),<br>                                                   &quot;{:.2f}&quot;.format(metrics.accuracy_score(test_labels, y_pred_rf)),<br>                                                   &quot;{:.2f}&quot;.format(metrics.accuracy_score(test_labels, Y_pred_xgboost)))],<br>                                fill_color=&#39; #d4e6f1&#39;,line_color=&#39;#010101&#39;,line_width=3,<br>                                           align=&#39;center&#39;,<br>                                font=dict(color=&quot;#1f1f1f&quot;, size=20),height=40) <br>)])<br><br>fig.update_layout(width=900, height=400,font=dict(<br>        family=&quot;Courier New, monospace&quot;))<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*TDuxH9UW7CqWpUW2ozq2JQ.png" /></figure><p>XGBoost is the best-performing model overall, with the highest precision (0.80) and accuracy (0.81) while maintaining high recall (0.87). Logistic Regression is a close second, with slightly lower precision and accuracy but marginally higher recall (0.89), while Decision Tree performs the worst across all three metrics.</p><p><a href="https://www.kaggle.com/code/prashanthan24/heart-attack-prediction-ml-model"><strong>Kaggle Notebook</strong></a></p><p>And before you go, don’t forget to <strong>clap</strong> and <strong>follow</strong> me!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38ec01fe36a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the basics of matrices]]></title>
            <link>https://medium.com/@prashanthnagaraj98/understanding-the-basics-of-matrices-33820c1e738f?source=rss-143ed7903137------2</link>
            <guid isPermaLink="false">https://medium.com/p/33820c1e738f</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[linear-regression]]></category>
            <dc:creator><![CDATA[Prashanth A N]]></dc:creator>
            <pubDate>Wed, 08 Feb 2023 18:43:18 GMT</pubDate>
            <atom:updated>2023-02-08T18:43:18.762Z</atom:updated>
            <content:encoded><![CDATA[<p>In machine learning problems, the numerical dataset is fed to the machine learning model in the form of a matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*pHN7Zaigxf2WvaN0cq7j_g.png" /><figcaption>Hypothesis function</figcaption></figure><p><em>θ</em>(0) and <em>θ</em>(1) are the parameters, 𝑥 represents an input variable in the form of a matrix.</p><h3>Matrices</h3><blockquote>By definition “<strong>Matrix is an ordered rectangular arrangement of elements</strong>”</blockquote><p><strong><em>Order of a matrix:</em></strong> Suppose a matrix is having <strong>m</strong> rows and <strong>n</strong> columns then the order of that particular matrix is <strong>mxn</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*v4wRymd5qB0jOk-Oy_RYSg.png" /><figcaption>Represents a matrix of order mxn</figcaption></figure><p><strong><em>Naming an element in a matrix: </em></strong>All the elements in the matrix are located by their positions. The element in the matrix’s top left and bottom right sides are named as a(11) and a(mxn) respectively. The first number in the subscript represents the row number and the second number represents the column number.</p><p>i.e a(34) represents the element present in 3rd row and 4th column of a matrix.</p><p><strong><em>Column matrix: </em></strong>A column matrix is a matrix consisting of only one column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/103/1*OtkIoBUDn0XuneYwpHEjDQ.png" /><figcaption>The order of the matrix is 4x1</figcaption></figure><p><strong><em>Row matrix:</em></strong> A row matrix is a matrix consisting of only one row.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*XPjgzi-Mc67CsoM0fZGqYQ.png" /><figcaption>The order of the matrix is 1x4</figcaption></figure><blockquote>An output variables matrix in a machine learning model consisting of numerical data will always be a column or square matrix.</blockquote><p><strong><em>Square matrix:</em></strong> A square matrix is a matrix having an equal number of rows and columns. i,e m = n.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*-o_Ct2yFnbEDVqwQ7YOvvw.png" /><figcaption>The order of the matrix is 3x3</figcaption></figure><p><strong><em>Multiplication of matrices:</em></strong> In order to multiply two matrices their order should be mxn and nxp. That is the number of columns in the first matrix should be equal to the number of rows in the second matrix.</p><p>The order of the product will be mxp.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*c_R4JPfuYs4Nb5P99IBqeg.png" /><figcaption>Matrix A is of order 2x2 and Matrix B is of order 2x3</figcaption></figure><p>The elements in the first row of matrix A will be multiplied by the elements in the first column of matrix B.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*w_dUxvIeWoqb6o9sI4USNA.png" /><figcaption>Matrix multiplication AxB</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*7jhzTuAHcgU2Ad-Etnaugw.png" /><figcaption>Multiplying elements</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/252/1*Q6xxqGnHdRhdVevo9tmqRg.png" /><figcaption>The product of multiplication and order of the matrix is 2x3</figcaption></figure><p>References:</p><ol><li>NCERT Books Class 12 Maths</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33820c1e738f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>