<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Ask Ghassem - Recent questions tagged machine-learning</title>
<link>https://ask.ghassem.com/tag/machine-learning</link>
<description>Powered by Question2Answer</description>
<item>
<title>Step-by-Step Hidden State Calculation in a Recurrent Neural Network</title>
<link>https://ask.ghassem.com/1049/step-step-hidden-state-calculation-recurrent-neural-network</link>
<description>&lt;p&gt;Consider a simplified Recurrent Neural Network (RNN) with a single input and a single output. The hidden state is updated using the recurrence:&lt;/p&gt;

&lt;p&gt;$$ h_t = \text{ReLU}(W_{ih} \cdot x_t + W_{hh} \cdot h_{t-1}) $$&lt;/p&gt;

&lt;p&gt;Assume the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;\( x_t = 3 \) for every time step&lt;/li&gt;
&lt;li&gt;\( h_0 = 0 \)&lt;/li&gt;
&lt;li&gt;\( W_{ih} = 0.4 \)&lt;/li&gt;
&lt;li&gt;\( W_{hh} = 0.6 \)&lt;/li&gt;
&lt;li&gt;Activation function: ReLU&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Compute the value of the hidden state \( h_4 \) at time \( t = 4 \).&lt;/strong&gt;&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/1049/step-step-hidden-state-calculation-recurrent-neural-network</guid>
<pubDate>Mon, 01 Dec 2025 18:32:24 +0000</pubDate>
</item>
<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>When to use one hot encode a category and when to segment by category?</title>
<link>https://ask.ghassem.com/1034/when-to-use-one-hot-encode-category-and-when-segment-category</link>
<description>When pre processing data for machine learning. Is there any difference in using one hot encoding to turn categoric variables into numeric variables or to segment the data and the model being used along the category. So say you run a multivariate regression model on data covering 5 cities. Would a single model with one variable for each city be more better or worse than having 5 models specific for each city? Or is there no difference? Or does it depend on certain factors and intuition?</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/1034/when-to-use-one-hot-encode-category-and-when-segment-category</guid>
<pubDate>Wed, 22 Feb 2023 20:30:38 +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>Creating tables from unstructured texts about stock market</title>
<link>https://ask.ghassem.com/1026/creating-tables-from-unstructured-texts-about-stock-market</link>
<description>&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;p&gt;I am trying to extract information such as profits, revenues and others along with their corresponding dates and quarters from an unstructured text about stock market and convert it into a report in the table form but as there is not format of the input text, it is hard to know which entity belong to what date and quarters and which value belong to which entity. Chunking works on few documents but not enough. Is there any unsupervised way to linking entities with their corresponding dates, values and quarters?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/1026/creating-tables-from-unstructured-texts-about-stock-market</guid>
<pubDate>Tue, 02 Aug 2022 00:47:49 +0000</pubDate>
</item>
<item>
<title>Kmeans clustering in python - Giving original labels to predicted clusters</title>
<link>https://ask.ghassem.com/1022/kmeans-clustering-python-giving-original-predicted-clusters</link>
<description>&lt;p&gt;I have a dataset with 7 labels in the target variable.&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-python&quot; data-pbcklang=&quot;python&quot; data-pbcktabsize=&quot;4&quot;&gt;
X = data.drop(&#039;target&#039;, axis=1)
Y = data[&#039;target&#039;]
Y.unique()&lt;/pre&gt;

&lt;p&gt;array([&#039;Normal_Weight&#039;, &#039;Overweight_Level_I&#039;, &#039;Overweight_Level_II&#039;,&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&#039;Obesity_Type_I&#039;, &#039;Insufficient_Weight&#039;, &#039;Obesity_Type_II&#039;,&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&#039;Obesity_Type_III&#039;], dtype=object)&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-python&quot; data-pbcklang=&quot;python&quot; data-pbcktabsize=&quot;4&quot;&gt;
km = KMeans(n_clusters=7, init=&quot;k-means++&quot;, random_state=300)
km.fit_predict(X)
np.unique(km.labels_)&lt;/pre&gt;

&lt;p&gt;array([0, 1, 2, 3, 4, 5, 6])&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;After performing KMean clustering algorithm with number of clusters as 7, the resulted clusters are labeled as 0,1,2,3,4,5,6. But how to know which real label matches with the predicted label.&lt;/p&gt;

&lt;p&gt;In other words, I want to know how to give original label names to new predicted labels, so that they can be compared like how many values are clustered correctly (Accuracy).&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/1022/kmeans-clustering-python-giving-original-predicted-clusters</guid>
<pubDate>Wed, 27 Apr 2022 05:32:54 +0000</pubDate>
</item>
<item>
<title>how to output f1-score instead of accuracy</title>
<link>https://ask.ghassem.com/1019/how-to-output-f1-score-instead-of-accuracy</link>
<description>&lt;p&gt;I have the code below, outputting the accuracy. How can I output the F1-score instead? Thanks in advance,&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt; clf.fit(data_train,target_train)  
preds = clf.predict(data_test)  
# accuracy for the current fold only     
r2score = clf.score(data_test,target_test)&lt;/code&gt;&lt;/pre&gt;</description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/1019/how-to-output-f1-score-instead-of-accuracy</guid>
<pubDate>Sat, 02 Apr 2022 13:04:21 +0000</pubDate>
</item>
<item>
<title>I cannot get this code to work. please help.</title>
<link>https://ask.ghassem.com/1018/i-cannot-get-this-code-to-work-please-help</link>
<description>&lt;p&gt;from keras.models import Sequential&amp;nbsp;&lt;br&gt;
from keras.layers import Dense&amp;nbsp;&lt;br&gt;
from keras.layers import LSTM&amp;nbsp;&lt;br&gt;
from sklearn.model_selection import train_test_split&lt;/p&gt;

&lt;p&gt;model = Sequential()&amp;nbsp;&lt;br&gt;
model.add(LSTM( 10, input_shape=(1, 1)))&amp;nbsp;&lt;br&gt;
model.add(Dense(1, activation=&quot;linear&quot;))&amp;nbsp;&lt;br&gt;
model.compile(loss=&quot;mse&quot;, optimizer=&quot;adam&quot;)&lt;/p&gt;

&lt;p&gt;X, y = get_data()&lt;/p&gt;

&lt;p&gt;X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=1)&lt;br&gt;
X_train_2, X_val, y_train_2, y_val = train_test_split(X_train, y_train, test_size=0.25, random_state=1)&lt;/p&gt;

&lt;p&gt;model.fit(X_train, y_train, epochs=800, validation_data=(X_val, y_val), shuffle=False)&lt;/p&gt;
html, body, table, thead, input, textarea, select {color: #bab5ab!important; background: #35393b;} input[type=&quot;text&quot;], textarea, select {color: #bab5ab!important; background: #35393b;} [data-darksite-inline-background-image-gradient] {background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))!important; -webkit-background-size: cover!important; -moz-background-size: cover!important; -o-background-size: cover!important; background-size: cover!important;} [data-darksite-force-inline-background] * {background-color: rgba(0,0,0,0.7)!important;} [data-darksite-inline-background] {background-color: rgba(0,0,0,0.7)!important;} [data-darksite-inline-color] {color: #fff!important;} [data-darksite-inline-background-image] {background-image: linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.3))!important}
</description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/1018/i-cannot-get-this-code-to-work-please-help</guid>
<pubDate>Mon, 21 Mar 2022 05:59:53 +0000</pubDate>
</item>
<item>
<title>When dealing with categorical values, should the &#039;year&#039; column be encoded using OHE or OrdinalEncoder?</title>
<link>https://ask.ghassem.com/1012/dealing-categorical-values-should-encoded-ordinalencoder</link>
<description>It&amp;#039;s a car prices dataset, and so I&amp;#039;m assuming that the more recent the more value a car should have. The values in the &amp;#039;year&amp;#039; column simply consist of years from 1995 to 2020.&lt;br /&gt;
I am trying to predict the selling price of the car.&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;m a bit new to ML, currently still doing my undergraduate so any help / tips are appreciated. Thank you.</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/1012/dealing-categorical-values-should-encoded-ordinalencoder</guid>
<pubDate>Sat, 18 Dec 2021 18:46:07 +0000</pubDate>
</item>
<item>
<title>How do I know which encoder to use to convert from categorical variables to numerical?</title>
<link>https://ask.ghassem.com/1006/know-which-encoder-convert-categorical-variables-numerical</link>
<description>So say I have a column with categorical data like different styles of temperature: &amp;#039;Lukewarm&amp;#039;, &amp;#039;Hot&amp;#039;, &amp;#039;Scalding&amp;#039;, &amp;#039;Cold&amp;#039;, &amp;#039;Frostbite&amp;#039;,... etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I know that we can use pd.get_dummies to convert the column to numerical data within the dataframe, but I also know that there are other &amp;#039;converters&amp;#039; (not sure if that&amp;#039;s the correct terminology) that we can use, i.e. OneHotEncoder from Sk-learn (like I could use the pipeline module to make a nice pipeline and feed my dataframe through the pipeline to also get my categorical data encoded to numerical).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How do I know which to use? Does it matter? If it does matter, when does it matter the most (i.e. what types of problems? When there are lots of categorical variables, or few?) If anyone can give me any pointers on this type of stuff I&amp;#039;d greatly appreciate it.</description>
<category>Exploratory Data Analysis</category>
<guid isPermaLink="true">https://ask.ghassem.com/1006/know-which-encoder-convert-categorical-variables-numerical</guid>
<pubDate>Mon, 29 Nov 2021 04:09:06 +0000</pubDate>
</item>
<item>
<title>Can Data Science solve this problem?</title>
<link>https://ask.ghassem.com/1002/can-data-science-solve-this-problem</link>
<description>So, I live in Brazil, and I have a task for college that I don&amp;#039;t know what data science method to use, if at all, to solve it. My idea is the following: We Brazilians have Real (BRL) as currency, and we of course have the dollar quotation value to see &amp;quot;how many Reais a dollar is worth&amp;quot;. What I wanted to do was to make a research and see whether the Country News have any influence over this price. So for example, if Bolsonaro, our president, says some dumb stuff, the dollar got up in price, and vice versa. What I wanted to do was collect all dollar values and variance over a set time interval, and try and get webscraping to get the news over some economy sites. Here&amp;#039;s my question then: How can I correlate the news with the dollar variance over a set time? Can data science do that? How do I preprocess this, if at all? Do I need to use bag-of-words? At least I heard so... Please help and thank you for reading.</description>
<category>General</category>
<guid isPermaLink="true">https://ask.ghassem.com/1002/can-data-science-solve-this-problem</guid>
<pubDate>Sun, 24 Oct 2021 15:43:11 +0000</pubDate>
</item>
<item>
<title>how many samples do we need to test image segmentation using synthetic data ?</title>
<link>https://ask.ghassem.com/993/many-samples-need-test-image-segmentation-using-synthetic</link>
<description>Hello,&lt;br /&gt;
&lt;br /&gt;
I trained a CNN using synthetic data to perform a segmentation task on human faces. During the test and to evaluate the prediction of this network, I used 200 examples from the database to compute precision and recall.&lt;br /&gt;
&lt;br /&gt;
Is this number sufficient, knowing that I control myself the data generator and that I build the database by randomly drawing the elements using centered Gaussian distributions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thank you,</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/993/many-samples-need-test-image-segmentation-using-synthetic</guid>
<pubDate>Mon, 21 Jun 2021 12:26:32 +0000</pubDate>
</item>
<item>
<title>Can we have multiple target values in a ML problem dataset for supervised learning?</title>
<link>https://ask.ghassem.com/989/multiple-target-values-problem-dataset-supervised-learning</link>
<description></description>
<category>Machine Learning Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/989/multiple-target-values-problem-dataset-supervised-learning</guid>
<pubDate>Sun, 30 May 2021 16:31:48 +0000</pubDate>
</item>
<item>
<title>Intermittent Mathematics (Logarim)</title>
<link>https://ask.ghassem.com/986/intermittent-mathematics-logarim</link>
<description>&lt;p&gt;&lt;strong&gt;The old keypad of the telephone, it has 10 numbers (10 keys) , this keypad allows the user to enter a text by successively pressing certain key many times in a small period of time. you need to draw a graph of entering a text input using this keypad.&amp;nbsp; after that you need to have a certain algorithm of finding the length of a path to enter certain text&lt;br&gt;
example&amp;nbsp;&lt;br&gt;
aaa&amp;nbsp; &amp;nbsp;--&amp;gt; 6&lt;br&gt;
aba&amp;nbsp; &amp;nbsp;--&amp;gt; 5&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;the link below shows the phone keypad&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://commons.wikimedia.org/wiki/File:Telephone-keypad.png&quot;&gt;https://commons.wikimedia.org/wiki/File:Telephone-keypad.png&lt;/a&gt;&lt;br&gt;
&amp;nbsp;&lt;/p&gt;</description>
<category>Web Development</category>
<guid isPermaLink="true">https://ask.ghassem.com/986/intermittent-mathematics-logarim</guid>
<pubDate>Wed, 05 May 2021 12:16:20 +0000</pubDate>
</item>
<item>
<title>Very short text classification when category text should be replaced by another category text?</title>
<link>https://ask.ghassem.com/980/classification-category-should-replaced-another-category</link>
<description>&lt;div style=&quot;max-width:800px&quot;&gt;
&lt;div style=&quot;color:#1A1A1B&quot;&gt;
&lt;p&gt;I need some tool to classify articles based on short category text which consists of two or three words separated by &#039;-&#039;. The RSS/XML tag content is for example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Foreign - News&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;p&gt;Football - Foreign&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I created my own categories in DB and now I need to classify categories from parsed RSS of this news source, so it fits news categories defined by me.&lt;/p&gt;

&lt;p&gt;I would, for example need all articles containing category &quot;football&quot; to be identified as a category &lt;em&gt;Sport&lt;/em&gt; but sometimes those categories XML tags contains exact match like &lt;em&gt;Foreign - News&lt;/em&gt; should belong in the DB to category defined by me as &lt;em&gt;Foreign&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Since I used only trained decision trees frameworks from AI so for another project so far, I would like to hear advice about probably AI based approach, technique or particular framework I can use to solve this problem. I don&#039;t want to get into a dead-end street by my own poor, in the field of AI not very experienced decision.&lt;/p&gt;

&lt;p&gt;While it can be solved by many ifs and &#039;contains&#039; function, it seems to me like not a very good solution.&lt;/p&gt;

&lt;p&gt;TLDR; I need basically something like &quot;clever, flexible and universal if-elseif&quot;.&lt;/p&gt;

&lt;p&gt;NOTE: I can also use article description text, if that would be necessary but it seems to me that this former category text is &amp;nbsp;unambiguous enough for this kind of problem.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;</description>
<category>Artificial Intelligence</category>
<guid isPermaLink="true">https://ask.ghassem.com/980/classification-category-should-replaced-another-category</guid>
<pubDate>Thu, 11 Feb 2021 12:48:47 +0000</pubDate>
</item>
<item>
<title>Do  I need to save the standardization transformation?</title>
<link>https://ask.ghassem.com/970/do-i-need-to-save-the-standardization-transformation</link>
<description>When I standardized my data when I created my model. Do I need to save the standardization transformation when I want to predict with my model new data ?</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/970/do-i-need-to-save-the-standardization-transformation</guid>
<pubDate>Tue, 15 Dec 2020 13:06:48 +0000</pubDate>
</item>
<item>
<title>Why should I use Dynamic Time Warping over GMM for timer series clustering?</title>
<link>https://ask.ghassem.com/962/why-should-dynamic-time-warping-over-timer-series-clustering</link>
<description></description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/962/why-should-dynamic-time-warping-over-timer-series-clustering</guid>
<pubDate>Fri, 04 Dec 2020 03:19:16 +0000</pubDate>
</item>
<item>
<title>How to predict from unseen data?</title>
<link>https://ask.ghassem.com/954/how-to-predict-from-unseen-data</link>
<description>&lt;p&gt;Hi. I have a question about model-based predictions when data is only available after the fact.&amp;nbsp;Let me give you an example. I try to predict the result (HOME,&amp;nbsp;AWAY or a DRAW) of the match based on data like number of shots, ball possession, number of fouls, etc.&lt;/p&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot; style=&quot;width:500px&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th scope=&quot;col&quot;&gt;TARGET&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;TEAM 1&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;TEAM 2&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;
&lt;p&gt;possesion&lt;/p&gt;

&lt;p&gt;team 1&lt;/p&gt;
&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;
&lt;p&gt;possesion&lt;/p&gt;

&lt;p&gt;team 2&lt;/p&gt;
&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;
&lt;p&gt;shots&lt;/p&gt;

&lt;p&gt;team 1&lt;/p&gt;
&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;
&lt;p&gt;shots&lt;/p&gt;

&lt;p&gt;team 2&lt;/p&gt;
&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;
&lt;p&gt;fouls&lt;/p&gt;

&lt;p&gt;team 1&lt;/p&gt;
&lt;/th&gt;
&lt;th scope=&quot;col&quot;&gt;
&lt;p&gt;fouls&lt;/p&gt;

&lt;p&gt;team 2&lt;/p&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;HOME&lt;/td&gt;
&lt;td&gt;Arsenal&lt;/td&gt;
&lt;td&gt;Chelsea&lt;/td&gt;
&lt;td&gt;60&lt;/td&gt;
&lt;td&gt;40&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Let&#039;s say I&#039;m already after training the model and I want to see if I can predict the upcoming match. However, this match is only a few days away and I want to know the result of the model today.&amp;nbsp;I understand that if the match had already taken place and I had the data, I could test it on the model and get the result. The goal is for the model to predict what will happen before the match.&lt;/p&gt;

&lt;p&gt;Is it possible at all? What are my options? Should I only select pre-match variables? For example, last game form, match referee etc or should I aggregate the variables and include average possession, average shots and average number of fouls from recent matches?&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/954/how-to-predict-from-unseen-data</guid>
<pubDate>Tue, 17 Nov 2020 16:18:28 +0000</pubDate>
</item>
<item>
<title>How to model unknown yet data</title>
<link>https://ask.ghassem.com/943/how-to-model-unknown-yet-data</link>
<description>&lt;p&gt;So far, I have modeled on known historical data. What if there are variables known only after the fact?&lt;br&gt;
Let me give you an example. I want to predict the outcome of the match, win, lose or draw. I use variables from previous games such as ball possession, number of shots, corners, etc. Let&#039;s say the Chelsea-Arsenal game is approaching Saturday. How am I supposed to build a model and predict the result if this data is not yet available for my event? What to do in such cases, is it possible to forecast such data?&lt;/p&gt;

&lt;div id=&quot;gtx-trans&quot; style=&quot;position: absolute; left: -4px; top: -5.27273px;&quot;&gt;
&lt;div class=&quot;gtx-trans-icon&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/943/how-to-model-unknown-yet-data</guid>
<pubDate>Tue, 27 Oct 2020 10:39:47 +0000</pubDate>
</item>
<item>
<title>From microarray data, which tools of pattern recognition can you apply to identify the genes responsible for diseases?</title>
<link>https://ask.ghassem.com/936/microarray-pattern-recognition-identify-responsible-diseases</link>
<description>“During the last decade, the advent of microarray datasets stimulated a new line of research called Bioinformatics. A microarray database is a repository containing microarray gene expression data. Microarray data pose a great challenge for computational techniques, due to their large dimensionality (up to several tens of thousands of genes) and their sample sizes. Furthermore, additional experimental complications like noise and variability render the analysis of microarray data an exciting domain [Saeys et al. 2007, Bioinformatics]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In light of the aforesaid excerpt, from microarray data which tools of the pattern recognition can you apply to identify the genes responsible for diseases like cancer? Explain how.</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/936/microarray-pattern-recognition-identify-responsible-diseases</guid>
<pubDate>Thu, 15 Oct 2020 20:11:31 +0000</pubDate>
</item>
<item>
<title>Can we use a trained model to supervise the other machine learning models?</title>
<link>https://ask.ghassem.com/930/can-trained-model-supervise-other-machine-learning-models</link>
<description>Is that possible to train a machine using another trained machine?</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/930/can-trained-model-supervise-other-machine-learning-models</guid>
<pubDate>Mon, 28 Sep 2020 14:17:37 +0000</pubDate>
</item>
<item>
<title>Where can I find illustrative real life machine learning examples (In business,  work. etc.)?</title>
<link>https://ask.ghassem.com/924/where-find-illustrative-machine-learning-examples-business</link>
<description>Is there a website for finding illustrative real-life examples of using machine learning? For instance: for End to End Machine Learning, End to End Machine Learning, Classification, Clustering, and Unsupervised Learning.</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/924/where-find-illustrative-machine-learning-examples-business</guid>
<pubDate>Tue, 22 Sep 2020 00:47:09 +0000</pubDate>
</item>
<item>
<title>Where can I find simple machine learning mathematics explained visually?</title>
<link>https://ask.ghassem.com/923/where-simple-machine-learning-mathematics-explained-visually</link>
<description>Could you please let me know where I can find simple machine learning mathematics explained visually?</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/923/where-simple-machine-learning-mathematics-explained-visually</guid>
<pubDate>Mon, 21 Sep 2020 23:55:12 +0000</pubDate>
</item>
<item>
<title>How to update the weights in backpropagation algorithm when activation function in not linear?</title>
<link>https://ask.ghassem.com/901/update-weights-backpropagation-algorithm-activation-function</link>
<description>&lt;p&gt;The goal of backpropagation is to optimize the weights so that the neural network can learn how to correctly map arbitrary inputs to outputs.&lt;/p&gt;

&lt;p&gt;Assume for the following neural network, inputs = [$i_1,i_2$] = [0.05,&amp;nbsp;0.10], we want the neural network to output = [$o_1$,$o_2$] = [0.01,&amp;nbsp;0.99], and&amp;nbsp;for learning rate, $\alpha=0.5$.&lt;br&gt;
In addition, the activation function for the hidden layer (both $h_1$ and $h_2$)&amp;nbsp;is sigmoid (logistic):&lt;/p&gt;

&lt;p&gt;$S(x)=\frac{1}{1+e^{-x}}$&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://i.imgur.com/cnY5feu.png&quot;&gt;https://i.imgur.com/cnY5feu.png&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hint:&lt;/strong&gt;&lt;br&gt;
$w_{new} = w_{old} - \alpha \frac{\partial E}{\partial w}$&lt;/p&gt;

&lt;p&gt;$E_{\text {total}}=\sum \frac{1}{2}(\text {target}-\text {output})^{2}$&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;a) &lt;/strong&gt;Show step by step solution to&amp;nbsp;calculate weights $w_1$ to $w_8$ after one update in table below.&lt;br&gt;
&lt;strong&gt;b) &lt;/strong&gt;Calculate initial error and error after one update (assume&amp;nbsp;biases $[b_1,b_2]$ are not changing during the updates).&lt;/p&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot;&gt;
&lt;caption&gt;Updating weights in backpropagation algorithm&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Weights&lt;/td&gt;
&lt;td&gt;Initialization&lt;/td&gt;
&lt;td&gt;New weights after one step&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w1$&lt;/td&gt;
&lt;td&gt;0.15&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w2$&lt;/td&gt;
&lt;td&gt;0.20&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w3$&lt;/td&gt;
&lt;td&gt;0.25&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w4$&lt;/td&gt;
&lt;td&gt;0.30&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w5$&lt;/td&gt;
&lt;td&gt;0.40&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w6$&lt;/td&gt;
&lt;td&gt;0.45&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w7$&lt;/td&gt;
&lt;td&gt;0.50&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$w8$&lt;/td&gt;
&lt;td&gt;0.55&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/901/update-weights-backpropagation-algorithm-activation-function</guid>
<pubDate>Mon, 10 Aug 2020 21:55:19 +0000</pubDate>
</item>
<item>
<title>How to calculate the class probabilities and classify using Naive Bayes classifier?</title>
<link>https://ask.ghassem.com/899/calculate-class-probabilities-classify-using-classifier</link>
<description>&lt;p&gt;We have data on 1000 pieces of fruit. The fruit being a Banana, Orange or some Other fruit and imagine we know 3 features of each fruit, whether it’s long or not, sweet or not and yellow or not, as displayed in the table below:&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://i.imgur.com/gOFzVXL.png&quot;&gt;https://i.imgur.com/gOFzVXL.png&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A&amp;nbsp;piece of an unknown fruit with these features are provided:&amp;nbsp;Long, Sweet and Yellow.&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calculate probability of each of these 3 classes based on Naive Bayes Classification algorithm and report the class.&lt;/strong&gt;&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/899/calculate-class-probabilities-classify-using-classifier</guid>
<pubDate>Mon, 10 Aug 2020 21:26:28 +0000</pubDate>
</item>
<item>
<title>How to print confusion matrix if I am using stratifiedkfold method?</title>
<link>https://ask.ghassem.com/894/how-to-print-confusion-matrix-using-stratifiedkfold-method</link>
<description></description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/894/how-to-print-confusion-matrix-using-stratifiedkfold-method</guid>
<pubDate>Thu, 06 Aug 2020 21:41:19 +0000</pubDate>
</item>
<item>
<title>How to split into train and test using PKL file?</title>
<link>https://ask.ghassem.com/892/how-to-split-into-train-and-test-using-pkl-file</link>
<description></description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/892/how-to-split-into-train-and-test-using-pkl-file</guid>
<pubDate>Thu, 30 Jul 2020 22:08:47 +0000</pubDate>
</item>
<item>
<title>What is difference between Support vector machine and Support Vector Classification?</title>
<link>https://ask.ghassem.com/863/difference-between-support-machine-support-classification</link>
<description></description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/863/difference-between-support-machine-support-classification</guid>
<pubDate>Wed, 13 May 2020 20:22:23 +0000</pubDate>
</item>
<item>
<title>guidance on sequencing data science courses below</title>
<link>https://ask.ghassem.com/844/guidance-on-sequencing-data-science-courses-below</link>
<description>Hello&lt;br /&gt;
my name is lutaaya mudathiru.&lt;br /&gt;
&lt;br /&gt;
I am planning to start data science online&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;professional courses at Harvard&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;University, but i don&amp;#039;t know which course &amp;nbsp;i should begin with . I request for help in sequencing these courses below so that i can&lt;br /&gt;
&lt;br /&gt;
benefitt more:&lt;br /&gt;
&lt;br /&gt;
1. Principles, Statistical and Computational Tools for Reproducible Science.&lt;br /&gt;
&lt;br /&gt;
2.Data Science: Inference and Modeling.&lt;br /&gt;
&lt;br /&gt;
3. Data Science: Productivity Tools&lt;br /&gt;
&lt;br /&gt;
4.Data Science: Wrangling&lt;br /&gt;
&lt;br /&gt;
5.Data Science: Linear Regression.&lt;br /&gt;
&lt;br /&gt;
6.Data Science: Machine Learning&lt;br /&gt;
&lt;br /&gt;
7.Data Science: Capstone&lt;br /&gt;
&lt;br /&gt;
8. Data Science: R Basics&lt;br /&gt;
&lt;br /&gt;
9.DataScience:Visualization&lt;br /&gt;
&lt;br /&gt;
10. DataScience:Probability.&lt;br /&gt;
&lt;br /&gt;
11. High-Dimensional Data Analysis&lt;br /&gt;
&lt;br /&gt;
12. Introduction to Linear Models and Matrix Algebra&lt;br /&gt;
&lt;br /&gt;
13. Data science:Statistics and R&lt;br /&gt;
&lt;br /&gt;
14. Fat Chance: Probability from the Ground Up&lt;br /&gt;
&lt;br /&gt;
15. Introduction to Probability (on edX)</description>
<category>Data Science</category>
<guid isPermaLink="true">https://ask.ghassem.com/844/guidance-on-sequencing-data-science-courses-below</guid>
<pubDate>Fri, 20 Mar 2020 13:55:49 +0000</pubDate>
</item>
<item>
<title>What are the differences among Data Science, Artificial Intelligence and Machine Learning?</title>
<link>https://ask.ghassem.com/842/differences-science-artificial-intelligence-machine-learning</link>
<description>What are the differences among Data Science, Artificial Intelligence and Machine Learning?</description>
<category>General</category>
<guid isPermaLink="true">https://ask.ghassem.com/842/differences-science-artificial-intelligence-machine-learning</guid>
<pubDate>Thu, 05 Mar 2020 03:02:31 +0000</pubDate>
</item>
<item>
<title>Can PCA be used for supervised learning?</title>
<link>https://ask.ghassem.com/832/can-pca-be-used-for-supervised-learning</link>
<description>Can PCA be used for supervised learning???&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ve seen some data scientists using PCA to transform their data for only numerical variables.&lt;br /&gt;
&lt;br /&gt;
However, some other data scientists say that it is only used for unsupervised ML techniques.</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/832/can-pca-be-used-for-supervised-learning</guid>
<pubDate>Tue, 18 Feb 2020 21:49:18 +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>Can I use a single Pipeline for multiple estimators in scikit-learn?</title>
<link>https://ask.ghassem.com/819/can-use-single-pipeline-for-multiple-estimators-scikit-learn</link>
<description>Is there any proper way to combine multiple classifiers and their parameter grids in one Pipeline?</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/819/can-use-single-pipeline-for-multiple-estimators-scikit-learn</guid>
<pubDate>Tue, 18 Feb 2020 14:14:30 +0000</pubDate>
</item>
<item>
<title>How can I find the &quot;Sate of the art&quot; approaches in Machine Learning?</title>
<link>https://ask.ghassem.com/801/how-can-find-the-sate-of-the-art-approaches-machine-learning</link>
<description>If I want to find the latest trends in Machine Learning and best approaches known as the &amp;quot;State of the art&amp;quot; approach, what resources I can use?</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/801/how-can-find-the-sate-of-the-art-approaches-machine-learning</guid>
<pubDate>Sat, 08 Feb 2020 00:56:39 +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>score() vs accuracy_score() in sklearn</title>
<link>https://ask.ghassem.com/777/score-vs-accuracyscore-in-sklearn</link>
<description>Hi,&lt;br /&gt;
&lt;br /&gt;
Since I still have confuse to use the score() &amp;nbsp;and accuracy_score(), so I want to confirm my test assumption.&lt;br /&gt;
Q1: score(), we use the split data to test the accuracy by knn.score(X_test, y_test) to prevent bias using the same training data, right? here knn.score(X_test, y_test) just compare the pair of test value.&lt;br /&gt;
&lt;br /&gt;
Q2: accuracy_score from sklearn.metrics to test the predicted output of target value &amp;quot;y_pred&amp;quot; with the y_test, using accuracy_score(y_test, y_pred), just compare the actual target value and predicted target value?&lt;br /&gt;
&lt;br /&gt;
Q3.My result is the same after using both methods, are they doing the same thing?&lt;br /&gt;
&lt;br /&gt;
Q4.using accuracy_score(), I can using to compare the split training target data y_train with the y_train_pred(return form knn.predict(X_train) ). Then it should be OK now, using it to show the accuracy by accuracy_score(y_train, y_train_pred), since the prediction is done and just compare the original data, then the bias does not exist?&lt;br /&gt;
&lt;br /&gt;
Thanks.</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/777/score-vs-accuracyscore-in-sklearn</guid>
<pubDate>Tue, 21 Jan 2020 21:28:11 +0000</pubDate>
</item>
<item>
<title>Best algorithm for table reservation</title>
<link>https://ask.ghassem.com/733/best-algorithm-for-table-reservation</link>
<description>What kind of algorithm would best for following problem.&lt;br /&gt;
I try to forecast reservation of different kind of tables. Let&amp;#039;s say I have 100 different tables, which are reserved for from 17.00-22.00 daily. Each table is either reserved (1) or available (0) on certain hour. &amp;nbsp;I&amp;#039;m interested in to forecast each table based on history data from 2 previous weeks. So for example result is that tomorrow 18.00-19.00 certain table is either 0 (available) or 1 (reserved).</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/733/best-algorithm-for-table-reservation</guid>
<pubDate>Mon, 21 Oct 2019 18:03:19 +0000</pubDate>
</item>
<item>
<title>What are the types of Classification and regression algorithms in Machine learning ?</title>
<link>https://ask.ghassem.com/660/types-classification-regression-algorithms-machine-learning</link>
<description>For example, Logistic regression is classification likewise what are the other types? I am a bit confused.</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/660/types-classification-regression-algorithms-machine-learning</guid>
<pubDate>Thu, 27 Jun 2019 21:00:05 +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 the class probabilities and classify using Naive Bayes classifier for NLP?</title>
<link>https://ask.ghassem.com/654/calculate-class-probabilities-classify-using-classifier</link>
<description>&lt;p&gt;We want to use Naive Bayes for tagging documents. It is a classification task that we want to assign a class (tag) to each string. We currently have two tags: &lt;strong&gt;Sport &lt;/strong&gt;and&lt;strong&gt; &lt;/strong&gt;&lt;strong&gt;Not Sport&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Which tag does the sentence&amp;nbsp;&lt;strong&gt;&lt;em&gt;A very close game&lt;/em&gt;&amp;nbsp;&lt;/strong&gt;belong to? Using Naive Bayes classifier, calculate the class probability for &lt;strong&gt;Sport&lt;/strong&gt; and &lt;strong&gt;Not sport &lt;/strong&gt;for this sentence based on&amp;nbsp;the dataset and decide about the tag.&lt;/p&gt;

&lt;table border=&quot;1px&quot; cellpadding=&quot;1px&quot; style=&quot;width:500px&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Text&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Tag&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;“A great game”&lt;/td&gt;
&lt;td&gt;Sports&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;“The election was over”&lt;/td&gt;
&lt;td&gt;Not sports&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;“Very clean match”&lt;/td&gt;
&lt;td&gt;Sports&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;“A clean but forgettable game”&lt;/td&gt;
&lt;td&gt;Sports&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;“It was a close election”&lt;/td&gt;
&lt;td&gt;Not sports&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/654/calculate-class-probabilities-classify-using-classifier</guid>
<pubDate>Wed, 26 Jun 2019 19:43:41 +0000</pubDate>
</item>
<item>
<title>How to calculate Covariance Matrix and Principal Components for PCA?</title>
<link>https://ask.ghassem.com/652/how-calculate-covariance-matrix-and-principal-components</link>
<description>&lt;p&gt;The dataset with two features $(x,y)$ is shown as follows (note $y$ in this example is the second feature, not a target value):&lt;/p&gt;

&lt;table border=&quot;01&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:50px&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;x&lt;/th&gt;
&lt;th&gt;y&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2.5&lt;/td&gt;
&lt;td&gt;2.4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.5&lt;/td&gt;
&lt;td&gt;0.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2.2&lt;/td&gt;
&lt;td&gt;2.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1.9&lt;/td&gt;
&lt;td&gt;2.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.1&lt;/td&gt;
&lt;td&gt;3.0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2.3&lt;/td&gt;
&lt;td&gt;2.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2.0&lt;/td&gt;
&lt;td&gt;1.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1.0&lt;/td&gt;
&lt;td&gt;1.1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1.5&lt;/td&gt;
&lt;td&gt;1.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1.1&lt;/td&gt;
&lt;td&gt;0.9&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;a) Calculate the Covariance Matrix.&lt;br&gt;
b) Calculate eigenvalues and eigenvectors&lt;br&gt;
c) Calculate all the PCs&lt;br&gt;
d) How much percent of the total variance in the dataset is explained by each PC?&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/652/how-calculate-covariance-matrix-and-principal-components</guid>
<pubDate>Wed, 26 Jun 2019 10:40:02 +0000</pubDate>
</item>
<item>
<title>How to calculate convolutions on a CONV layer for a Convolutional Neural Network?</title>
<link>https://ask.ghassem.com/650/calculate-convolutions-layer-convolutional-neural-network</link>
<description>&lt;p&gt;Assume we have a $5\times5$ px&amp;nbsp;RGB image with 3&amp;nbsp;channels respectively for R, G, and B. If&lt;/p&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:100px&quot;&gt;
&lt;caption&gt;R&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&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;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&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;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&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;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:100px&quot;&gt;
&lt;caption&gt;G&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&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;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&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;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:100px&quot;&gt;
&lt;caption&gt;B&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&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;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&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;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&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;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&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;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We have one&amp;nbsp;$3\times3$ px kernel (filter) with 3 channels as follows:&lt;/p&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:100px&quot;&gt;
&lt;caption&gt;Filter - R&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&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;1&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;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:100px&quot;&gt;
&lt;caption&gt;Filter - G&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;-1&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;0&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;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:100px&quot;&gt;
&lt;caption&gt;Filter - B&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&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;-1&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;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;a)&lt;/strong&gt; If&amp;nbsp;&lt;strong&gt;Stride = 2&lt;/strong&gt;,&lt;strong&gt; &lt;/strong&gt;and&lt;strong&gt;&amp;nbsp;Zero-padding = 1&lt;/strong&gt;, and &lt;strong&gt;Bias&amp;nbsp;= 1&lt;/strong&gt;, what will be the result of convolution?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b)&lt;/strong&gt; What is the result after applying a &lt;strong&gt;ReLU&amp;nbsp;layer ($max(z,0)$)&lt;/strong&gt;on the result with the same size of the reuslt&amp;nbsp;in part a?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c)&lt;/strong&gt; Calculate the output&amp;nbsp;by applying &lt;strong&gt;max-pooling&lt;/strong&gt; layer with the size of $2\times2$ on the output of part b, and &lt;strong&gt;Stride = 1&lt;/strong&gt;. (hint: max-pooling layer here and&amp;nbsp;usually do not include any zero-paddings)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d)&lt;/strong&gt; What is the result after applying &lt;strong&gt;flatten&lt;/strong&gt; on the output of part c and creating a vector?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e)&lt;/strong&gt; Assume the vector you created contains m elements. Consider it as the input vector for a &lt;strong&gt;Softmax&lt;/strong&gt; &lt;strong&gt;Regression classifier&amp;nbsp;&lt;/strong&gt;(without any hidden layers and biases and it is fully connected). Assume there are 2 classes of 0 and 1. For all the weights from&amp;nbsp;each element in the feature vector, the optimized weights are 1 for odd elements and 2 for even elements. For example, if the feature vector is [10,11,12,13,14], all the weights &lt;strong&gt;from &lt;/strong&gt;10 are 1 (because 10 is element 1 and 1 is odd), all the weights &lt;strong&gt;from&lt;/strong&gt; 11 are 2, all the weights &lt;strong&gt;from&lt;/strong&gt; 12 are&amp;nbsp;1, all the weights &lt;strong&gt;from&lt;/strong&gt; 13 are&amp;nbsp;2 and all the weights &lt;strong&gt;from&lt;/strong&gt; 14 are 1 and so on. Draw the&amp;nbsp;Softmax&amp;nbsp;Regression network and calculate the class should be 0 or 1?&lt;/p&gt;

