<?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 Sudhir Kumar Rai on Medium]]></title>
        <description><![CDATA[Stories by Sudhir Kumar Rai on Medium]]></description>
        <link>https://medium.com/@srai7785?source=rss-e0b826209e58------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QotUZSd22aNE35sBVPMg_Q.jpeg</url>
            <title>Stories by Sudhir Kumar Rai on Medium</title>
            <link>https://medium.com/@srai7785?source=rss-e0b826209e58------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 10:30:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@srai7785/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[Long Before LLM’s, there were “Only” “Language Models”!]]></title>
            <link>https://medium.com/@srai7785/all-about-basics-of-numpy-d9a25eab1934?source=rss-e0b826209e58------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9a25eab1934</guid>
            <dc:creator><![CDATA[Sudhir Kumar Rai]]></dc:creator>
            <pubDate>Mon, 12 Feb 2024 05:27:54 GMT</pubDate>
            <atom:updated>2024-02-12T05:32:09.410Z</atom:updated>
            <content:encoded><![CDATA[<p>The AI and NLP industry is a Buzz these days with LLM a.k.a “Large Language Models”. The tech industry tends to get carried away by big terminologies like LLM, Deep Learning, etc. Hence it is important to simplify some of these buzzwords.</p><p>Through this post, I will explain a simple language modeling approach to build a Q&amp;A system like Quora.</p><p>Approach</p><ol><li>Calculate the probability of a “Term” coming from a document.</li><li>Calculate the probability of a “Term” coming from a corpus.</li><li>Take the weighted sum of the above probabilities. This weight coefficient (Lambda) is a tunable parameter.</li><li>Repeat 1–4 for every term in a “Query” for each document in the corpus.</li><li>Multiply the joint probability of each term in a query to get the probability of a “Query” coming from a document in the corpus.</li><li>Rank-order the documents based on the probability.</li><li>These top documents are your desired matching posts.</li></ol><p>The diagram Describes the approach:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nkbywo-lrNp13eMuDyLnig.png" /></figure><p>Jupyter Notebook Code to do some hands-on practice</p><h3>1. Import Required Packages</h3><pre>### Import All librarries required for data processing<br>import time<br>import pandas as pd<br>import re<br>import string<br>from nltk.tokenize import word_tokenize<br>from nltk.corpus import stopwords<br>from nltk.stem import PorterStemmer<br>from nltk.stem import WordNetLemmatizer <br>import numpy as np<br>#from nltk.book import *<br>from wordcloud import WordCloud<br>import matplotlib.pyplot as plt<br>from sklearn.feature_extraction.text import CountVectorizer<br>import textblob<br>from textblob import TextBlob<br>from sklearn.model_selection import train_test_split</pre><h3>2. Load Text Corpus</h3><pre>## Import text data in pandas data frame<br>Docuemnt_Corpus=pd.read_csv(&quot;Document_Corpus.csv&quot;)</pre><h3>3. Utility Functions</h3><h4>3.1. Corpus Processing Function</h4><pre>## Function to calculate count of terms in the entire corpus and sum of all counts in corpus<br>def corpus_word_count(df, text_col):<br>    vec = CountVectorizer(stop_words = &#39;english&#39;).fit(df[text_col])<br>    bag_of_words = vec.transform(df[text_col])<br>    sum_words = bag_of_words.sum(axis=0) <br>    words_freq = [(word, sum_words[0, idx]) for word, idx in vec.vocabulary_.items()]<br>    words_freq =sorted(words_freq, key = lambda x: x[1], reverse=True)<br>    Term_list=[]<br>    Count_list=[]<br>    for i in range(len(words_freq)):<br>        Term_list.append(words_freq[i][0])<br>        Count_list.append(words_freq[i][1])<br>    Corpus_Word_Count_dict = dict(zip(Term_list, Count_list))<br>    Corpus_total_word_count=np.sum(Count_list)<br>    return Corpus_Word_Count_dict,Corpus_total_word_count</pre><h4>3.2. Document Processing Function</h4><pre>## This function will be called for each document duirng probability calculation<br>## This function returns a dictionary of terms and their count in a given document<br>## and sum of count of all the terms in the document.<br>def process_doc(doc):<br>    #doc=[doc]<br>    vecd = CountVectorizer(stop_words = &#39;english&#39;).fit(doc)<br>    bag_of_wordsd = vecd.transform(doc)<br>    sum_wordsd = bag_of_wordsd.sum(axis=0) <br>    words_freqd = [(word, sum_wordsd[0, idx]) for word, idx in vecd.vocabulary_.items()]<br>    words_freqd =sorted(words_freqd, key = lambda x: x[1], reverse=True)<br>    doc_Term_list=[]<br>    doc_Count_list=[]<br>    for i in range(len(words_freqd)):<br>        doc_Term_list.append(words_freqd[i][0])<br>        doc_Count_list.append(words_freqd[i][1])<br>    Doc_Word_Count_dict = dict(zip(doc_Term_list, doc_Count_list))<br>    Doc_total_word_count=np.sum(doc_Count_list)<br>    return Doc_Word_Count_dict,Doc_total_word_count</pre><h4>3.3. Query Processing Function</h4><pre>## Function to apply preprocesing to the query. Same pre-processing that is applied to train data<br>## This function will return tokenized query after basic preprocessing like removing stopwards<br>def pre_process_query(query):<br>    query=query.values<br>    v=CountVectorizer(stop_words = &#39;english&#39;).fit(query)<br>    bw=v.transform(query)<br>    sw=bw.sum(axis=0)<br>    wf=[(word, sw[0, idx]) for word, idx in v.vocabulary_.items()]<br>    QTerm_list=[]<br>    for i in range(len(wf)):<br>        QTerm_list.append(wf[i][0])<br>    return QTerm_list</pre><h4>3.4. Query Matching Score Calculation Function</h4><pre>## Calculate the query matching probability score for each query with all the documents in the corpus<br>def calculate_score(QTerm_list,Corpus_Word_Count_dict,Corpus_total_word_count,df,text_col,lmbda=0.6):<br>## These two blank lists are used to store document id and respective probability score for a given query<br>    docID=[]<br>    P_Score=[]<br>## A count k to count document id<br>    k=0<br>## Loop over each document in the corpus and calculate probability of query being generated from the document    <br>    for doc in df[text_col]:<br>        doc=[doc]<br>## Get the dictionary of wrods and count in the document and total count of word in the document<br>        Doc_Word_Count_dict,Doc_total_word_count=process_doc(doc)<br>## Initialize the query probability for the document<br>        Query_p=1<br>## Calculate the probability of each term in the query coming from document<br>        for term in QTerm_list:<br>## Check if query term is in the document dictionary, if yes then get the count else count=0            <br>            if(term in Doc_Word_Count_dict.keys()):<br>                term_cnt_doc=Doc_Word_Count_dict[term]<br>            else:<br>                term_cnt_doc=0<br>## Check if query term is in the corpus dictionary, if yes then get the count else count=0 <br>            if(term in Corpus_Word_Count_dict.keys()):<br>                term_cnt_cor=Corpus_Word_Count_dict[term]<br>            else:<br>                term_cnt_cor=0<br>## Calculate the probability of a term in query coming from the document                <br>            termp=(term_cnt_doc/Doc_total_word_count) * lmbda + (term_cnt_cor/Corpus_total_word_count) * (1-lmbda)<br>## Multiply the probability of each term in the query coming from a document            <br>            Query_p=Query_p*termp<br>## Update the probability of query coming from one document in the list<br>## Repeat this excercise for each document in the corpus for a given query<br>        P_Score.append(Query_p)<br>## Append the document id to keep track of matching document        <br>        docID.append(k)<br>        k=k+1<br>## Create pandas data frame by concatinating score and document id<br>    Final_Score=pd.concat([pd.DataFrame(P_Score),pd.DataFrame(docID)],axis=1)<br>    Final_Score.columns=[&#39;P_Score&#39;,&#39;Doc_ID&#39;]<br>## Sort the dataframe with highest to lowest probability<br>    Final_Score=Final_Score.sort_values(by=[&#39;P_Score&#39;],ascending=False)<br>    return Final_Score</pre><h3>4. Query Matching and Score Calculation</h3><pre>### Query matching on first dataset for 4 queries<br><br>#train1, test1 = train_test_split(D1, test_size=0.05, random_state=10)<br>#Corpus_Word_Count_dict_D1,Corpus_total_word_count_D1=corpus_word_count(train1,&#39;Body&#39;)<br>## Getting matching score for 1st query<br>Q1_D1=test1[&#39;Body&#39;].sample(n=1,random_state=10)<br>Q1_list_D1=pre_process_query(Q1_D1)<br>Final_Score_D1_Q1=calculate_score(Q1_list_D1,Corpus_Word_Count_dict_D1,Corpus_total_word_count_D1,train1,&#39;Body&#39;)<br>## Getting matching score for 2nd query<br>Q2_D1=test1[&#39;Body&#39;].sample(n=1,random_state=80)<br>Q2_list_D1=pre_process_query(Q2_D1)<br>Final_Score_D1_Q2=calculate_score(Q2_list_D1,Corpus_Word_Count_dict_D1,Corpus_total_word_count_D1,train1,&#39;Body&#39;)<br><br>## Getting matching score for 3rd query<br>Q3_D1=test1[&#39;Body&#39;].sample(n=1)<br>Q3_list_D1=pre_process_query(Q3_D1)<br>Final_Score_D1_Q3=calculate_score(Q3_list_D1,Corpus_Word_Count_dict_D1,Corpus_total_word_count_D1,train1,&#39;Body&#39;)<br><br>## Getting matching score for 4th query<br>Q4_D1=test1[&#39;Body&#39;].sample(n=1,random_state=100)<br>Q4_list_D1=pre_process_query(Q4_D1)<br>Final_Score_D1_Q4=calculate_score(Q4_list_D1,Corpus_Word_Count_dict_D1,Corpus_total_word_count_D1,train1,&#39;Body&#39;)</pre><h3>5. Print the Top 5 posts matching the query</h3><pre>### Printing queries and top 5 matching posts based on score for dataset 1<br>print(&#39;First Query is: &#39;)<br>print(Q1_D1.values)<br>print(&#39;Tokenized query is:&#39;)<br>print(Q1_list_D1)<br>print(&#39;Top 5 Matching posts  for Query1 are: &#39;)<br>for Doc_ID in Final_Score_D1_Q1.head(5)[&#39;Doc_ID&#39;]:<br>    print(Doc_ID)<br>    print(list(train1.iloc[Doc_ID,:]))<br>print(&#39;Second Query is: &#39;)<br>print(Q2_D1.values)<br>print(&#39;Tokenized query is:&#39;)<br>print(Q2_list_D1)<br>print(&#39;Top 5 Matching posts  for Query2 are: &#39;)<br>for Doc_ID in Final_Score_D1_Q2.head(5)[&#39;Doc_ID&#39;]:<br>    print(Doc_ID)<br>    print(list(train1.iloc[Doc_ID,:]))<br>print(&#39;Third Query is: &#39;)<br>print(Q3_D1.values)<br>print(&#39;Tokenized query is:&#39;)<br>print(Q3_list_D1)<br>print(&#39;Top 5 Matching posts  for Query3 are: &#39;)<br>for Doc_ID in Final_Score_D1_Q3.head(5)[&#39;Doc_ID&#39;]:<br>    print(Doc_ID)<br>    print(list(train1.iloc[Doc_ID,:]))<br>print(&#39;Fourth Query is: &#39;)<br>print(Q4_D1.values)<br>print(&#39;Tokenized query is:&#39;)<br>print(Q4_list_D1)<br>print(&#39;Top 5 Matching posts  for Query4 are: &#39;)<br>for Doc_ID in Final_Score_D1_Q4.head(5)[&#39;Doc_ID&#39;]:<br>    print(Doc_ID)<br>    print(list(train1.iloc[Doc_ID,:]))</pre><pre>First Query is: <br>[ &#39;&lt;p&gt;I have not seen this explicitly stated anywhere so I was curious. Say I have network trained to meet my segmentation needs using 250x250 images. After this training is complete and I wish to submit images in production for segmentation, do those production submitted images need to be 250x250 as well or can they be any reasonable size?&lt;/p&gt;\n\n&lt;p&gt;If they must be resized to 250x250 for segmentation, is it possible to scale up the segmentation regions to apply to a larger image? If so what is the name of that technique so I can research it a bit more.&lt;/p&gt;\n&#39;]<br>Tokenized query is:<br>[&#39;seen&#39;, &#39;explicitly&#39;, &#39;stated&#39;, &#39;curious&#39;, &#39;say&#39;, &#39;network&#39;, &#39;trained&#39;, &#39;meet&#39;, &#39;segmentation&#39;, &#39;needs&#39;, &#39;using&#39;, &#39;250x250&#39;, &#39;images&#39;, &#39;training&#39;, &#39;complete&#39;, &#39;wish&#39;, &#39;submit&#39;, &#39;production&#39;, &#39;submitted&#39;, &#39;need&#39;, &#39;reasonable&#39;, &#39;size&#39;, &#39;resized&#39;, &#39;possible&#39;, &#39;scale&#39;, &#39;regions&#39;, &#39;apply&#39;, &#39;larger&#39;, &#39;image&#39;, &#39;technique&#39;, &#39;research&#39;, &#39;bit&#39;]<br>Top 5 Matching posts  for Query1 are: <br>0<br>[&quot;Would a neuromorphic SNN of the same complexity as the human nervous system be &#39;smarter&#39;?&quot;, &quot;&lt;p&gt;If the nervous system is wired up such that there are no well defined layers, how does this compare to a neatly stacked artificial net? If between my sensory and motor side I had a neatly designed SNN with well defined layers, how would I see the world?\nI get that there are some evolutionary advantages to a system where information can sometimes take a shortcut from sensory cell to motor cell (reflex action) bypassing brain processing but for arguments sake let&#39;s talk only about intelligence.&lt;/p&gt;\n&quot;]<br>1983<br>[&#39;In LSTM text generation can low amount of training data be compensated?&#39;, &#39;&lt;p&gt;I\&#39;m playing with an LSTM to generate text. In particular, this one:&lt;/p&gt;\n\n&lt;p&gt;&lt;a href=&quot;https://raw.githubusercontent.com/fchollet/keras/master/examples/lstm_text_generation.py&quot; rel=&quot;nofollow&quot;&gt;https://raw.githubusercontent.com/fchollet/keras/master/examples/lstm_text_generation.py&lt;/a&gt;&lt;/p&gt;\n\n&lt;p&gt;It works on quite a big demo text set from Nietzsche and says&lt;/p&gt;\n\n&lt;blockquote&gt;\n  &lt;p&gt;If you try this script on new data, make sure your corpus\n  has at least ~100k characters. ~1M is better.&lt;/p&gt;\n&lt;/blockquote&gt;\n\n&lt;p&gt;This pops up a couple of questions.&lt;/p&gt;\n\n&lt;p&gt;A.) If all I want is an AI with a very limited vocabulary where the generate text should be short sentences following a basic pattern.&lt;/p&gt;\n\n&lt;p&gt;E.g.&lt;/p&gt;\n\n&lt;p&gt;&lt;em&gt;I like blue sky with white clouds&lt;/em&gt;&lt;/p&gt;\n\n&lt;p&gt;&lt;em&gt;I like yellow fields with some trees&lt;/em&gt;&lt;/p&gt;\n\n&lt;p&gt;&lt;em&gt;I like big cities with lots of bars&lt;/em&gt;&lt;/p&gt;\n\n&lt;p&gt;...&lt;/p&gt;\n\n&lt;p&gt;Would it then be reasonable to use a much much smaller dataset?&lt;/p&gt;\n\n&lt;p&gt;B.) If the dataset really needs to be that big. What if I just repeat the text over and over to reach the recommended minimum? If that would work though, I\&#39;d be wondering how that is any different from just taking more iterations of learning with the same shorter text?&lt;/p&gt;\n\n&lt;p&gt;Obviously I can play with these two questions myself and in fact I am experimenting with it. One thing I already figured out is that with a shorter text following a basic pattern I can get to a very very low ( ~0.04) quite fast but the predicted text just turns out as gibberish.&lt;/p&gt;\n\n&lt;p&gt;My naive explanation for that would be that there are just not enough samples to proof against whether the gibberish actually makes sense or not? But then again I wonder if more iterations or duplicating the content would actually help.&lt;/p&gt;\n\n&lt;p&gt;I\&#39;m trying to experiment with these questions myself so please don\&#39;t think I\&#39;m just too lazy and are aiming for others to do the work. I\&#39;m just looking for more experienced people to give me a better understanding of the mechanics that influence these things.&lt;/p&gt;\n&#39;]<br>1974<br>[&#39;Is a mathematical formula a form of intelligence?&#39;, &#39;&lt;p&gt;&lt;em&gt;Warning: This question takes us into &lt;a href=&quot;https://en.wikipedia.org/wiki/VALIS&quot; rel=&quot;nofollow noreferrer&quot;&gt;VALIS&lt;/a&gt; territory, but I wouldn\&#39;t underestimate the profundity of that particular philosopher.&lt;/em&gt;&lt;/p&gt;\n\n&lt;p&gt;&lt;a href=&quot;https://en.oxforddictionaries.com/definition/intelligence&quot; rel=&quot;nofollow noreferrer&quot;&gt;There is a non-AI definition of intelligence which is simply &quot;information&quot; (see definition 2.3)&lt;/a&gt;.  If that information is &lt;em&gt;active&lt;/em&gt;, in terms of utilization, I have to wonder if it might qualify as a form of algorithmic intelligence, regardless of the qualities of the information.&lt;/p&gt;\n\n&lt;p&gt;What I\&#39;m getting at is that fields such as recreational mathematics often produce techniques and solutions that don\&#39;t have immediate, real world applications.  But there\&#39;s an adage that pure math tends to find uses. &lt;/p&gt;\n\n&lt;p&gt;So you might have algorithms applied to a problems that outside of the problems from which it originated, or that couldn\&#39;t initially be implemented in a computing context. (Minimax in 1928 might be an example.)&lt;/p&gt;\n\n&lt;p&gt;Goal orientation has been widely understood as a fundamental aspect of AI, but in the case of an algorithm designed for one problem, that it subsequently applied to a different problem, the goal may simply be a function of the algorithm\&#39;s structure. (To understand the goal of minimax precisely, you read the algorithm.)&lt;/p&gt;\n\n&lt;p&gt;If you regard this form of information as intelligence, then intelligence can be general, regardless of strength in relation to a given problem.&lt;/p&gt;\n\n&lt;ul&gt;\n&lt;li&gt;Can we consider this form of codification of information to be algorithmic intelligence?&lt;/li&gt;\n&lt;/ul&gt;\n\n&lt;p&gt;&lt;em&gt;And, just for fun, if a string that encodes a cutting-edge AI is not being processed, does it still qualify as artificial intelligence?&lt;/em&gt; &lt;/p&gt;\n&#39;]<br>1975<br>[&#39;How could an AI be used to improve the teaching and learning of mathematics?&#39;, &#39;&lt;p&gt;I have been working with AI methods. I am thinking about how my daughter (and also other kids) could learn mathematics with the help of AI. For example, how could an AI be used to show the mistakes that a kid does during the learning path?&lt;/p&gt;\n&#39;]<br>1976<br>[&#39;Is it possible to implement reinforcement learning using a neural network?&#39;, &#39;&lt;p&gt;I\&#39;ve implemented &lt;a href=&quot;https://en.wikipedia.org/wiki/Reinforcement_learning&quot; rel=&quot;nofollow noreferrer&quot;&gt;the reinforcement learning alogrithm&lt;/a&gt; for an agent to play &lt;a href=&quot;https://github.com/admonkey/snappybird&quot; rel=&quot;nofollow noreferrer&quot;&gt;snappy bird&lt;/a&gt; (a shameless cheap ripoff of flappy bird) utilizing a q-table for storing the history for future lookups. It works and eventually achieves perfect convergence after enough training.&lt;/p&gt;\n\n&lt;p&gt;Is it possible to implement a neural network to do function approximation in order to accomplish the purpose of the q-table? Obviously, storage is a concern with the q-table, but it doesn\&#39;t seem to ever train with the neural net alone. Perhaps training the NN on an existing q-table would work, but I would like to not use a q-table at all if possible.&lt;/p&gt;\n&#39;]<br>Second Query is: <br>[ &quot;&lt;p&gt;I am interested in making a simple chess engine using neural networks. I already have a fairly good value network but I can&#39;t figure out how to train a policy network. I know that Leela chess zero outputs the probability of any of the about 1800 possible moves. But how do you train such a network? How do you calculate the loss when you  only have the 1 move that was played in the game \nto work with?&lt;/p&gt;\n&quot;]<br>Tokenized query is:<br>[&#39;interested&#39;, &#39;making&#39;, &#39;simple&#39;, &#39;chess&#39;, &#39;engine&#39;, &#39;using&#39;, &#39;neural&#39;, &#39;networks&#39;, &#39;fairly&#39;, &#39;good&#39;, &#39;value&#39;, &#39;network&#39;, &#39;figure&#39;, &#39;train&#39;, &#39;policy&#39;, &#39;know&#39;, &#39;leela&#39;, &#39;zero&#39;, &#39;outputs&#39;, &#39;probability&#39;, &#39;1800&#39;, &#39;possible&#39;, &#39;moves&#39;, &#39;calculate&#39;, &#39;loss&#39;, &#39;played&#39;, &#39;game&#39;, &#39;work&#39;]<br>Top 5 Matching posts  for Query2 are: <br>1075<br>[&#39;Transposition table is only used for roughly 17% of the nodes - is this expected?&#39;, &quot;&lt;p&gt;I&#39;m making a Connect Four game using the typical minimax + alpha-beta pruning algorithms. I just implemented a Transposition Table, but my tests tell me the TT only helps 17% of the time. By this I mean that 17% of the positions my engine comes across in its calculations can be automatically given a value (due to the position being calculated previously via a different move order).&lt;/p&gt;\n\n&lt;p&gt;For most games, is this figure expected? To me it seems very low, and I was optimistically hoping for the TT to speed up my engine by around 50%. It should be noted though that on each turn in the game, I reset my TT (since the evaluation previously assigned to each position is inaccurate due to lower depth back then).&lt;/p&gt;\n\n&lt;p&gt;I know that the effectiveness of TT&#39;s are largely dependent on the game they&#39;re being used for, but any ballparks of how much they speed up common games (chess, go, etc) would be helpful.&lt;/p&gt;\n\n&lt;p&gt;EDIT - After running some more tests and adjusting my code, I found that the TT sped up my engine to about 133% (so it took 75% as much time to calculate). This means those 17% nodes were probably fairly high up in the tree, since not having to calculate the evaluation of these 17% sped up things by 33%. This is definitely better, but my question still remains on whether this is roughly expected performance of a typical TT.&lt;/p&gt;\n&quot;]<br>356<br>[&#39;What is a &quot;logit probability&quot;?&#39;, &#39;&lt;p&gt;DeepMind\&#39;s paper &lt;a href=&quot;https://www.nature.com/articles/nature24270.epdf?author_access_token=VJXbVjaSHxFoctQQ4p2k4tRgN0jAjWel9jnR3ZoTv0PVW4gB86EEpGqTRDtpIz-2rmo8-KG06gqVobU5NSCFeHILHcVFUeMsbvwS-lxjqQGg98faovwjxeTUgZAUMnRQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Mastering the game of Go without human knowledge&quot;&lt;/a&gt; states in its &quot;Methods&quot; section on its &quot;Neural network architecture&quot; that the output layer of AlphaGo Zero\&#39;s policy head is &quot;A fully connected linear layer that outputs a vector of size 19^2+1=362, corresponding to the &lt;em&gt;logit probabilities&lt;/em&gt; for all intersections and the pass move&quot; (emphasis mine).  I am self-trained regarding neural networks, and I have never heard of a &quot;logit probability&quot; before this paper.  I have not been able by searching and reading to figure out what it means.  In fact, the &lt;a href=&quot;https://en.wikipedia.org/wiki/Logit&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia page on logit&lt;/a&gt; seems to make the term a contradiction.  A logit can be converted into a probability using the equation &lt;span class=&quot;math-container&quot;&gt;$p=\\frac{e^l}{e^l+1}$&lt;/span&gt;, and a probability can be converted into a logit using the equation &lt;span class=&quot;math-container&quot;&gt;$l=\\ln{\\frac{p}{1-p}}$&lt;/span&gt;, so the two cannot be the same.  The &lt;a href=&quot;https://github.com/gcp/leela-zero/blob/master/training/caffe/zero.prototxt&quot; rel=&quot;nofollow noreferrer&quot;&gt;neural network configuration for Leela Zero&lt;/a&gt;, which is supposed to have a nearly identical architecture to that described in the paper, seems to indicate that the fully connected layer described in the above quote needs to be followed with a softmax layer to generate probabilities (though I am absolutely new to Caffe and might not be interpreting the definitions of &quot;p_ip1&quot; and &quot;loss_move&quot; correctly).  The &lt;a href=&quot;https://medium.com/applied-data-science/alphago-zero-explained-in-one-diagram-365f5abf67e0&quot; rel=&quot;nofollow noreferrer&quot;&gt;AlphaGo Zero cheat sheet&lt;/a&gt;, which is otherwise very helpful, simply echoes the phrase &quot;logit probability&quot; as though this is a well-known concept.  I have seen several websites that refer to &quot;logits&quot; on their own (such as &lt;a href=&quot;https://eli.thegreenplace.net/2016/the-softmax-function-and-its-derivative/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;), but this is not enough to satisfy me that &quot;logit probability&quot; must mean &quot;a probability generated by passing a logit vector through the softmax function&quot;.&lt;/p&gt;\n\n&lt;p&gt;What is a logit probability?  What sources can I read to help me understand this concept better?&lt;/p&gt;\n&#39;]<br>2747<br>[&#39;Teach a Neural Network to play a card game&#39;, &quot;&lt;p&gt;I am currently writing an engine to play a card game, as there is no engine yet for this particular game.&lt;/p&gt;\n\n&lt;p&gt;I am hoping to be able to introduce a neural net to the game afterwards, and have it learn to play the game.&lt;/p&gt;\n\n&lt;p&gt;I&#39;m writing the engine in such a way that is helpful for an AI player. There are choice points, and at those points, a list of valid options is presented. Random selection would be able to play the game (albeit not well).&lt;/p&gt;\n\n&lt;p&gt;I have learned a lot about neural networks (mostly NEAT and HyperNEAT) and even built my own implementation. I am still unsure how best build an AI that can take into account all the variables in one of these types of games. Is there a common approach? I know that Keldon wrote a good AI for RftG which has a decent amount of complexity, I am not sure how he managed to build such an AI.&lt;/p&gt;\n\n&lt;p&gt;Any advice? Is it feasible? Are there any good examples of this? How were the inputs mapped?&lt;/p&gt;\n\n&lt;p&gt;EDIT: I have looked online and learned how neural networks work and usually how they pertain to image recognition or steering a simple agent. I&#39;m not sure if or how I would apply it to making selections with cards which have a complex synergy. Any direction towards what I should be looking into would be greatly appreciated.&lt;/p&gt;\n\n&lt;p&gt;About the game: The game is similar to Magic: The Gathering. There is a commander which has health and abilities. Players have an energy pool which they use to put minions and spells on the board. Minions have health, attack values, costs, etc. Cards also have abilities, these are not easily enumerated. Cards are played from the hand, new cards are drawn from a deck. These are all aspects it would be helpful for the neural network to consider. &lt;/p&gt;\n&quot;]<br>1263<br>[&#39;How to train a neural network for a round based board game?&#39;, &quot;&lt;p&gt;I&#39;m wondering how to train a neural network for a round based board game like, tic-tac-toe, chess, risk or any other round based game.\nGetting the next move by inference seems to be pretty straight forward, by feeding the game state as input and using the output as the move for the current player.\nHowever training an AI for that purpose doesn&#39;t appear to be that straight forward, because:&lt;/p&gt;\n\n&lt;ol&gt;\n&lt;li&gt;There might not be a rating if a single move is good or not, so training of single moves doesn&#39;t seem to be the right choice&lt;/li&gt;\n&lt;li&gt;Using all game states (inputs) and moves (outputs) of the whole game to train the neural network, doesn&#39;t seem to be the right choice as not all moves within a lost game might be bad&lt;/li&gt;\n&lt;/ol&gt;\n\n&lt;p&gt;So I&#39;m wondering how to train a neural network for a round based board game?\nI would like to create a neural network for tic-tac-toe using tensorflow.&lt;/p&gt;\n&quot;]<br>106<br>[&#39;Building AI from chess - data shape from simulation&#39;, &#39;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;\n\n&lt;p&gt;My problem is the following: Given 1000 wins, losses, and ties from a chess simulation I am using, what shape should each game be (I.e., sequence of moves leading to win/loss/tie) in order to build an deep neural network on it?&lt;/p&gt;\n\n&lt;p&gt;&lt;strong&gt;Literature Review&lt;/strong&gt;&lt;/p&gt;\n\n&lt;ol&gt;\n&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://ai.stackexchange.com/questions/4672/can-an-ai-learn-how-to-play-chess-without-instructions&quot;&gt;Kind of got me in the right direction.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;\n&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://ai.stackexchange.com/questions/4910/how-would-you-encode-your-input-vector-matrix-from-a-sequence-of-moves-in-game-l&quot;&gt;Great theoretical way of thinking about it, but left me wanting detail.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;\n&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://erikbern.com/2014/11/29/deep-learning-for-chess.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gave a good high level tutorial, but not enough detail.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;\n&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/lamesjim/Chess-AI&quot; rel=&quot;nofollow noreferrer&quot;&gt;Alpha beta pruning python example, but no neural network.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;\n&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/erikbern/deep-pink/blob/master/reinforcement.py&quot; rel=&quot;nofollow noreferrer&quot;&gt;Neural network using reinforcement learning, but I cant figure out what the (X,y) shapes are and their meaning from just digging into the source code.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;\n&lt;/ol&gt;\n\n&lt;p&gt;&lt;strong&gt;Current Situation&lt;/strong&gt;&lt;/p&gt;\n\n&lt;p&gt;I currently have a sample of 1000 wins, 1000 losses, and 1000 ties from the &lt;code&gt;python-chess&lt;/code&gt; api, so if &lt;code&gt;i&lt;/code&gt; is the index of a game, then this is the structure of the current dataset I am working with:&lt;/p&gt;\n\n&lt;pre&gt;&lt;code&gt;game_i -&amp;gt; (num_moves_i,8,8,16)\n&lt;/code&gt;&lt;/pre&gt;\n\n&lt;p&gt;So each &lt;code&gt;game_i&lt;/code&gt; where &lt;code&gt;i in {1..3000}&lt;/code&gt; and &lt;code&gt;num_moves_i is variable&lt;/code&gt; depending on the game (E.g., 14 for a good winning game, or 765 moves for a tie game). The 16 represents a &lt;code&gt;one_hot_encoding&lt;/code&gt; for one of the 16 unique board pieces. The data set is also an alternating board state, so:&lt;/p&gt;\n\n&lt;pre&gt;&lt;code&gt;game_i[0] == board state of whites first move\ngame_i[1] == baord state of blacks first move\n&lt;/code&gt;&lt;/pre&gt;\n\n&lt;p&gt;Furthermore, I also have alpha-beta pruning and maximin working, so for each move I have an intrinsic value associated with it using recursion three levels deep. Leading my current approach to a regression of a given move, essentially leading me to believe the AI would simply learn the heuristic and predict a value the heuristic would give.&lt;/p&gt;\n\n&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;\n\n&lt;p&gt;Clearly my proof of concept 1000 winning games is not enough to make a meaningful AI, but that isn\&#39;t my goal. I want to learn the techniques, not produce an enterprise scale chess AI.&lt;/p&gt;\n\n&lt;ol&gt;\n&lt;li&gt;Does the tensor shape make sense?&lt;/li&gt;\n&lt;li&gt;Is this a reinforcement learning problem? If so, how can I shape my current framing into that type of thinking? Theory in this area would be greatly appreciated as I am less familiar with it.&lt;/li&gt;\n&lt;li&gt;Is this a RNN/LSTM problem? (E.g., predict the next board state).&lt;/li&gt;\n&lt;li&gt;Is this a regression problem?&lt;/li&gt;\n&lt;li&gt;Is this a sequence mining problem?&lt;/li&gt;\n&lt;/ol&gt;\n\n&lt;p&gt;What is the standard approach to framing this problem, once you have data falling through the pipeline. &lt;/p&gt;\n\n&lt;p&gt;Your support is more than appreciated.&lt;/p&gt;\n\n&lt;p&gt;&lt;strong&gt;* UPDATE (STILL IN RESEARCH) *&lt;/strong&gt;&lt;/p&gt;\n\n&lt;p&gt;With further research, a candidate label for the training data is the tensor and the item from the state-space that was selected with that board state. Then only keep games containing sequences of moves which obtain a cumulative value &gt;= &lt;code&gt;epsilon&lt;/code&gt;. This would require a &lt;code&gt;one_hot_encoding&lt;/code&gt; of all moves played in all games we wish to train on, as labels. E.g., &lt;code&gt;(game_i,board_ij,e2e6)&lt;/code&gt;&lt;/p&gt;\n&#39;]<br>Third Query is: <br>[ &quot;&lt;p&gt;I am interested in understanding how to choose data-acquisition parameters for the subject matter:&lt;/p&gt;\n\n&lt;ul&gt;\n&lt;li&gt;Frame Resolution&lt;/li&gt;\n&lt;li&gt;Frame rates (FPS)&lt;/li&gt;\n&lt;/ul&gt;\n\n&lt;p&gt;The goal is to have &#39;enough&#39; (preferably the minimal) resolution and frames to enable AI to identify people. &lt;/p&gt;\n\n&lt;h1&gt;QUESTIONS&lt;/h1&gt;\n\n&lt;ol&gt;\n&lt;li&gt;Are there any published rules of thumb or processes to select video parameters?&lt;/li&gt;\n&lt;li&gt;Is there a term or label for the selection of video parameters for AI projects?&lt;/li&gt;\n&lt;/ol&gt;\n&quot;]<br>Tokenized query is:<br>[&#39;interested&#39;, &#39;understanding&#39;, &#39;choose&#39;, &#39;data&#39;, &#39;acquisition&#39;, &#39;parameters&#39;, &#39;subject&#39;, &#39;matter&#39;, &#39;ul&#39;, &#39;li&#39;, &#39;frame&#39;, &#39;resolution&#39;, &#39;rates&#39;, &#39;fps&#39;, &#39;goal&#39;, &#39;preferably&#39;, &#39;minimal&#39;, &#39;frames&#39;, &#39;enable&#39;, &#39;ai&#39;, &#39;identify&#39;, &#39;people&#39;, &#39;h1&#39;, &#39;questions&#39;, &#39;ol&#39;, &#39;published&#39;, &#39;rules&#39;, &#39;thumb&#39;, &#39;processes&#39;, &#39;select&#39;, &#39;video&#39;, &#39;term&#39;, &#39;label&#39;, &#39;selection&#39;, &#39;projects&#39;]<br>Top 5 Matching posts  for Query3 are: <br>2923<br>[&#39;How can we connect artificial intelligence with cognitive psychology?&#39;, &#39;&lt;p&gt;Cognitive Psychology is one of the basic sciences of artificial intelligence (AI). The founder of the psychology is &lt;strong&gt;Wilhelm W.(1832-1920)&lt;/strong&gt;, who engaged in empirical methods,and was interested in the &lt;strong&gt;&lt;em&gt;thinking processes&lt;/em&gt;&lt;/strong&gt; during his scientific work.&lt;/p&gt;\n\n&lt;p&gt;According to his research,Psychology had two main leading subjects: &lt;/p&gt;\n\n&lt;ol&gt;\n&lt;li&gt;Behaviourism.&lt;/li&gt;\n&lt;li&gt;Cognitivism.&lt;/li&gt;\n&lt;/ol&gt;\n\n&lt;p&gt;&lt;strong&gt;Behaviourism:&lt;/strong&gt; Refused the theory of the mental processes, and insisted to study the resulted action or the stimulus strictly objective. The representatives of this theory have been decreasing with time.&lt;/p&gt;\n\n&lt;p&gt;&lt;strong&gt;Cognitive psychology:&lt;/strong&gt; defines that the brain is an information processing device.&lt;/p&gt;\n\n&lt;p&gt;Therefore,this question is not a duplicate of this &lt;a href=&quot;https://ai.stackexchange.com/questions/1847/what-is-the-difference-between-artificial-intelligence-and-cognitive-science&quot;&gt;what-is-the-difference-between-artificial-intelligence-and-cognitive-science?&lt;/a&gt; ,However my question is;how can we connect artificial intelligence with cognitive psychology for instance;&lt;/p&gt;\n\n&lt;p&gt;&lt;strong&gt;Human Computing Interaction:&lt;/strong&gt;\nWe may come in a contact with Humana Computer Interaction every day, because this field includes the every day use of computer for example;tapping stack exchange app on smart-phone, the user interfaces and some other expert programs which may use cognitive psychology in order to manipulate or help people. But still such tasks have got a minimal  relevant connection.&lt;/p&gt;\n&#39;]<br>163<br>[&quot;What are the latest &#39;hot&#39; research topics for deep learning and AI?&quot;, &#39;&lt;p&gt;I did my Master\&#39;s thesis on Deep Generative Models and I\&#39;m currently looking for a new subject.&lt;/p&gt;\n\n&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; What are the &quot;hottest&quot; research topics that are taking a lot of attention of the deep learning community lately?&lt;/p&gt;\n\n&lt;p&gt;A few clarifications:&lt;/p&gt;\n\n&lt;ul&gt;\n&lt;li&gt;I did look through similar questions and none of them answered my\nquestion.&lt;/li&gt;\n&lt;li&gt;I come from a pure mathematical background, I only\ntransitioned into deep learning a year ago, and my research on\ngenerative models was mostly theoretical. Which means, most of my\nwork revolved around structured probabilistic models, and approximate\ninference. That said, I have yet to explore real world applications of deep learning.&lt;/li&gt;\n&lt;li&gt;I did my homework before posing the question. My goal was to get ai SE\&#39;s input on the matter and see what people are working on.&lt;/li&gt;\n&lt;/ul&gt;\n&#39;]<br>2736<br>[&#39;What are the current approaches for AI to learn a foreign language just from English books?&#39;, &quot;&lt;p&gt;I&#39;m aware this could be a complex topic, however I&#39;m interested in existing research projects or studies where people are attempting or have succeeded in teaching an AI a foreign language just by training/teaching it from English books. By reading, analysing and understanding, so that it knows the foreign language&#39;s rules (such as grammar, spelling, etc.), the same way as a human would learn. The language doesn&#39;t have to be Chinese, which is difficult for even humans to learn.&lt;/p&gt;\n&quot;]<br>2431<br>[&#39;How can we create eXplainable Artificial Intelligence?&#39;, &#39;&lt;p&gt;Currently, we can build the &lt;a href=&quot;https://en.wikipedia.org/wiki/Artificial_intelligence&quot; rel=&quot;nofollow noreferrer&quot;&gt;Artificial Intelligence (AI)&lt;/a&gt; approaches that respectively explain their actions within the use of goal trees [1]. By moving up and down across the tree, it keeps tracking the last and next movements. Therefore, giving the ability to the machine for &quot;explain&quot; the actions.&lt;/p&gt;\n\n&lt;p&gt;Explainability regarding human levels, requires some cognitive effort, such as self-awareness, memory retrieval, a theory of mind and so on [2]. Humans are adept at selecting several causes from an infinite number of causes to be the explanation. However, this selection is influenced by certain cognitive biases. The idea of explanation selection is not new in &lt;a href=&quot;https://en.wikipedia.org/wiki/Explainable_Artificial_Intelligence&quot; rel=&quot;nofollow noreferrer&quot;&gt;eXplainable Artificial Intelligence (XAI)&lt;/a&gt; [3, 4]. But, as far as we are aware, there are currently no studies that look at the cognitive biases of humans as a way to select explanations from a set of causes.&lt;/p&gt;\n\n&lt;p&gt;Despite a clear definition and description of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Explainable_Artificial_Intelligence&quot; rel=&quot;nofollow noreferrer&quot;&gt;XAI&lt;/a&gt; field, several questions remain present. The issues are summarized in just one sentence and listed as follows.&lt;/p&gt;\n\n&lt;p&gt;That said, our question is:&lt;/p&gt;\n\n&lt;blockquote&gt;\n  &lt;p&gt;How can we create and build &lt;a href=&quot;https://en.wikipedia.org/wiki/Explainable_Artificial_Intelligence&quot; rel=&quot;nofollow noreferrer&quot;&gt;XAI&lt;/a&gt;?&lt;/p&gt;\n&lt;/blockquote&gt;\n\n&lt;h1&gt;References&lt;/h1&gt;\n\n&lt;p&gt;[1] Hadoux, Emmanuel, and Anthony Hunter. &quot;Strategic Sequences of Arguments for Persuasion Using Decision Trees.&quot; AAAI. 2017.&lt;/p&gt;\n\n&lt;p&gt;[2] Miller, T., 2018. Explanation in artificial intelligence: Insights from the social sciences. Artificial Intelligence.&lt;/p&gt;\n\n&lt;p&gt;[3] Gunning, D., 2017. Explainable artificial intelligence (xai). Defense Advanced Research Projects Agency (DARPA), nd Web.&lt;/p&gt;\n\n&lt;p&gt;[4] Samek, W., Wiegand, T. and Müller, K.R., 2017. Explainable artificial intelligence: Understanding, visualizing and interpreting deep learning models. arXiv preprint arXiv:1708.08296.&lt;/p&gt;\n&#39;]<br>1261<br>[&#39;Can I detect unique people in a video?&#39;, &#39;&lt;p&gt;I am having a video feed with multiple faces in it. I need to detect each face and the gender as well and assign the gender against each person. I am not sure how to uniquely identify a face as Face1 and Face2 etc. I do not need to know their names, just need to track a person in the entire video. I thought of tracking methods but people are constantly moving and changing so a box location can be occupied by another person after some frames. &lt;/p&gt;\n\n&lt;p&gt;I am interested in a way where I can assign an id to a face but I am not sure how to do it. I can use Facial Recognition Based embedding on each face and track that. But that seems to be an overkill for the job. Is there any other method available or Facial Recognition/Embedding is the only method to uniquely identify people in a video?&lt;/p&gt;\n&#39;]<br>Fourth Query is: <br>[ &#39;&lt;p&gt;I wanted to know what the differences between hyper-heuristics and meta-heuristics are, and what their main applications are. Which problems are suited to be solved by Hyper-heuristics?&lt;/p&gt;\n&#39;]<br>Tokenized query is:<br>[&#39;wanted&#39;, &#39;know&#39;, &#39;differences&#39;, &#39;hyper&#39;, &#39;heuristics&#39;, &#39;meta&#39;, &#39;main&#39;, &#39;applications&#39;, &#39;problems&#39;, &#39;suited&#39;, &#39;solved&#39;]<br>Top 5 Matching posts  for Query4 are: <br>2576<br>[&#39;What kind of problems require more than 2 hidden layers?&#39;, &quot;&lt;p&gt;I&#39;ve read that the most of the problems can be solved with 1-2 hidden layers.&lt;/p&gt;\n\n&lt;p&gt;How do you know you need more than 2? For what kind of problems you would need them (give me an example)?&lt;/p&gt;\n&quot;]<br>1994<br>[&#39;What non-math/CS classes are good supplements for computational neuroscience and/or linguistics?&#39;, &quot;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I wanted to ask a meta-post first to see if this site was supposed to be used only for AI-related questions, or if AI-related questions such as this were allowed, too, but apparently you need to have asked five actual questions first.&lt;/p&gt;\n\n&lt;hr&gt;\n\n&lt;p&gt;I&#39;m going to be entering a masters computer science program in the fall, and I wanted to move towards a concentration in computational neuroscience and linguistics for AI development applications. While I have a math and CS background, I have almost no biology/neuroscience background, and my linguistics background is limited to the random research I&#39;ve done in my spare time to satiate my curiosities.&lt;/p&gt;\n\n&lt;p&gt;What are good non-math and CS related topics to study for these fields? &lt;/p&gt;\n&quot;]<br>2674<br>[&#39;When should I use simulated annealing as opposed to a genetic algorithm?&#39;, &#39;&lt;p&gt;What kind of problems is simulated annealing better suited for compared to genetic algorithms?&lt;/p&gt;\n\n&lt;p&gt;From my experience, genetic algorithms seem to perform better than simulated annealing for most problems.&lt;/p&gt;\n&#39;]<br>1428<br>[&#39;Machine Learning papers for matching packets to request flows&#39;, &#39;&lt;p&gt;I\&#39;m currently doing a research project related to Distributed Tracing. My research has led me to a point where I think ML might be suited for our problem.&lt;/p&gt;\n\n&lt;p&gt;I\&#39;m looking for papers that are similar to this (even if they have other applications):&lt;/p&gt;\n\n&lt;p&gt;I want to match packets exiting a black-box system (outputs) to packets that enter a black box (inputs). I can do that easily in a non concurrent setting which should help  me grow a training set (maybe for supervised learning), but I need an algorithm that, in a concurrent setting, can separate the different request &quot;flows&quot; if you will.&lt;/p&gt;\n\n&lt;p&gt;I hope this makes sense.&lt;/p&gt;\n\n&lt;p&gt;The closest thing to what I\&#39;m looking for is &quot;Aguilera, Marcos K., et al. &quot;Performance debugging for distributed systems of black boxes.&quot; ACM SIGOPS Operating Systems Review. Vol. 37. No. 5. ACM, 2003.&quot; but it\&#39;s mostly suited for finding the dependency graph of the system, which I already know.&lt;/p&gt;\n\n&lt;p&gt;Thank you&lt;/p&gt;\n&#39;]<br>2448<br>[&#39;What is the difference between MLP and RBF?&#39;, &#39;&lt;p&gt;What are the main differences between two types of feedforward networks such as &lt;em&gt;multilayer perceptrons&lt;/em&gt; (MLP) and &lt;em&gt;radial basis function&lt;/em&gt; (RBF)?&lt;/p&gt;\n\n&lt;p&gt;What are the fundamental differences between these two types?&lt;/p&gt;\n&#39;]</pre><h3>Observation and Conclusion</h3><p>1. These kinds of approaches are basics of NLP and Information retrieval on text data</p><p>2. It can be seen from the above results that a simple approach like this can identify and match key query words to keywords in the documents present in the corpus.</p><p>3. One of the limitations of this approach is that it is unable to get the complete context of the query and identify the matching posts with high<br> degree of matching context.</p><p>4. This is where next-gen algorithms like RNNs and LSTM do better than the approach in this post.</p><p>5. LLMs take Language Modeling to the next level by training models on really large datasets. This helps to capture more and more types of contexts for a given word/sentence.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9a25eab1934" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Robust Machine Learning Model Evaluation- Part II]]></title>
            <link>https://medium.com/@srai7785/robust-machine-learning-model-evaluation-part-ii-b21f06469d69?source=rss-e0b826209e58------2</link>
            <guid isPermaLink="false">https://medium.com/p/b21f06469d69</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[model-evaluation]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Sudhir Kumar Rai]]></dc:creator>
            <pubDate>Wed, 22 Sep 2021 07:23:28 GMT</pubDate>
            <atom:updated>2021-09-22T07:23:28.595Z</atom:updated>
            <content:encoded><![CDATA[<p>This is second post on the model evaluation. Please find Part I here: <a href="https://medium.com/@srai7785/robust-machine-learning-model-evaluation-part-i-ffdefedd38bc">https://medium.com/@srai7785/robust-machine-learning-model-evaluation-part-i-ffdefedd38bc</a></p><p><strong>Test Case 3: Probability Bin-wise primary class count comparison</strong></p><p>Following are the steps to run this test case:</p><p><strong>Step 1:</strong> Create 10 or 20 probability bins.</p><p><strong>Step 2:</strong> On test data and OOT data calculate % count of primary target class=1 for each probability bin.</p><p><strong>Key Patterns to look for:</strong></p><p><strong>Pattern 1: Stable Model</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*WS9yRSxbwo6JvUq6XP-ICQ.jpeg" /><figcaption>Binwise Proportion of Primary Class</figcaption></figure><p><strong>i. Proportion of primary class monotonically increases as score increases for OOT and Test data both.</strong></p><p><strong>ii. Proportion of primary class captured for each bin for OOT data and Test data should be close to each other as seen in above chart.</strong></p><p><strong>Pattern 2: Unstable Model</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*hCYGUDjpVeACLO6UbFFf7g.jpeg" /><figcaption>Binwise Proportion of Primary Class</figcaption></figure><p><strong>i. Proportion of primary class monotonically increases in Test data but not in OOT data.</strong></p><p><strong>ii. Capturing much lower proportion of primary class in higher bins in OOT data as compared to Test data.</strong></p><p><strong>iii. Capturing much higher proportion of primary class in lower bins in OOT data as compared to Test data.</strong></p><p><strong>iv. For really unstable models even on test data, proportion of primary class captured may show lot of fluctuations across score bins.</strong></p><p><strong>Test Case 4: Probability Bin-wise Miss-classification Rate comparison</strong><br>Following are the steps to run this test case:<br><strong>Step 1:</strong> Create 10 or 20 probability bins.<br><strong>Step 2:</strong> On test data and OOT data calculate miss-classification rate for each bin on OOT and Test data. This will be based on score cut-off decided for classification.<br><strong>Key Patterns to look for:</strong></p><p><strong>Pattern 1: Stable Model</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*2fNPtAPpmVxVedGa2CVh2A.jpeg" /><figcaption>Binwise Miss-Classification Rate</figcaption></figure><p><strong>i. Binwise miss-classification rate should be small for low probability and high probability bins. Where as it will be higher in the middle probability bins as show in above chart.</strong></p><p><strong>ii. One would observe that, for middle range bins, miss-classification seems quite high. Then we should look at over-all proportion of data falling in that particular bin. In general, if model is good then proportion of data falling in middle score bin will be really small.</strong></p><p><strong>iii. Binwise miss-classification rates should be similar between OOT and Test set for each bin. As seen in the above chart.</strong></p><p><strong>Pattern 2: Unstable Model</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*6e9w4Q4kDBaMznI1bGYuCQ.jpeg" /><figcaption>Binwise Miss-Classification Rate</figcaption></figure><p><strong>i. Binwise miss-classification rate is quite different between Test and OOT across different bins.</strong></p><p><strong>ii</strong>. <strong>Much higher miss-classification rate for high and low score bins on OOT dataset. As scene in above image.</strong></p><p><strong>iii. For really unstable models even on test data, miss-classification rate may show lot of fluctuations across score bins.</strong></p><p>This concludes second installment in the series of posts on “Robust Machine Learning Model Evaluation.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b21f06469d69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Robust Machine Learning Model Evaluation- Part I]]></title>
            <link>https://medium.com/@srai7785/robust-machine-learning-model-evaluation-part-i-ffdefedd38bc?source=rss-e0b826209e58------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffdefedd38bc</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[t-test]]></category>
            <category><![CDATA[bootstrapping]]></category>
            <category><![CDATA[model-evaluation]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Sudhir Kumar Rai]]></dc:creator>
            <pubDate>Tue, 24 Aug 2021 09:12:06 GMT</pubDate>
            <atom:updated>2021-08-25T04:57:46.981Z</atom:updated>
            <content:encoded><![CDATA[<p>In machine learning projects, one of the the biggest problems is drop in model performance as soon as it is deployed. Some times data science teams get into panic mode as it is quite difficult to find out the root cause while model is in production.</p><p>One way to mitigate this risk is to have more robust model evaluation in the lab, so that, we know what all could go wrong if model is showing lower accuracy on production immediately after deployment.</p><p>One can think of this as evaluation equivalent to software testing. A streamlined test case based evaluation.</p><p>Prerequisite for this evaluation is model predicted score and actual class values for following datasets:</p><ol><li><strong>Test Dataset:</strong> This is the dataset used in-lab for testing and not used in model training.</li><li><strong>Out-of-time Dataset:</strong> This is an out-of-time dataset not at all used in any model training or testing.</li></ol><p>In order to perform a comprehensive evaluation, we will look at 5 different accuracy metrics namely: F1 Score, FPR, FNR, Precision, Recall. I have created 10 Test cases which every model should be tested against. Now lets explore each test case in detail:</p><p><strong>Test Case 1: Metric Comparison @various probability threshold</strong></p><p>Generate F1 Score, FPR, FNR, Precision, Recall between Test set and OOT set various probability threshold. Create a table as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*B2uhd-f0bVhRDSXebcjYpg.jpeg" /><figcaption><strong>Metric Comparison Table</strong></figcaption></figure><p><strong>Key patterns to look for:</strong></p><p><strong>a) In general, if different evaluation metric’s are close to each other for both the dataset then model is stable and robust.</strong></p><p><strong>b) Metric consistency between two datasets across different probability thresholds is a concrete indication of model robustness.</strong></p><p><strong>c) If there are one or more thresholds for which evaluation metric are way different between two datasets then model might not do well in production setting for long.</strong></p><p><strong>Test Case 2: Using T-Test for model evaluation on Bootstrapped Samples</strong></p><p>Following are the steps to run a T-Test for this test case:</p><p><strong>Step 1:</strong> Select Bootstrapped samples from Test data and OOT data. The bootstrapped sample size should equivalent to size of the Test and OOT dataset. Lets say we take 5000 different bootstrapped samples of the size of test data.</p><p><strong>Step 2:</strong> For each Bootstrapped sample calculate F1 Score, FPR, FNR, Precision, Recall for Test set and OOT set.<br> <strong>Step 3: </strong>Now you have two pairs of each accuracy metric and 5000 such records.<br><strong>Step 4:</strong> Run a two tailed t-test to evaluate if F1_test and F1_OOT come from the same population or not @0.05 p-value.</p><p>Step 5: Create a table as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*wmvtkCRNesPlDGnQjDDjnA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*Lh0AORVdBJiT7qREES_flw.jpeg" /><figcaption><strong>Table 1: Model is consistent Table 2: Model is inconsistent</strong></figcaption></figure><p><strong>Key patterns to look for:</strong></p><ol><li><strong>If for each evaluation metric, T-Test p-value &gt; 0.05, this indicates that model is robust and consistent. As shown in table 1 above.</strong></li><li><strong>If for one more evaluation metric, T-Test p-value ≤0.05, this indicates model might be inconsistent. As shown in table 2 above.</strong></li><li><strong>Depending on domain one can decide if we should go ahead with this model. For example in Cyber Security and Banking domain, high false positive is not acceptable where as in Marketing domain it may not be an issue.</strong></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffdefedd38bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>