<?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 Saksham Saxena on Medium]]></title>
        <description><![CDATA[Stories by Saksham Saxena on Medium]]></description>
        <link>https://medium.com/@SaxenaSaksham?source=rss-7b249093572e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NuPVpzWFaYxEQIMJL66jfQ.jpeg</url>
            <title>Stories by Saksham Saxena on Medium</title>
            <link>https://medium.com/@SaxenaSaksham?source=rss-7b249093572e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 21:27:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@SaxenaSaksham/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[A/B Testing: A Numbers Game with a Massive Impact]]></title>
            <link>https://medium.com/@SaxenaSaksham/a-b-testing-a-numbers-game-with-a-massive-impact-3714c13ef231?source=rss-7b249093572e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3714c13ef231</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[a-b-testing]]></category>
            <category><![CDATA[innovation]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Saksham Saxena]]></dc:creator>
            <pubDate>Mon, 29 May 2023 02:04:04 GMT</pubDate>
            <atom:updated>2023-05-29T02:04:04.798Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone! In our digitally driven world, the slightest change can be the difference between a conversion and a lost potential customer. Today, I invite you into the world of A/B testing — the silent powerhouse behind effective data-based decision making!</p><h3>A/B Testing Demystified</h3><p>At its heart, A/B testing sounds like a simple concept, reminiscent of high school science experiments. It involves creating two versions of a webpage, email, or other content, labeled as Version A (our control) and Version B (our variant). The audience is split into two equal halves — one sees Version A, and the other is presented Version B. Engagement is then measured across both versions, and the one that performs better is declared the winner.</p><p>This, in essence, is the formula that drives A/B testing:</p><p>Success Rate = (Number of Successful Events / Total Number of Events) *100%</p><h3>The Power of Decisions and Data</h3><p>Every decision, be it the color scheme, the call-to-action placement, the font style, or even the microcopy, plays a crucial role in how a user interacts with your content. A/B testing allows you to experiment with these elements, gather data, and make informed decisions based on that data.</p><p>This entire process operates on statistical significance — the mathematical likelihood that the difference in conversion rates between Version A and Version B is not due to random chance. This is calculated using the following formula:</p><p>z = (p1 - p2) / sqrt [ (p(1-p) / n1) + (p(1-p) / n2) ]</p><p>Here, p1 and p2 are the conversion rates of Version A and B respectively, n1 and n2 are the number of users exposed to each version, and p is the pooled probability.</p><h3>Why A/B Testing is a Game-Changer</h3><p>A/B testing offers a robust scientific methodology for businesses to validate the effectiveness of their digital strategies. By running these tests, organizations can reduce bounce rates, increase conversion rates, and optimize the overall user experience. It also extends its benefits to various facets of your digital presence like emails, social media posts, and online advertisements.</p><h3>The Beauty of Incremental Improvements</h3><p>A/B testing celebrates the power of gradual, step-by-step improvements. It acknowledges that significant progress often comes from a series of small but smart changes. With each iteration, businesses get closer to an optimal user experience, validating each step with real-world data and mathematical evidence.</p><p>In summary, A/B testing is an incredibly potent tool in the data-driven decision-making arsenal. It enables you to navigate through the vast array of choices, guided by data, steering clear of assumptions.</p><p>So the next time you’re contemplating whether to go with a red button or a blue one, remember the power of A/B testing. Your success might just depend on such fine details.</p><p>Thank you for joining me on this intriguing journey into the numerical world of A/B testing. Here’s to your next successful test, and may the odds always be in your favor!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3714c13ef231" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encoding Techniques for Categorical Attributes]]></title>
            <link>https://medium.com/@SaxenaSaksham/encoding-techniques-for-categorical-attributes-4dafaa18822a?source=rss-7b249093572e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4dafaa18822a</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-wrangling]]></category>
            <category><![CDATA[categorical-encoding]]></category>
            <category><![CDATA[data-cleaning]]></category>
            <dc:creator><![CDATA[Saksham Saxena]]></dc:creator>
            <pubDate>Thu, 03 Nov 2022 05:17:37 GMT</pubDate>
            <atom:updated>2022-11-03T05:17:37.939Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*x9R-Iwnb4QiyGOJK.jpg" /></figure><p>When performing a classification analysis, the dependent variable is commonly affected by both qualitative (nominal scale) and ratio scale variables. It is required to encode these categorical variables into numerical values using encoding techniques because machine learning algorithms only take numerical inputs. This blog describes nine different categorical variable encoding methods that can be applied to a categorical dataset.</p><p>The different types of encoding techniques are:</p><ol><li>One Hot Encoding</li><li>Label Encoding</li><li>Multi label Binarizer</li><li>Leave One Out Encoding</li><li>Hashing Encoding</li><li>Weight of Evidence</li><li>Helmert Encoding</li><li>Cat Boost Encoding</li><li>James Stein Encoding</li><li>M Estimator Encoding</li><li>Sum Encoder</li></ol><p>ONE HOT ENCODING</p><p>The most popular encoding approach is known as One Hot Coding. Every level of the categorical variable is compared to a predetermined reference level. A single variable with n observations and d different values is converted into d binary variables with n observations each using a single hot encoding. Each observation shows whether the dichotomous binary variable is present or absent.</p><p>Dataframe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/132/1*85Ah8Re3zRI-8XYc4Z2u1w.png" /></figure><p>After One Hot encoding</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*3XzpqOHbEciFYc3MQ2zHMg.png" /><figcaption>The presence of 0 and 1 delineates the absence and presence of a particular gender respectively for different rows of a Dataframe</figcaption></figure><p>Code:</p><p>new_df=pd.get_dummies(columns=[‘Sex’], data=df)</p><p>‘get_dummies’ is the function that converts the ‘Sex’ column into dummy variables</p><p>2. Label Encoding:</p><p>Each label of a categorical data variable is allocated to the most appropriate integer number in the label encoding technique. Although this approach is quite straightforward, it might be challenging to identify the appropriate assignment for a given issue (especially with categorical variables representing unordered data). While label encoding transforms the data into machine-readable form, it also gives each class of data a distinct number (beginning at 0). This could cause priority concerns to emerge during the training of data sets. A label with a high value could be given more priority than one with a low value.</p><p>Dataframe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/140/1*12r94FNO-YtdkBIan_i4vw.png" /></figure><p>After Label Encoding:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/1*5hHmbF-NyhuXh5aA2-KeuQ.png" /><figcaption>0,1,2 represents Female, Male, Non/binary respectively</figcaption></figure><p>Code:</p><p>from sklearn.preprocessing import LabelEncoder</p><p>le=LabelEncoder()</p><p>df[‘Sex’]=le.fit_transform(df[‘Sex’])</p><p>‘LabelEncoder ’ is the function that encodes categorical column ‘sex’ to numerical value.</p><p>3.Label Binarizer</p><p>In a matrix where each variable is represented as a column, LabelBinarizer converts each variable to binary. In other words, it will convert a list into a matrix with exactly as many columns as there are unique values in the input collection.<br>The output matrix, which has each of the input labels [1, 10, 12] as a column, is a three-column matrix. then it will be indicated (binary) whether your instances (observations) relate to label 1 or 10 or 12 if they are any of the numbers 1, 10, or 12.</p><p>Dataframe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/127/1*ytzGd9dm5n3pfGx8dXfYyg.png" /></figure><p>After Label Binarizer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/160/1*kqmq2wrKSCs3pGB2OTGzeA.png" /><figcaption>Label Binarizer is similar to One hot encoding, the resultant is in the form of an np.array rather than a Dataframe</figcaption></figure><p>Code:</p><p>from sklearn.preprocessing import LabelBinarizer<br>lb = LabelBinarizer()<br>new_df[‘Sex’]=lb.fit_transform(df[‘Sex’])</p><p>‘LabelBinarizer ’ is the function that encodes categorical column ‘Sex’ to an np.array.</p><p>4.Leave one out Encoding</p><p>When using Leave One Out encoding, all the records with the same value for the target categorical feature variable are essentially averaged to determine the mean of the target variables. Between the training data set and the test data set, the encoding algorithm differs slightly. The record being considered is excluded from the training data set, thus the name “Leave One Out.” The definition is slightly different for validation data or a set of prediction data. The randomization factor is not necessary, nor do we have to disregard the present record.</p><p>The encoding for a specific value of a specific categorical variable is as follows.</p><p><em>ci = (Σj != i tj / (n — 1 + R)) x (1 + εi) where</em><br> <em>ci = encoded value for ith record</em><br> <em>tj = target variable value for jth record</em><br> <em>n = number of records with the same categorical variable value</em><br> <em>R = regularization factor</em><br> <em>εi = zero mean random variable with normal distribution N(0, s)</em></p><p>Dataframe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/1*I4Rbnc8PtX4TitlD1E2JhA.png" /></figure><p>After Leave one out Encoding:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*PVEw7oA4PZjvIwf1g7QkYQ.png" /><figcaption>Column ‘value’ represents the mean value of the particular department</figcaption></figure><p>Code:</p><p>Creating the Dataframe</p><p><strong>import pandas as pd;<br>data = [[‘1’, 120], [‘2’, 120], [‘3’, 140], <br> [‘2’, 100], [‘3’, 70], [‘1’, 100],[‘2’, 60], <br> [‘3’, 110], [‘1’, 100],[‘3’, 70] ]<br>df = pd.DataFrame(data, columns = [‘Dept’,’Yearly Salary’])</strong></p><p>Encoding the department column</p><p><strong>import category_encoders as ce<br>tenc=ce.TargetEncoder() <br>df_dep=tenc.fit_transform(df[‘Dept’],df[‘Yearly Salary’])<br>df_dep=df_dep.rename({‘Dept’:’Value’}, axis=1)</strong></p><p>Joining the old and new dataframe</p><p><strong>df_new = df.join(df_dep)</strong></p><p>‘<strong>category_encoders</strong>’ is the library that encodes the categorical column</p><p>5. Hashing</p><p>When a hash function is used, a string of characters is converted into a single, unique hash value. This method is highly helpful because it uses little memory and can handle more categorical data. For managing sparse, high-dimensional features in machine learning, feature hashing is a potent approach. It is suitable for use in online learning scenarios and is quick, easy, memory-efficient, and speedy. It is an approximation, but in many machine learning problems, the accuracy tradeoffs are surprisingly modest.</p><p>The fundamental concept underlying feature hashing is rather straightforward: rather than retaining a one-to-one mapping of categorical feature values to positions in the feature vector, we utilize a hash function to locate the feature in a vector of dimensions.</p><p>One-hot encoding, for instance, would provide each potential feature value a unique index in the feature vector, translating a feature with one million possible values to a vector size of one million (that is, one index into the vector for each feature value). The same feature, which has a million possible values, might be hashed into a vector with a substantially smaller size, such as 100,000 or even 10,000, if we utilize feature hashing.</p><p>Dataframe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*wQXTie7EE8NxENb1YO0dtg.png" /></figure><p>Github link:</p><p>After hashing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*IySMljvC51r2Z6sr62hY-A.png" /></figure><p>Code:</p><p>from sklearn.feature_extraction import FeatureHasher<br># n_features contains the number of bits you want in your hash value.<br>h = FeatureHasher(n_features = 3, input_type =’string’)<br># transforming the column after fitting<br>hashed_Feature = h.fit_transform(df[‘nom_0’])<br>hashed_Feature = hashed_Feature.toarray()<br>df = pd.concat([df, pd.DataFrame(hashed_Feature)], axis = 1)<br>df.head(10)</p><p>‘FeatureHasher’ is the library that hash encode the attribute</p><p>6. Weight of Evidence Encoding</p><p>Weight of Evidence (WoE) evaluates a grouping technique’s “strength” in identifying good from bad. The primary goal of this technique’s development was to create a predictive model for assessing the risk of loan default in the credit and financial industries. How much the evidence bolsters or refutes a theory is determined by its weight of evidence, or WOE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*abWK1xdBPzL2Q1OFWVMrQQ.png" /></figure><p>If P(Goods) / P(Bads) = 1, WoE is 0. If the result is random for that group, that is. If P(Bads) &gt; P(Goods), the odds ratio is 1, and the weight of evidence (WoE) is 0. If, however, P(Goods) &gt; P(Bads) in a group, the WoE is greater than 0.</p><p>Because the Logit transformation is just the log of the odds, or ln(P(Goods)/P(Bads)), WoE is ideally suited for Logistic Regression. As a result, the predictors are prepared and coded to the same scale when used in Logistic Regression with WoE-coded predictors. It is possible to compare the variables in the linear logistic regression equation directly.</p><p>Dataframe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/112/1*PX2RqzoGh8X17ex0iNNNlg.png" /></figure><p>After Weight of evidence encoding:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/98/1*-Kx7G7dw-MhTWl0bz_Av3g.png" /></figure><p>Code:</p><p>from category_encoders import WOEEncoder<br>df = pd.DataFrame({‘cat’: [‘a’, ‘b’, ‘a’, ‘b’, ‘a’, ‘a’, ‘b’, ‘c’, ‘c’], ‘target’: [1, 0, 0, 1, 0, 0, 1, 1, 0]})<br>woe = WOEEncoder(cols=[‘cat’], random_state=42)<br>X = df[‘cat’]<br>y = df.target<br>encoded_df = woe.fit_transform(X, y)</p><p>‘WOEEncoder’ is the library that calculate the weigth of different categories</p><p>7. Helmert Encoding:</p><p>The dependent variable’s mean for a level is compared to the dependent variable’s mean across all earlier levels in this encoding.</p><p>Reverse Helmert Coding is another name for the variant in category encoders. The dependent variable’s level-specific mean is compared to its level-average mean across all preceding levels.</p><p>Dataframe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/173/1*79y0BD20kLBeXW2echmCHA.png" /></figure><p>After Helmert Encoding over Dept:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*ye2V77qgfs-rwoUfkdpyvg.png" /></figure><p>Code:</p><p>import category_encoders as ce<br>encoder=ce.HelmertEncoder(cols=’Dept’)<br>new_df=encoder.fit_transform(df[‘Dept’])<br>new_hdf=pd.concat([df,new_df], axis=1)<br>new_hdf</p><p>‘Helmert Encoder’ is the library that encodes the categorical dept into numerical value</p><p>8. Cat Boost Encoding:</p><p>A common method for category encoding is target encoding. A categorical feature is replaced with the average value of the target assigned to that category in the training dataset along with the target probability calculated across the entire dataset. However, since the target is needed to anticipate the target, this results in a target leakage. These models frequently exhibit overfitting and perform poorly when applied to novel situations.</p><p>Target leaking is a problem that a CatBoost encoder attempts to solve by using an ordering concept in addition to target encoding. It operates on a similar principle to time series data validation. Target probability for the current feature is only calculated from the rows (observations) before it, meaning that the values of target statistic depend on the observed history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/1*MG-sZCIq0RinMR0SbppFoQ.png" /></figure><p>TargetCount: The total of the target value for a certain categorical feature (upto the current one).</p><p>Prior: Its value is constant and is denoted by (total number of observations (i.e. rows) in the dataset)/(sum of goal values throughout the whole dataset).</p><p>FeatureCount: The total number of categorical features that have been seen and have the same value as this one up to this point.</p><p>Dataframe</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/1*gxbQX_tBYSsz8cre66uHOQ.png" /></figure><p>After Catboosting Encoding:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/1*Wd6qK6CDtHlhzZ5wMFDyGA.png" /></figure><p>Code:</p><p>import category_encoders<br>category_encoders.cat_boost.CatBoostEncoder(verbose=0, <br>cols=None, drop_invariant=False, return_df=True, <br>handle_unknown=’value’, handle_missing=’value’, <br>random_state=None, sigma=None, a=1)</p><p>target = df[[‘target’]]<br>train = df.drop(‘target’, axis = 1)<br> <br># Define catboost encoder<br>cbe_encoder = ce.cat_boost.CatBoostEncoder()<br> <br># Fit encoder and transform the features<br>cbe_encoder.fit(train, target)<br>train_cbe = cbe_encoder.transform(train)</p><p>9. James Stein Encoding:</p><p>The James-Stein estimator provides the following weighted average for feature value:</p><p>The average target value for the feature value that was observed.<br>The average desired value (regardless of the feature value).</p><p>The average is shrunk toward the global average by the James-Stein encoder. This encoder is target-based. However, the James-Stein estimator has one practical drawback: it was only defined for normal distributions.</p><p>Disadvantage:</p><p>It can only be defined given a normal distribution (which is not the case in real time).<br>To prevent it, we can either utilize beta distribution or convert binary targets using a log-odds ratio, as was done in WOE Encoder (which is used by default because it is straightforward).</p><p>10: M Estimator Encoding:</p><p>A more straightforward variant of Target Encoder is M-Estimate Encoder.<br>It just contains one hyperparameter, m, which stands for the regularization power.<br>A larger m number produces stronger shrinkage.<br>The recommended range of values for m is 1 to 100.</p><p>11. Sum Encoder</p><p>Sum Encoder compares the dependent variable’s (target’s) mean for a specific level of a categorical column to the target’s overall mean. Both Sum Encoding and OHE are frequently employed in models of the linear regression (LR) variety. The interpretation of LR coefficients in the two models differs, with the Sum Encoder model’s intercept representing the overall mean (across all conditions) and the coefficients being easily understood as the main effects. In the OHE model, the intercept represents the mean for the baseline condition, and the coefficients represent simple effects (the difference between one particular condition and the baseline).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4dafaa18822a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resume-Parser-using-spaCy-deployment-using-Paperclip]]></title>
            <link>https://medium.com/@SaxenaSaksham/resume-parser-using-spacy-deployment-using-paperclip-20601fca9329?source=rss-7b249093572e------2</link>
            <guid isPermaLink="false">https://medium.com/p/20601fca9329</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[resume-parser]]></category>
            <category><![CDATA[resume-parser-software]]></category>
            <category><![CDATA[ocr]]></category>
            <dc:creator><![CDATA[Saksham Saxena]]></dc:creator>
            <pubDate>Wed, 02 Nov 2022 14:02:37 GMT</pubDate>
            <atom:updated>2022-11-02T14:02:37.744Z</atom:updated>
            <content:encoded><![CDATA[<p>This project uses Python’s library, SpaCy to implement various NLP (natural language processing) techniques like tokenization, lemmatization, parts of speech tagging, etc., for building a resume parser in Python. Considering all the resumes are submitted in PDF format, we’ll how to implement optical character recognition (OCR) for extracting textual data from the documents.</p><p>Importing the train and test dataset in the form of json file:</p><pre>import utils<br><br># function to read the data<br>def read_data():<br>    train=utils.convert_json_to_spacy(&quot;D:\\ProjectProd\\Resume_Parser\\input\\train_1.json&quot;) # train file<br><br>    test=utils.convert_json_to_spacy(&quot;D:\\ProjectProd\\Resume_Parser\\input\\test.json&quot;)     # test file<br><br>    return train,test</pre><p>Converting Json format to Spacy format</p><pre>import json<br>import os<br>import json<br>import random<br>import logging<br>from sklearn.metrics import classification_report<br>from sklearn.metrics import precision_recall_fscore_support<br>from spacy.gold import GoldParse<br>from spacy.scorer import Scorer<br><br># function to convert data <br>def convert_data_to_spacy(JSON_FilePath):<br>    try:<br>        training_data = [] # create an empty list for training data<br>        lines=[]<br>        with open(JSON_FilePath, &#39;r&#39;,encoding=&#39;utf-8&#39;) as f: # open the json file<br>            lines = f.readlines()<br><br>        for line in lines:<br>            data = json.loads(line)<br>            text = data[&#39;content&#39;]<br>            entities = []<br>            for annotation in data[&#39;annotation&#39;]:<br>                #only a single point in text annotation.<br>                point = annotation[&#39;points&#39;][0]<br>                labels = annotation[&#39;label&#39;]<br>                # handle both list of labels or a single label.<br>                if not isinstance(labels, list):<br>                    labels = [labels]<br><br>                for label in labels:<br>                    <br>                    entities.append((point[&#39;start&#39;], point[&#39;end&#39;] + 1 ,label))<br><br><br>            training_data.append((text, {&quot;entities&quot; : entities}))<br><br>        return training_data<br>    except Exception as e: # in case of exception print-<br>        logging.exception(&quot;Unable to process &quot; + JSON_FilePath + &quot;\n&quot; + &quot;error = &quot; + str(e))<br>        return None</pre><p>Building a function to extract Keywords from the Dataset(Entity Recognition)</p><pre>import spacy<br>import re<br><br>#Function to extract names from the string using spacy<br>def extract_name(string):<br>    r1 = unicode(string)<br>    nlp = spacy.load(&#39;xx_ent_wiki_sm&#39;) # load the model<br>    doc = nlp(r1)<br>    for ent in doc.ents:<br>        if(ent.label_ == &#39;PER&#39;):<br>            print(ent.text)<br>            break<br>#Function to extract Phone Numbers from string using regular expressions<br>def extract_phone_numbers(string):<br>    r = re.compile(r&#39;(\d{3}[-\.\s]??\d{3}[-\.\s]??\d{4}|\(\d{3}\)\s*\d{3}[-\.\s]??\d{4}|\d{3}[-\.\s]??\d{4})&#39;)<br>    phone_numbers = r.findall(string)<br>    return [re.sub(r&#39;\D&#39;, &#39;&#39;, number) for number in phone_numbers]<br><br><br>#Function to extract Email address from a string using regular expressions<br>def extract_email_addresses(string):<br>    r = re.compile(r&#39;[\w\.-]+@[\w\.-]+&#39;)<br>    return r.findall(string)</pre><p>Building a function to extract the text under the keywords extracted in the previous section</p><pre>from tika import parser<br>import os<br><br># function for text convertion <br>def convert_pdf_to_text(dir):<br>    output=[]<br>    for root, dirs, files in os.walk(dir):<br>        print(files)<br>        for file in files:<br>            path_to_pdf = os.path.join(root, file)<br>            #print(path_to_pdf)<br>            [stem, ext] = os.path.splitext(path_to_pdf)<br>            if ext == &#39;.pdf&#39;:<br>                print(&quot;Processing &quot; + path_to_pdf)<br>                pdf_contents = parser.from_file(path_to_pdf,service=&#39;text&#39;)<br>                path_to_txt = stem + &#39;.txt&#39;<br>                # with open(path_to_txt, &#39;w&#39;,encoding=&#39;utf-8&#39;) as txt_file:<br>                #     print(&quot;Writing contents to &quot; + path_to_txt)<br>                #     txt_file.write(pdf_contents[&#39;content&#39;])<br>                output.append(pdf_contents[&#39;content&#39;])<br>    return output</pre><p>Training the model on the dataset</p><pre>import spacy<br>import random<br>from spacy.util import minibatch, compounding<br><br># function to train the model<br>def build_spacy_model(train,model):<br><br>    if model is not None:<br>        nlp = spacy.load(model)  # load existing spaCy model<br>        print(&quot;Loaded model &#39;%s&#39;&quot; % model)<br>    else:<br>        nlp = spacy.blank(&quot;en&quot;)  # create blank Language class<br>        print(&quot;Created blank &#39;en&#39; model&quot;)<br><br>    TRAIN_DATA =train<br>    #nlp = spacy.blank(&#39;en&#39;)  # create blank Language class<br>    # create the built-in pipeline components and add them to the pipeline<br>    # nlp.create_pipe works for built-ins that are registered with spaCy<br>    if &#39;ner&#39; not in nlp.pipe_names:<br>        ner = nlp.create_pipe(&#39;ner&#39;)<br>        nlp.add_pipe(ner, last=True)<br>    else:<br>        ner = nlp.get_pipe(&quot;ner&quot;)<br>       <br><br>    # add labels<br>    for _, annotations in TRAIN_DATA:<br>         for ent in annotations.get(&#39;entities&#39;):<br>            ner.add_label(ent[2])<br><br>    # get names of other pipes to disable them during training<br>    other_pipes = [pipe for pipe in nlp.pipe_names if pipe != &#39;ner&#39;]<br>    with nlp.disable_pipes(*other_pipes):  # only train NER<br>        if model is None:<br>            optimizer = nlp.begin_training()<br>        for itn in range(2):<br>            print(&quot;Starting iteration &quot; + str(itn))<br>            # random.shuffle(TRAIN_DATA)<br>            # losses = {}<br>            # batches = minibatch(TRAIN_DATA, size=compounding(8., 32., 1.001))<br>            # for batch in batches:<br>            #     texts, annotations = zip(*batch)<br>            #     nlp.update(texts, annotations, sgd=optimizer, <br>            #                losses=losses)<br>            # print(&#39;Losses&#39;, losses)<br>            random.shuffle(TRAIN_DATA)<br>            losses = {}<br>            for text, annotations in TRAIN_DATA:<br>                    try:<br>                        nlp.update(<br>                            [text],  # batch of texts<br>                            [annotations],  # batch of annotations<br>                            drop=0.2,  # dropout - make it harder to memorise data<br>                            sgd=optimizer,  # callable to update weights<br>                            losses=losses)<br>                    except Exception as e:<br>                        pass<br>            print(losses)<br>    <br>    nlp.to_disk(&quot;model&quot;)<br>    return nlp</pre><p>Testing the model on testing dataset</p><pre>import spacy<br>import text_extractor<br><br># function for prediction<br>def predict(path):<br>    #output={}<br>    nlp=spacy.load(&quot;model&quot;) # load the model<br>    test_text=text_extractor.convert_pdf_to_text(path) # convert<br>    for text in test_text:<br>        text=text.replace(&#39;\n&#39;,&#39; &#39;) # replace<br>        doc = nlp(text)<br>        for ent in doc.ents:<br>            print(f&#39;{ent.label_.upper():{30}}-{ent.text}&#39;)<br>            #output[ent.label_.upper()]=ent.text<br>    #return output</pre><p>Templating all the functions thru a class ML_Pipeline</p><pre>from ML_Pipeline import json_spacy<br>from ML_Pipeline import train_model<br>from ML_Pipeline import predict_model<br>from ML_Pipeline import text_extractor<br>from ML_Pipeline import utils<br><br>#####First lets create training data out of the tagged data############<br><br>train= json_spacy.convert_data_to_spacy(&quot;D:\\ProjectProd\\Resume_Parser\\input\\training\\Entity Recognition in Resumes.json&quot;)<br><br>#print(train[0])<br>print(&quot;Done. Converted into spacy format&quot;)<br><br>print(&quot;Checking if previously built spacy model exists. If not, we will train a new one&quot;)<br><br>model=utils.check_existing_model(&quot;nlp_model&quot;)<br><br>model=train_model.build_spacy_model(train,model)<br><br>#test_text=text_extractor.convert_pdf_to_text(&quot;D:\\ProjectProd\\Resume_Parser\\output\\&quot;)<br><br><br>predict_model.predict(&quot;D:\\ProjectProd\\Resume_Parser\\output\\&quot;)<br><br><br>#mine = text_extractor.convert_pdf_to_text(&#39;D:\\ProjectProd\\Resume_Parser\\input\\resumes\\resumes&#39;)<br><br>#print(test.head())</pre><p>The resulting application requires minimum human intervention to extract crucial information from a resume, such as an work experience, name, skills, etc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20601fca9329" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stock market forecasting using ARIMA time series analysis]]></title>
            <link>https://medium.com/@SaxenaSaksham/stock-market-forecasting-using-arima-time-series-analysis-fac7f7d27c6a?source=rss-7b249093572e------2</link>
            <guid isPermaLink="false">https://medium.com/p/fac7f7d27c6a</guid>
            <category><![CDATA[cnn-model]]></category>
            <category><![CDATA[arima]]></category>
            <category><![CDATA[artificial-neural-network]]></category>
            <category><![CDATA[stock-prediction]]></category>
            <category><![CDATA[time-series-analysis]]></category>
            <dc:creator><![CDATA[Saksham Saxena]]></dc:creator>
            <pubDate>Mon, 18 Jul 2022 15:58:51 GMT</pubDate>
            <atom:updated>2022-07-18T15:58:51.981Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*frAek9FRfvp228QT2zWO3w.png" /></figure><h3>Abstract</h3><p>To earn or to trade one can visit a stock market which is considered to be a marketplace that is generally working on the exchanges which are made related to the purchasing of stock to the sale of one or more stocks depending on the buyer and the seller. It is an intermediate for the buyer and the seller to keep an account of the exchanges and the trade that is being done between both parties. It has a big impact on the economy as it can give rise to a company’s growth which indirectly gives rise to the economy of a particular country and the nation and also to the individual to growth in long and short terms.ARIMA models are known to be more durable and more accurate than the popular techniques which include artificial neural networks, and different types of forecasting which are done in the long and especially in the short term. The ARIMA is a moving average-based concept which is highly used in the markets as a great indicator to notice the price of the stock if it will move up or move down according to the trend that has been followed by the stock. Hence, rather than using conventional machine learning and deep learning approaches, we have tried to use the ARIMA approach to predict the further output of a particular stock. Finally, a comparison with the CNN model and ANN model is also presented to show the difference between the algorithms, and their use.</p><p><strong>I. INTRODUCTION</strong></p><p>The stock prediction will always be a worthwhile read for experts to investigate. It has attracted the researchers’ curiosity in developing stronger prediction models regularly. In finance and economics, stock price prediction is a hot issue. Financial organizations and individual investors require an effective approach to making daily decisions based on forecasts. Because of the complicated structure of stock market investment risk, price prediction is considered one of the most challenging tasks in financial forecasting[9]. Forecasting stock prices has become an appealing hobby for investors who want to receive the greatest results from the stock market. As a result, various models and strategies for predicting stock values have been created in recent years. Data in time series are points listed in time order, which is a sequence of discrete-time spaced evenly points in time, where forecasting is done by evaluating observed points in the series and projecting the future. From the standpoint of statistical models, ARIMA (Autoregressive Integrated Moving Average) models are used. The prediction may be done from two angles, according to the literature: statistics and artificial intelligence approaches[2]. ARIMA models are recognized to be more recovering and better than the compared models which are present out there in the market based on the short-term predictions and also the long-term predictions done by an entity. It is widely utilized in the fields of economics and finance. The regression method, simple exponential, and generalized autoregressive conditional heteroskedasticity are examples of other statistics models (GARCH).</p><p>II. RELATED WORK</p><p>According to a research work in which they collected stock price data of State Bank Of India (SBI) collected from Yahoo Finance from a period starting from 20th January 2014 to 20th January 2016. The detailed explanation of the approach utilized in the study to construct the ARIMA model for stock price prediction is For the period of 20.01.14 to 30.10.14, the original data for the SBI stock was split in the ratio of 1:10, The Dickey-Fuller Test is used to check for data stationarity, The selected data was discovered to be non-stationary, thus it was made stationary by obtaining the first and second differences at the same time, The optimal ARIMA model was determined by interpreting data and analyzing graphics and The following criteria are utilized in this study for each stock index to find the best ARIMA model among multiple tests done. The nonstationary nature of the series may be seen in the graph above. As a result, the BSE’s opening price of SBI stock is subject to the Augmented Dickey-Fuller (ADF) unit root test. After the first difference in the data, the series becomes stationary, as shown by the result. A model called the Auto-Regressive Integrated Moving Average (ARIMA) characterizes time series based on observed values and can be used to estimate future values. When ARIMA models are applied to any time series, patterns emerge that are free of random white noise and nonseasonal[1]. According to another forecasting stock marketing ARIMA Model, analyzing a series, mean, and covariance to see if the mean is increasing over time is a typical method of discovering a unit root. Another option is to use the t-test and F test to see if the autocorrelation function (ACFs) for the variable tends to zero as the lag duration grows. The variable is stationary if the ACFs converge to zero soon; otherwise, the variable is non-stationary. The Dickey-Fuller (DF) test is another well-known approach for determining non-stationary status. The test investigates whether the variable under consideration has a unit root and, as a result, should be represented in the first difference form. Fitting an autoregressive integrated moving average (ARIMA) model to the provided set of data and then taking conditional expectations is the basis for this approach[7]. The Box-Jenkins technique is a collection of processes for identifying, estimating, and diagnosing ARIMA models with time-series data using the Box-Jenkins approach. Forecasts are derived directly from the fitted model’s form. Fitting an autoregressive integrated moving average (ARIMA) model to the provided set of data and then taking conditional expectations is the basis for this approach. The Box-Jenkins technique is a collection of processes for identifying, estimating, and diagnosing ARIMA models with time-series data using the Box-Jenkins approach. Forecasts are derived directly from the fitted model’s form[2].In [3] The identification stage involves determining whether the time series data is stationary or not, as well as comparing the estimated Autocorrelation Function (ACF) and Partial Autocorrelation Function (PACF) to see if there is a match. We chose the ARMA process whose theory ACF and PACF best match the estimated ACF and PACF as a tentative model followed by Nonlinear least squares and maximum likelihood estimates are the two major methodologies for fitting Box-Jenkins models. Maximum likelihood, which is arithmetically correct for time series, is commonly used to estimate parameters. For Gaussian distributions, estimators are always sufficient, efficient, and consistent, while for various non-Gaussian distributions, estimators are asymptotically normal and efficient and Diagnostic testing is required to ensure that the chosen model is appropriate[4]. The values of specific criteria, such as likelihood function, Akaike Information Criteria (AIC), Bayesian Information Criteria (BIC), and Schwarz-Bayesian Information Criteria (SBIC), can be used to pick a model (SBC)[11].</p><p>III. METHODOLOGY</p><p>A. Data preparation</p><p>The dataset taken into account contains full historical daily price and volume data for all U.S.-based stocks from the year 2005 to 2017. As it’s tough to get real-time stock data and test it on it, we take a dataset of US stocks and try to test different models on it and prove the results through it. This dataset has 3201 data (or rows) and 6 features (or columns). A dataset is a collection of data in a structured way to show data in an easy way. Features of the dataset are Open, High, Low, Close, and Volume B. Data Preprocessing: Dataset is analysed (or preprocessed) before making any conclusion and training ML models. After analysing it was found that all 6 features are numerical features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*apTJQt90vW-rbahTn_QKEQ.png" /></figure><p>B. Data Preprocessing:</p><p>TDataset is analysed (or preprocessed) before making any conclusion and training ML models because if we avoid that then some unwanted data will also be trained which will affect our ML model and its accuracy which we won’t want to happen. After analysing it was found that all 6 features are numerical features. Numerical features are those types of features that have values continuous or integer related.</p><p>C. Feature Visualization</p><p>We find the trend of the ‘close’ price in the dataset in figure 2, whether it is increasing or decreasing from the year 2005 to 2017. We can conclude that it is increasing. We find the stationarity of the data. Data is called stationary when some of its essential property like mean, variance and autocorrelation structure doesn’t change with time. In real-life time series are non-stationary, the value of important properties of data changes over time. From figure 3 we can see that the mean and standard deviation are changing with time, it means that the series is not stationary. Time series analysis requires the 4 most important features to be checked which are levels for the stocks, a trend followed by the stock and the noise which is present along with the seasonality. The trend which is being followed is a pattern of rising and falling of the values which are there in the series along with an important part which is seasonality that is present in the short-term cycle of the series. For the TSA to happen successfully one has to discard the two things which include the seasonality of the stocks and also the trend that has been occurring from the series. To shorten the size of the values and the increasing trend line which can be seen in the series is why we take the log function of the series and after which calculation of the average of the series which is performed is obtained with the help of the log function.</p><p>D. Model Architecture</p><p>The ARIMA model is basically used for predictive forecasting of the problem statement that is present out there. The AR in the model name is for autoregression which means that a variable can be changed which is regressed on its own or in other terms it is used to forecast the future outcomes based on the past outcomes. The I in the model name is to just see the difference between the static values and the values previous to it. The main aim is to get stationary data which is not subject to any season change that occurs. The math properties of the series which include the mean value, variance of the value and autocorrelation are very constant. And finally, the MA is dependent on the value which is observed and the residual error. After following all this the visualisation of the time series data takes place followed by the finding of the stationary variable which is the date in this case and then constructing an ARIMA model along with a seasonally ARIMA model based on the data that is present or available. After performing the ARIMA we further move to ANN in which the neurons which are artificial in this case are not numerical by a math function that works on computing the sum of the inputs as well as the outputs. Each layer of a ConvNet produces numerous activation maps when you feed it an image. Activation maps bring focus to the image’s most important aspects. The same process is followed by the convolution neural network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*_VHi6ERL6PMwdZPfU0LZ6g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*OqVhXuAKZ96qU_sKHflQUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*P90Vw8BFz1q7lQqCS-YL6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*J3D0fcV1K2HpDc7NUBDdVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*BiJsKFyKpXMmZnO59Womjg.png" /></figure><p>IV. EXPERIMENTAL RESULTS</p><p>After all the forecasting algorithms that have been performed by taking the seasonal variable into consideration, we get four results which are MSE which is the mean square error followed by MAE which is the mean absolute error followed by RMS is the root mean square error and map which is mean absolute percentage error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*YgUp9Xwf2ff5kCGzBoglvQ.png" /></figure><p>V. CONCLUSION</p><p>The article summarises a forecasting algorithm known as ARIMA and tried to predict the future of stocks or the direction that is going to be followed by the stock. Followed by a comparison between the convolution neural network approach, artificial neural network approach and the ARIMA algorithm. Hence, after the comparison, it can be safely concluded that the ARIMA method suits the best for the following problem statement..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fac7f7d27c6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep learning using Convolutional Neural Network]]></title>
            <link>https://medium.com/@SaxenaSaksham/deep-learning-using-convolutional-neural-network-f2166dea1d2d?source=rss-7b249093572e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2166dea1d2d</guid>
            <category><![CDATA[convolutional-neural-net]]></category>
            <category><![CDATA[deep-learning-using-cnn]]></category>
            <category><![CDATA[image-classification]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Saksham Saxena]]></dc:creator>
            <pubDate>Mon, 18 Jul 2022 14:44:36 GMT</pubDate>
            <atom:updated>2022-07-18T14:44:36.688Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hiBDE4DqspUZ2MkFVjQevg.png" /><figcaption>CNN Architecture</figcaption></figure><h3><strong>Introduction</strong></h3><p>Artificial neural networks (ANN) with several layers are referred to as deep neural networks or deep learning. It has been regarded as one of the most potent tools over the last several decades and has gained a lot of popularity in the literature due to its ability to handle enormous amounts of data. Deeper hidden layers are now starting to outperform traditional approaches in a variety of applications, including pattern recognition. The Convolutional Neural Network is one of the most well-liked deep neural networks (CNN). Convolution is a mathematical linear action between matrices that gave rise to the term.</p><p>Convolutional, non-linear, pooling, and fully-connected layers are among the many layers that make up CNN. Pooling and non-linearity layers lack parameters, but convolutional and fully connected layers do(explained further in detail). In machine learning issues, CNN performs quite well. Particularly the image-related applications, such as the biggest image classification data set (Image Net), computer vision, and natural language processing (NLP), and the outcomes attained were truly astounding. The components of CNN, their functions, and all other significant problems will be discussed in detail in this essay. We will also list the factors that affect CNN’s effectiveness. This article makes the assumption that the readers are familiar with artificial neural networks and machine learning.</p><h3><strong>Data Augmentation Techniques</strong></h3><p>Data Augmentation or Image augmentation is a method of applying different transformations to original images which results in multiple transformed copies of the same image. Each copy, nonetheless, is unique in certain aspects, these subtle nuances depend upon the augmentation techniques applied to the data like rescaling, zooming, flipping, etc. These Geometric transformations are normally used to enhance the amount of sample for preparing the deep neural network model (Mitkowski et al., 2017; Kwasigroch et al.,2017 Jun), to adjust the size of datasets (Kwasigroch et al.,2017 Aug). The resulting augmentation of the dataset provides a new perspective of the data to the model and aids in bolstering the performance metrics of the model for its optimal performance (Wąsowicz et al.,2017). Combinations of relative picture modifications and shading (colour) alteration are the current standard practises for data augmentation (Mikołajczyk and Grochowski, 2018).</p><p><strong>1. Rescale</strong></p><p>In any dataset, some pictures are in the high pixel range, while some are low pixelated. Since the pictures altogether share the same model, loads and learning rate, the high pixelated pictures will generate a more significant loss while the low range makes a feeble loss, the total sum of which contributes to the backpropagation update. In order to reduce the difference in the contribution to the backpropagation loss, scaling each picture to a similar range of [0,1] is significant which makes all of them contribute equally to the complete loss. Rescale 1./255 is used to transform every pixel value from range [0,255] -&gt; [0,1].</p><p><strong>2. Horizontal and Vertical Flip</strong></p><p>An image flip is done by switching the rows and columns of pixels on account of a vertical and a horizontal flip respectively. The flip augmentation is determined by a Boolean, horizontal_flip or vertical_flip argument of the ImageDataGenerator (IDG) class constructor (Chollet,2016; Shorten and Khoshgoftaar,2019 ). Each flip engenders a new outlook of the data to the training model.</p><p><strong>3.</strong> <strong>Random Zoom Augmentation</strong></p><p>The random Zoom Augmentation method is manoeuvred to enlarge the images. This is done either by zooming in or by adding some pixels to the image (Shorten and Khoshgoftaar,2019 ). It results in generating an output of images of different heights and widths.</p><p><strong>4. Shear Range Augmentation</strong></p><p>Shear augmentation distorts the images along an axis to generate and/or rectify the perception angle (Shorten and Khoshgoftaar,2019).</p><h3><strong>The architecture of a Convolutional Neural Network</strong></h3><p><strong>1.</strong> <strong>Convolutional Layer</strong></p><p>The first layer of a Convolutional Neural Network (CNN) ie. Convolutional Layer performs a convolution on the input before forwarding the output to the next layer. It works in a totally different manner contrasted with the other neural organization layers. It generates new images called feature maps. The feature maps emphasize the features of the original image. This layer doesn’t utilize the connection weights and weighted sum, instead, it contains convolutional filters which yield feature maps. The convolution layer creates a similar number of feature maps as the convolution filters present (LeCun et al.,1989).</p><p><strong>2.</strong> <strong>Pooling Layer</strong></p><p>A pooling layer is the second layer in the architecture of the network. This layer diminishes the size of a picture, as it consolidates adjacent pixels of a specific territory of the picture into a single representative value. The size of the pooling operation or filter is smaller than the size of the feature maps. The pooling layer plays a significant role in providing a summarized version of the features detected in the input images. The representative value is typically set as the mean or maximum of the selected pixels (Phil, 2017; Gholamalinezhad and Khosravi,2020).</p><p><strong>3.</strong> <strong>Flatten Layer</strong></p><p>The fatten layer of the CNN converts the output of the convolutional and pooling layers into a 1D component vector, to be utilized by the Artificial Neural Network (ANN) part(Dense Layer) of the network. It conflates the input from previous layers and flattens its design to make a solitary long component vector to be utilized by the dense layer for the final classification (Jin et., 2017).</p><p><strong>4.</strong> <strong>Dense Layer</strong></p><p>The last layer of the CNN is a classifier, the Dense layer. This layer is nothing but an ANN. The Dense layer is a network layer that is connected deeply, suggesting that every neuron in the previous layers sends input to all the neurons of the dense layer. In the backdrop(background), the dense layer carries out a matrix-vector multiplication. The values utilized in the matrix are the parameters that can be updated with the assistance of the backpropagation to alter further the dimensions of the vector(Josephine et., 2021) The layer has a weight matrix W, a bias vector b, and the activations of the previous layer.</p><h3><strong>Activation functions</strong></h3><p>Activation functions are an important part of the planning of a neural network. The choice of the activation function within the hidden layer is used to manage the learning of the model from the training dataset. While the selection of the function in the output layer defines the type of prediction that model makes. The five most common activation functions in the hidden layer are-</p><p><strong>1.</strong> <strong>Rectified Linear Activation</strong></p><p>Rectified Linear Activation The Rectified Linear Activation (ReLU) is the most commonly used activation function considering that it is least susceptible to the vanishing gradients which hinder the training of the model. Furthermore, it is easier in implementing and circumventing the saturation limitations.</p><p><strong>2.</strong> <strong>Sigmoid</strong></p><p>Sigmoid The Sigmoid Function operates by taking a value of input and output between 0 and 1. It is non-linear and undemanding to work out when constructing a neural network model. 1.0 / (1.0 + e^-x) ▪ TanH It is similar to the sigmoid function. The hyperbolic tangent function operates by taking any input and output values in the range of 1 to -1. The output value depends on the input value; the larger the input value, the closer the output value to 1 while the smaller the input value, the output value is closer to -1. The Tanh activation function is calculated as follows:</p><p><em>(e^x — e^-x) / (e^x + e^-x)</em></p><p><strong>3.</strong> <strong>Hyperbolic Tangent</strong></p><p>The Tanh function (also “tanh” and “TanH”) is another name for the hyperbolic tangent activation function, very similar to Sigmoid Function. It even has the same S-shape like the Sigmoid activation function. Any real value may be used as an input, and the function returns values between -1 and 1.</p><p><strong>4.</strong> <strong>Linear</strong></p><p>Linear function The Linear function doesn’t modify the weighted sum of the input by any means and returns the value as it is.</p><p><strong>5.</strong> <strong>SoftMax</strong></p><p>SoftMax function The SoftMax function results in the generating of the vector values which total up to 1.0(100%) which can be elucidated as the probabilities of the class memberships. The SoftMax function is calculated as follows:</p><p><em>e^x / sum(e^x)</em></p><h3><strong>Model Compilation and Performance Evaluation Metrics for a classification model</strong></h3><ol><li><strong>Learning Rate</strong></li></ol><p>Deep Learning Neural Networks are trained using the stochastic gradient algorithm. The stochastic gradient descent algorithm is an associate degree optimization algorithm that estimates the error gradient on the basis of the training data, and then reconditions the weights of the model using simple backpropagation. This reconditioning of the weights is called the learning rate of the model. It is a hyperparameter that controls what proportion of the model is to be altered in response to the calculable error each time the model weights are upgraded(Takase et al., 2018; Bengio, 2012; Goodfellow et.,2016) Determining the Learning rate is an arduous process as a value too small could lead to a protracted training process that could thwart the performance, whereas a value too large would lead to learning of sub-par sets of weights too quickly and engendering a volatile training process. The Learning rate is a customizable hyperparameter with a positive value, typically within the range between 0.0 and 1.0.</p><p><strong>2.</strong> <strong>CNN Model Evaluation</strong></p><p>Models can be assessed using standards such as accuracy, specificity, sensitivity, and precision. Evaluation can be done by using any one of them or all of these parameters; for an imbalanced dataset a higher value can be obtained for one of these measurements, but lower scores might be obtained for the other metrics. Thus, it is important to take 2 or 3 of these metrics into consideration while assessing the performance of the CNN model. The metrics mentioned above can be calculated by the following equations</p><p>Accuracy = (TP+TN)/(TP+FP+FN+TN)</p><p>Sensitivity or Recall = TP/(TP+FN)</p><p>Specificity = TN/(TN+FP)</p><p>Precision = TP/(TP +FP)</p><p>TP and TN denote the true-positive and true-negative values, respectively; and FP and FN represent false-positive and false-negative values, respectively (Sokolova et al.,2006).</p><h3>Final Framework of the model</h3><p><strong>Structure of the CNN model</strong></p><p>This section presents the results obtained from the model compilation. Let’s assume, the size of each image is equal to (150,150,3). The Keras appends an additional dimension for the processing of the multiple batches in the training data in each step of one epoch. As the batch size can vary, the size is represented as None. Hence the shape becomes (None, 150, 150, 3)</p><p>Combining a (150,150) image with a (3,3) filter, with strides and dilation rate of 1, and ‘valid’ padding, results in an output of size (150–3 + 1, 150–3 + 1) = (148, 148). For 64 such filters, the output shape becomes (148, 148, 32).</p><p>Number of parameters = (3 x 3 x 3 x 64) + 64= 1792</p><p>The default Max-pooling kernel has a shape of (2, 2) and strides of (2, 2). Applying that to a (148,148) image the output results in an image (((148–2)//2) + 1, ((148–2)//2) + 1)) = (74, 74).</p><p>The output shape of the Conv2d and the Max-pooling layer of the subsequent layers is also calculated in a similar manner.</p><p>2nd Conv2d layer</p><p>(74–3 + 1, 74–3 + 1) = (72, 72)</p><p>Number of parameters = (3 x 3 x 128 x 64) +128 = 73856</p><p>2nd Max-pooling</p><p>(((72–2)//2) + 1, ((72–2)//2) + 1)) = (36, 36)</p><p>3rd Conv2d layer</p><p>(36–3 + 1, 36–3 + 1) = (34, 34)</p><p>Number of parameters = (3x 3 x 128 x 128) + 128 = 147584</p><p>The Flatten layer combines all the pixels on all the channels and creates a 1D vector. Therefore, an input of size (34, 34, 128) is converted into (34 x 34 x 128) = (147968)</p><p>The output of the dense layer would be (147968 x 128) + 128 = 18940032</p><p>Similarly for the next layer (128 x 5) + 5 = 645</p><p>The total number of parameters which can be manipulated and trained in the model are19,163,909.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*VMaDYkhsbxGB-ytScLasPQ.png" /><figcaption>Table delineating the structure of a CNN model</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2166dea1d2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>