&lt;p&gt;Hint:&amp;nbsp;&lt;br&gt;
&lt;strong&gt;Softmax Regression:&lt;/strong&gt;&amp;nbsp;$p_{i}=\frac{e^{z_{i}}}{\sum_{i=1}^{c} e^{z_{i}}}$&lt;br&gt;
Where $p_{i}$ is the probability of class $i$ anc $c$ is the number of classes.&lt;/p&gt;</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/650/calculate-convolutions-layer-convolutional-neural-network</guid>
<pubDate>Wed, 26 Jun 2019 08:54:12 +0000</pubDate>
</item>
<item>
<title>What is the difference between cross-validation and validation set?</title>
<link>https://ask.ghassem.com/648/what-the-difference-between-cross-validation-and-validation</link>
<description>&lt;p&gt;I am confused about this figure. Is not this&amp;nbsp;a cross-validation test or we have a fixed few examples for which it is tested while you also have various folds being tested at the same time?&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://i.imgur.com/aVru1MX.png&quot;&gt;https://i.imgur.com/aVru1MX.png&lt;/a&gt;&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/648/what-the-difference-between-cross-validation-and-validation</guid>
<pubDate>Wed, 19 Jun 2019 18:39:39 +0000</pubDate>
</item>
<item>
<title>In DBSCAN algorithm, how should we choose optimal eps and minimum points?</title>
<link>https://ask.ghassem.com/646/dbscan-algorithm-how-should-choose-optimal-minimum-points</link>
<description></description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/646/dbscan-algorithm-how-should-choose-optimal-minimum-points</guid>
<pubDate>Thu, 13 Jun 2019 17:22:08 +0000</pubDate>
</item>
<item>
<title>How to optimize weights in Logistic Regression?</title>
<link>https://ask.ghassem.com/639/how-to-optimize-weights-in-logistic-regression</link>
<description>&lt;p&gt;The hypothesis (model) of Logistic Regression which is a binary classifier&amp;nbsp;( $y =\{0,1\} $) is given in the equation below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hypothesis&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;$S(z)=P(y=1 | x)=h_{\theta}(x)=\frac{1}{1+\exp \left(-\theta^{\top} x\right)}$&lt;/p&gt;

