<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Ask Ghassem - Recent questions tagged ml-midterm</title>
<link>https://ask.ghassem.com/tag/ml-midterm</link>
<description>Powered by Question2Answer</description>
<item>
<title>How to calculate feed-forward (forward-propagation) in neural network for classification?</title>
<link>https://ask.ghassem.com/1047/calculate-forward-forward-propagation-network-classification</link>
<description>&lt;p&gt;For the following neural network, calculate accuracy of classification, given these settings&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;&quot; height=&quot;1831&quot; src=&quot;https://i.imgur.com/nEyM4qU.jpeg&quot; width=&quot;2179&quot;&gt;&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/1047/calculate-forward-forward-propagation-network-classification</guid>
<pubDate>Wed, 02 Oct 2024 14:47:26 +0000</pubDate>
</item>
<item>
<title>How to calculate the residual errors, (MSE),(MAE), and (RMSE)?</title>
<link>https://ask.ghassem.com/1031/how-to-calculate-the-residual-errors-mse-mae-and-rmse</link>
<description>&lt;p&gt;Given the following sample dataset with 5 samples and 2 features:&lt;/p&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot; style=&quot;width:500px&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;Sample&lt;/th&gt;
&lt;th&gt;Feature 1&lt;/th&gt;
&lt;th&gt;Feature 2&lt;/th&gt;
&lt;th&gt;Actual Value&lt;/th&gt;
&lt;th&gt;Predicted Value&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br&gt;
Calculate the residual errors, mean squared error (MSE), mean absolute error (MAE), and root mean squared error (RMSE) using a sample model.&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/1031/how-to-calculate-the-residual-errors-mse-mae-and-rmse</guid>
<pubDate>Fri, 27 Jan 2023 04:09:28 +0000</pubDate>
</item>
<item>
<title>How to calculate residual errors for linear regression and interpret regression metrics?</title>
<link>https://ask.ghassem.com/829/calculate-residual-regression-interpret-regression-metrics</link>
<description>Assuming we have a linear regression equation and some data points (sample), how can we calculate residual error for each data point, and total cost based on the metrics such as MAE, MSE, RMSE, MAPE, or MPE if we have their formula?</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/829/calculate-residual-regression-interpret-regression-metrics</guid>
<pubDate>Tue, 18 Feb 2020 18:30:51 +0000</pubDate>
</item>
<item>
<title>How to calculate the probability and accuracy of a Logistic Regression classifier?</title>
<link>https://ask.ghassem.com/795/calculate-probability-accuracy-logistic-regression-classifier</link>
<description>&lt;p&gt;How to solve this problem?&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://i.imgur.com/8urywpf.jpg&quot;&gt;https://i.imgur.com/8urywpf.jpg&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Q1) Complete the ? sections&lt;/p&gt;

&lt;p&gt;Q2) Accuracy of system if threshold = 0.5?&lt;/p&gt;

&lt;p&gt;Q3)&amp;nbsp;Accuracy of system if threshold = 0.95?&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/795/calculate-probability-accuracy-logistic-regression-classifier</guid>
<pubDate>Mon, 03 Feb 2020 20:31:49 +0000</pubDate>
</item>
<item>
<title>How to calculate Accuracy, Precision, Recall or F1?</title>
<link>https://ask.ghassem.com/789/how-to-calculate-accuracy-precision-recall-or-f1</link>
<description>&lt;p&gt;In the following example, calculate&amp;nbsp;Accuracy, Precision, Recall or F1?&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://i.imgur.com/OezFpqC.png&quot;&gt;https://i.imgur.com/OezFpqC.png&lt;/a&gt;&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/789/how-to-calculate-accuracy-precision-recall-or-f1</guid>
<pubDate>Mon, 27 Jan 2020 19:22:26 +0000</pubDate>
</item>
<item>
<title>How to perform a classification or regression using k-NN?</title>
<link>https://ask.ghassem.com/658/how-to-perform-a-classification-or-regression-using-k-nn</link>
<description>&lt;p&gt;Suppose, you have given the following dataset where x and y are the 2 features and color Red or Blue&amp;nbsp;is the target variable.&lt;/p&gt;