&lt;p&gt;Which calculates probability of Class 1, and by setting a threshold (such as $h_{\theta}(x) &amp;gt; 0.5 $) we can classify to 1, or 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cost function&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The cost function for Logistic Regression is defined as below. It is called&amp;nbsp;&lt;em&gt;binary cross entropy loss function&lt;/em&gt;&lt;strong&gt;:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;$J(\theta)=-\frac{1}{m} \sum_{i}^{m}\left(y^{(i)} \log \left(h_{\theta}\left(x^{(i)}\right)\right)+\left(1-y^{(i)}\right) \log \left(1-h_{\theta}\left(x^{(i)}\right)\right)\right)$&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Iterative updates&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Assume we start all the model parameters&amp;nbsp;with a random number (in this case the only model parameters we have are&amp;nbsp;$\theta_j$ and assume we initialized all of them with 1:&amp;nbsp;&amp;nbsp;for all $\theta_j = 1$ for $j=\{0,1,...,n\}$ and $n$ is the number of features we have)&lt;/p&gt;

&lt;p&gt;$\theta_{j_{n e w}} \leftarrow \theta_{j_{o l d}}+\alpha \times \frac{1}{m} \sum_{i=1}^{m}\left[y^{(i)}-\sigma\left(\theta_{j_{o l d}}^{\top}\left(x^{(i)}\right)\right)\right] x_{j}^{(i)}$&lt;/p&gt;

&lt;p&gt;Where:&lt;br&gt;
$m =$ number of rows in the training batch&lt;br&gt;
$x^{(i)} = $ the feature &lt;em&gt;vector&lt;/em&gt; for sample $i$&lt;br&gt;
$\theta_j = $ the coefficient &lt;em&gt;vector &lt;/em&gt;corresponding the features&lt;br&gt;
$y^{(i)} = $ actual class label for sample $i$ in the training batch&lt;br&gt;
$x_{j}^{(i)} = $ the element (column) $j$ in&amp;nbsp;the feature &lt;em&gt;vector&lt;/em&gt; for sample $i$&lt;br&gt;
$\alpha =$ the learning rate&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dataset&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The training dataset of pass/fail in an exam for 5 students is given in the table below:&lt;br&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;If we initialize all the model parameters with 1 (all $\theta_j = 1$), and the learning rate is $\alpha = 0.1$, and if we use &lt;strong&gt;batch gradient descent&lt;/strong&gt;, what will be the:&lt;/p&gt;

&lt;p&gt;$a)$ Accuracy of the model at initialization of the train set ($\text{accuracy} = \frac{\text{number of correct classifications}}{\text{all classifications}}$)?&lt;br&gt;
$b)$&amp;nbsp;Cost at initialization?&lt;br&gt;
$c)$ Cost after 1 epoch?&lt;br&gt;
$d)$ Repeat all $a,b,c$ steps if we use &lt;strong&gt;mini-batch gradient descent &lt;/strong&gt;and&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;$\text{batch size} = 2$&lt;/p&gt;