&lt;p&gt;a) A new&amp;nbsp;data point $x=1$ and $y=1$ is given. Using Euclidean distance in 3-NN, what you predict as the color for this data point?&lt;/p&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:300px; width:200px&quot;&gt;
&lt;caption&gt;Dataset&lt;/caption&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th scope=&quot;col&quot;&gt;x&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;y&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;Color&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;-1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Red&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Blue&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Red&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;-1&lt;/td&gt;
&lt;td&gt;Red&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;Blue&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Blue&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Red&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Blue&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;b) Now assume we have the following dataset and the target value is the price.&amp;nbsp;A new&amp;nbsp;data point $x=1$ and $y=1$ is given. Using Euclidean distance in 3-NN. What would be the estimated price?&lt;/p&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:300px; width:200px&quot;&gt;
&lt;caption&gt;Dataset&lt;/caption&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th scope=&quot;col&quot;&gt;x&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;y&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;Price&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;-1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;$100&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;$50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;$20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;-1&lt;/td&gt;
&lt;td&gt;$40&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;$30&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;$40&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;$70&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;$30&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/658/how-to-perform-a-classification-or-regression-using-k-nn</guid>
<pubDate>Thu, 27 Jun 2019 02:54:42 +0000</pubDate>
</item>
<item>
<title>How to calculate k-means clustering with a numerical example?</title>
<link>https://ask.ghassem.com/656/how-to-calculate-k-means-clustering-with-numerical-example</link>
<description>&lt;p&gt;Use the k-means algorithm and Euclidean distance to cluster the following 8 examples into 3 clusters:&lt;/p&gt;

&lt;p&gt;$A1=(2,10),&amp;nbsp;A2=(2,5), A3=(8,4), A4=(5,8), A5=(7,5), A6=(6,4), A7=(1,2), A8=(4,9)$.&lt;/p&gt;

&lt;p&gt;Suppose that the initial seeds (centers of each cluster) are $A1$, $A4$ and $A7$. Run the k-means algorithm for 1 epoch only. At the end of this epoch show:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a)&lt;/strong&gt; The new clusters (i.e. the examples belonging to each cluster)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b)&lt;/strong&gt; The centers of the new clusters&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c)&lt;/strong&gt; Draw a 10 by 10 space with all the 8 points and show the clusters after the first epoch and the new centroids.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d)&lt;/strong&gt; How many more iterations are needed to converge? Draw the result for each epoch&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/656/how-to-calculate-k-means-clustering-with-numerical-example</guid>
<pubDate>Thu, 27 Jun 2019 02:16:32 +0000</pubDate>
</item>
<item>
<title>How to calculate Softmax Regression probabilities in this example?</title>
<link>https://ask.ghassem.com/605/calculate-softmax-regression-probabilities-this-example</link>
<description>&lt;p&gt;The scatter plot of Iris Dataset is shown in the figure below. Assume&lt;strong&gt;&amp;nbsp;Softmax Regression&lt;/strong&gt;&amp;nbsp;is used to classify Iris to Setosa, Versicolor, or Viriginica&amp;nbsp;using just petal length and petal width. If&amp;nbsp; weights required for Softmax&amp;nbsp;Regression initialized to 1 for class Setosa, 2 for class Versicolor, and 3 for Virginica,&lt;/p&gt;

&lt;p&gt;1) What will be the probability of an iris with petal&amp;nbsp;length = 4.6&amp;nbsp; and petal width = 1.7 to be classified as Virginica?&amp;nbsp;&lt;/p&gt;

&lt;p&gt;2) What will be the probability of Virginica, if we use all features&amp;nbsp;petal&amp;nbsp;length = 4.6&amp;nbsp; and petal width = 1.7, sepal length = 5.5 and sepal width = 3.0&amp;nbsp;with the same weight initialization?&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://i.imgur.com/CezSTPM.png&quot;&gt;&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/605/calculate-softmax-regression-probabilities-this-example</guid>
<pubDate>Thu, 04 Apr 2019 18:20:53 +0000</pubDate>
</item>
<item>
<title>How to calculate feed-forward (forward-propagation) in neural network?</title>
<link>https://ask.ghassem.com/603/calculate-feed-forward-forward-propagation-neural-network</link>
<description>&lt;p&gt;In the figure&amp;nbsp;below, a neural network is shown. Calculate the following:&lt;/p&gt;

&lt;p&gt;1) How many neurons do we have in the input layer and the output layer?&lt;/p&gt;

&lt;p&gt;2) How many hidden layers do we have?&lt;/p&gt;

&lt;p&gt;3) If all the weights initialized with 1 ($w1=w2=w3=...=w19=1$), what is the output of this network after feed-forward for the sample shown in the figure&amp;nbsp;(X = (x1,x2,x3) = (2,5,3) and y=10)? What is the error of the network ($\text { Error }=\frac{1}{2}(\hat{y}-y)^{2}$)? Assume activation functions for all neurons except the output neuron is $f(z)=z$.&amp;nbsp;&lt;br&gt;
&lt;br&gt;
4) If we change the activation function of all&amp;nbsp;the neurons in the second hidden layer to Sigmoid ($S(x)=\frac{1}{1+e^{-x}}=\frac{e^{x}}{e^{x}+1}$), what would be the output of the network after this change? Calculate the error as well.&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://i.imgur.com/rtqPiRa.jpg&quot;&gt;https://i.imgur.com/rtqPiRa.jpg&lt;/a&gt;&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/603/calculate-feed-forward-forward-propagation-neural-network</guid>
<pubDate>Thu, 04 Apr 2019 15:54:17 +0000</pubDate>
</item>
<item>
<title>How to calculate Softmax Regression probabilities?</title>
<link>https://ask.ghassem.com/591/how-to-calculate-softmax-regression-probabilities</link>
<description>&lt;p&gt;The scatter plot of Iris Dataset is shown in the figure below. Assume Softmax Regression is used to classify Iris to Setosa, Versicolor, or Viriginica using just petal length and petal width. If all the weights required for Softmax Regression initialized to 0.5 and the network includes bias nodes:&lt;br&gt;
&lt;br&gt;
1) Write the weight vectors and equations for calculating the class probabilities.&lt;br&gt;
&lt;br&gt;
2) We have a new iris and we have measured petal length = 4.5 &amp;nbsp;and petal width = 1.6. Using the above initial model, what would be the result of classification?&lt;br&gt;
&lt;br&gt;
3) If we change all the weights related to the class blue to 1 and keep all other weights 0.5, what will be the predicted class?&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://i.imgur.com/CezSTPM.png&quot;&gt;&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/591/how-to-calculate-softmax-regression-probabilities</guid>
<pubDate>Thu, 21 Mar 2019 16:11:09 +0000</pubDate>
</item>
<item>
<title>How to calculate LogLoss in logistic regression?</title>
<link>https://ask.ghassem.com/588/how-to-calculate-logloss-in-logistic-regression</link>
<description>&lt;p&gt;The dataset of pass/fail in an exam for 5 students is given in the table below. If we use&amp;nbsp;&lt;strong&gt;Logistic Regression&lt;/strong&gt;&amp;nbsp;as the classifier and assume the model suggested by the optimizer will become the following for Odds of passing a course:&lt;/p&gt;

&lt;p&gt;$\log_e(Odds) = -64 + 2 \times hours$&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;&quot; height=&quot;203&quot; src=&quot;https://i.imgur.com/aVDAxTj.png&quot; width=&quot;300&quot;&gt;&lt;/p&gt;

&lt;p&gt;1) How to calculate&amp;nbsp;&lt;strong&gt;the loss of model&lt;/strong&gt;&amp;nbsp;for the student who studied 33 hours?&amp;nbsp;&lt;/p&gt;

&lt;p&gt;2) What is the &lt;strong&gt;total loss &lt;/strong&gt;of the model given in equation below?&amp;nbsp;&lt;/p&gt;

&lt;p&gt;$Logloss = -\frac{1}{N} \sum_{i=1}^N(y_i\log_e(p_i) + (1 - y_i)\log_e(1 - p_i))$&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/588/how-to-calculate-logloss-in-logistic-regression</guid>
<pubDate>Mon, 18 Mar 2019 20:34:40 +0000</pubDate>
</item>
<item>
<title>How to calculate probability in Logistic Regression?</title>
<link>https://ask.ghassem.com/587/how-to-calculate-probability-in-logistic-regression</link>
<description>&lt;p&gt;The dataset of pass/fail in an exam for 5 students is given in the table below. If we use&amp;nbsp;&lt;strong&gt;Logistic Regression&lt;/strong&gt;&amp;nbsp;as the classifier and assume the model suggested by the optimizer will become the following for Odds of passing a course:&lt;/p&gt;

&lt;p&gt;$\log (Odds) = -64 + 2 \times hours$&lt;/p&gt;

&lt;p&gt;&lt;img alt=&quot;&quot; height=&quot;203&quot; src=&quot;https://i.imgur.com/aVDAxTj.png&quot; width=&quot;300&quot;&gt;&lt;/p&gt;

&lt;p&gt;1) How to calculate the&amp;nbsp;&lt;strong&gt;probability of Pass&lt;/strong&gt;&amp;nbsp;for the student who studied 33 hours?&amp;nbsp;&lt;/p&gt;

&lt;p&gt;2) &lt;strong&gt;At least how many hours &lt;/strong&gt;the student should study that makes sure will pass the course with the probability of more than 95%?&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/587/how-to-calculate-probability-in-logistic-regression</guid>
<pubDate>Mon, 18 Mar 2019 20:22:35 +0000</pubDate>
</item>
</channel>
</rss>