&lt;p&gt;(Hint: For $x_{j}^{(i)}$ when $j=0$ we have&amp;nbsp;$x_{0}^{(i)}&amp;nbsp; = 1$ for all $i$ )&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/639/how-to-optimize-weights-in-logistic-regression</guid>
<pubDate>Wed, 05 Jun 2019 17:38:50 +0000</pubDate>
</item>
<item>
<title>Could you please explain math symbols behind Machine Learning equations?</title>
<link>https://ask.ghassem.com/631/please-explain-symbols-behind-machine-learning-equations</link>
<description></description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/631/please-explain-symbols-behind-machine-learning-equations</guid>
<pubDate>Sat, 18 May 2019 19:56:35 +0000</pubDate>
</item>
<item>
<title>How do I Plot the linear classifier calculated with LIBLINEAR using sklearn?</title>
<link>https://ask.ghassem.com/629/plot-linear-classifier-calculated-liblinear-using-sklearn</link>
<description>Make a scatter plot where the x-axis is the height of the citizens and the y-axis is the weight of the citizens. The color of the points need to be different for males and females. In the same figure, plot the linear classifier calculated with LIBLINEAR using sklearn</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/629/plot-linear-classifier-calculated-liblinear-using-sklearn</guid>
<pubDate>Thu, 16 May 2019 08:13:06 +0000</pubDate>
</item>
<item>
<title>is impossible predict hours time series to minutes time series?</title>
<link>https://ask.ghassem.com/625/is-impossible-predict-hours-time-series-minutes-time-series</link>
<description>&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://stackoverflow.com/questions/55930051/is-impossible-predict-hours-time-series-to-minutes-time-series&quot;&gt;https://stackoverflow.com/questions/55930051/is-impossible-predict-hours-time-series-to-minutes-time-series&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i want to this hours time series predict model to minute predict model&lt;/p&gt;</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/625/is-impossible-predict-hours-time-series-minutes-time-series</guid>
<pubDate>Wed, 01 May 2019 13:11:26 +0000</pubDate>
</item>
</channel>
</rss>