<?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 Dheeraj Bajaj on Medium]]></title>
        <description><![CDATA[Stories by Dheeraj Bajaj on Medium]]></description>
        <link>https://medium.com/@decodingdheeraj?source=rss-3ecaa9e35c85------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Ugqx_slGLCUe_T1p.jpg</url>
            <title>Stories by Dheeraj Bajaj on Medium</title>
            <link>https://medium.com/@decodingdheeraj?source=rss-3ecaa9e35c85------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 22:29:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@decodingdheeraj/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[Pretend to be a Data Scientist for a day…]]></title>
            <link>https://decodingdheeraj.medium.com/pretend-to-be-a-data-scientist-for-a-day-5a4aef6be964?source=rss-3ecaa9e35c85------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a4aef6be964</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <dc:creator><![CDATA[Dheeraj Bajaj]]></dc:creator>
            <pubDate>Sat, 09 Mar 2019 18:30:12 GMT</pubDate>
            <atom:updated>2019-03-09T18:30:12.860Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s pretend that you are a recently hired Data Scientist in a company ….</p><p>Looking at the big picture .. The first task you are asked to perform is to build a model(Let’s say housing prices in India).This data has metrics such as population, income, housing prices and so on. Here your model should learn from this data and able to predict housing prices for new locations. So now what’s the first thing Data Scientist will do ?</p><h4>Frame the problem</h4><p>What exactly is the business use case ? How is your model going to benefit others ? Let’s say you get an answer that your model output (housing prices) will be fed to another ML model to finally predict whether its worth investing in that area or not. This means your output is extremely critical and directly affects revenue.</p><p>Okay, now first you need to frame your problem: <em>Supervised, Unsupervised , Semi, Reinforcement, Batch or Online Learning , Classification or Regression</em> … Which one to use ? If you don’t have any idea regarding this please go through my old blog <a href="https://medium.com/@dheerajbajaj.panasonic/the-fundamentals-of-machine-learning-d5d5c1bece80">https://medium.com/@dheerajbajaj.panasonic/the-fundamentals-of-machine-learning-d5d5c1bece80</a> Have you found the answer ?</p><p>Its clearly a <em>supervised learning</em> task since you are given labels i.e., housing prices, moreover its a <em>regression</em> problem and since you will use multiple features its <em>multivariate regression</em>. Finally, there is no continuous data so batch learning should be fine.</p><h4>Get the data</h4><p>Well getting data can be from any means (csv file, Database, API). <strong>Try creating small functions to fetch and load data</strong> :</p><pre><strong># Load Data to create Dataframe</strong><br>script_path = os.path.dirname(__file__)<br>parent_file = os.path.join(script_path, os.pardir)<br>data_test_path = os.path.join(parent_file, &#39;data&#39;, &#39;test.csv&#39;)<br>data_train_path = os.path.join(parent_file, &#39;data&#39;, &#39;train.csv&#39;)<br><br><strong># Function to Box plot test and train data</strong><br>def create_boxplot(path, rows):<br>    df_sub = pd.read_csv(path, sep=&#39;,&#39;, usecols=columns)<br>    df_sub[&#39;TESTId&#39;] = df_sub[&#39;TESTId&#39;].map(rows,   na_action=&#39;ignore&#39;)<br>    df_sub = scaler.fit_transform(df_sub)<br>    df_sub_2d = np.array(df_sub)<br>    x = pd.DataFrame(df_sub_2d, columns=columns)<br>    x = x.drop([&#39;TESTId&#39;], axis=1)<br>    return x</pre><p><strong>Its always best practices to make you framework generic</strong>.Therefore instead of using hardcoded test and train paths i have used <strong>os.path.join </strong>functions. <em>The above code might not be the best and optimised one so please bear with me. </em>Above function returns a dataframe for you.</p><h4>Analyse the data</h4><p>This function gives you several useful things all at the same time. For example, you will get the three quartiles, mean, count, minimum and maximum values and the standard deviation. This is very useful, especially in exploratory data analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*2c21SkzJMf3frPXPAR_gZA.png" /><figcaption>Image from <a href="https://cdn-images-1.medium.com/max/1600/1*2c21SkzJMf3frPXPAR_gZA.png">https://cdn-images-1.medium.com/max/1600/1*2c21SkzJMf3frPXPAR_gZA.png</a></figcaption></figure><p>Using boxplot we can get a multiple details ( <strong>Count , Max , min , quartiles, std , mean</strong> ). <strong>std</strong> measures how dispersed the values are. <em>25%, 50% and 75% indicates</em> the value below which a given percentage of observations in a group falls and correspondingly means <strong>1st quartile , 2nd and 3rd.</strong></p><pre>plt.subplot(2, 1, 1)<br>train_x = create_boxplot(data_train_path, train_rows)<br>train_x.boxplot(patch_artist=True)<br>plt.title(&#39;Training&#39;)<br><br>plt.subplot(2, 1, 2)<br>test_x = create_boxplot(data_test_path, test_rows)<br>test_x.boxplot(patch_artist=True)<br>plt.title(&#39;Test&#39;)</pre><p>Here <em>patch_artist=True</em> fill the boxplot with color , using subplot with <em>nrows</em> = 2 and <em>ncolumns</em> = 1</p><p>Below is a boxplot image of training and test set with multiple instances and columns (Native_Pss , Native_Private_Dirty …)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Q2EQb843_53fwm66VW3mw.png" /></figure><p>Lets check whats the standard deviation of each column in test and training set and finally create a bar plot</p><pre># Std plot<br>std_dict = {}<br>for i in range(0, 6):<br>    std_dict[columns[i + 1]] = [df_train_x.iloc[2, i], df_test_x.iloc[2, i]]<br>std_df = pd.DataFrame.from_dict(std_dict)<br>std_df_transpose = std_df.T<br>std_df_transpose = std_df_transpose.rename(index=str, columns={0: &quot;train&quot;, 1: &quot;test&quot;})<br>std_df_transpose[&#39;diff&#39;] = std_df_transpose[&#39;test&#39;] - std_df_transpose[&#39;train&#39;]<br>print &quot;Std diff b/w train and test (This should be as less as possible): &quot; + str(std_df_transpose[&#39;diff&#39;].mean())<br>std_df_transpose.plot.bar()<br>plt.title(&#39;ST.deviation b/w test and train&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*1ZRBnE19NzRs7s6UGmGloA.png" /></figure><p><strong>Conclusion</strong></p><p>Till now you have framed a problem by defining what kind of technique should be used ( Well we focused on EDA in this blog). Then learned best practices to load data and created function to fetch data. Finally analysing data using boxplots.</p><p><em>Finally Ending this blog with a key note that before using any Machine Learning model simply a data scientist dedicates 75% of time in doing Exploratory Data Analysis phase. We focused on a few. ( Try using Histogram , Scatter_Matrix for correlations , Transpose , Scaling and many more ). Goodbye !</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a4aef6be964" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Fundamentals of Machine Learning]]></title>
            <link>https://decodingdheeraj.medium.com/the-fundamentals-of-machine-learning-d5d5c1bece80?source=rss-3ecaa9e35c85------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5d5c1bece80</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Dheeraj Bajaj]]></dc:creator>
            <pubDate>Sat, 02 Mar 2019 10:12:43 GMT</pubDate>
            <atom:updated>2019-03-02T15:04:29.686Z</atom:updated>
            <content:encoded><![CDATA[<h3>Fundamentals of Machine Learning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*2STtjDV1V8qwGhy6Npeplg.jpeg" /></figure><p>In this blog I will go through the basics of ML and type of ML. Please go through the table of content</p><h4>What is Machine Learning ?</h4><p>Machine Learning is a science of programming codes to learn from data without being explicitly programmed.</p><p><strong>For example</strong>, detecting spam emails is one among hundreds ML programs out there. Here program learns which is a spam and nonspam email using data ( <em>training set</em>). Each training example is called <em>training instance</em> or <em>sample</em>. You can also measure performance of the program using accuracy check. In below plot we can clearly detect F2 and F1 is not as usual and so can be a spam</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*C8R01qRZHZ1isPrI" /><figcaption>Spam detection Plot</figcaption></figure><h4>Types of Machine Learning Systems</h4><p>Most commonly there are 3 broad categories :</p><ol><li>Supervised , Unsupervised, Semisupervised and Reinforcement Learning</li><li>Online versus batch learning</li><li>instance based versus model-based learning</li></ol><h4>Supervised Learning</h4><p>In <em>supervised learning</em>, the training data includes the desired output, called <em>labels.</em>The spam filter is a good example of it. This is a typical kind of supervised learning task called <em>classification. </em>Where in <em>Regression</em> you need to predict continuous <em>numeric</em> <em>target</em> or output.</p><figure><img alt="Image result for classification machine learning" src="https://cdn-images-1.medium.com/proxy/0*WE3Sz--1NUEWBmUR." /><figcaption>Classification Vs Regression</figcaption></figure><h4>Unsupervised Learning</h4><p>You might have guessed, yes the training data is unlabeled. Sharing you some most important unsupervised learning algorithms :</p><ol><li>Clustering using K-means, Hierarchical Cluster Analysis HCA</li><li>Visualization and dimensionality reduction using PCA , Kernal PCA , t-SNE etc.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gO5XCQHOroohN67w.png" /></figure><h4>Semisupervised Learning</h4><p>Some programs can deal with partially labeled training data, usually a lot of unlabeled data and a little bit of labeled data. For example auto face recognition of your photo in a group of photo</p><h4>Reinforcement Learning</h4><p>In this kind of learning system program learns from its mistakes. The learning system, called an <em>agent</em> can observe the environment, select and perform actions, and get <em>rewards</em> or <em>penalties</em>.It then learns by itself what is the best strategy, called a <em>policy</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/0*4jLyXi78KNpmxYXf" /></figure><h4>Batch learning Vs Online Learning</h4><p>In <em>batch learning</em> training is done using all the available data. This take a lot of time. Issue in this kind of learning is it runs without learning anymore and this also called as <em>offline learning. In Online learning </em>you train the system incrementally by feeding it data instances sequentially. In simple terms, system receives data as a continuous flow</p><h4>Instance-Based Vs Model-Based Learning</h4><p>In Instance based learning model simply learns all the train data and try to generalise to test data using similarity measures. K-nn is a Instance based model. In Model based way it builds a model from training set and then used for predictions. Linear mod</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vXeoNuhK5xFaJoQW.png" /><figcaption>Instance based — Knn regression</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jBaN3I-N9diM4B--.png" /><figcaption>Model Based</figcaption></figure><p><em>This ends my blog at this point. Hope it was easy enough to understand the basic concepts of Machine Learning. I would love to get your valuable feedbacks regarding improvements if any !</em></p><p>Here is a the link of my previous blog : Data Extraction from an Android App using Python <a href="https://medium.com/@dheerajbajaj.panasonic/data-extraction-from-an-android-app-using-python-60b0fde7d629">https://medium.com/@dheerajbajaj.panasonic/data-extraction-from-an-android-app-using-python-60b0fde7d629</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5d5c1bece80" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Extraction from an Android App using Python]]></title>
            <link>https://decodingdheeraj.medium.com/data-extraction-from-an-android-app-using-python-60b0fde7d629?source=rss-3ecaa9e35c85------2</link>
            <guid isPermaLink="false">https://medium.com/p/60b0fde7d629</guid>
            <category><![CDATA[android-performance]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Dheeraj Bajaj]]></dc:creator>
            <pubDate>Mon, 18 Feb 2019 16:33:55 GMT</pubDate>
            <atom:updated>2019-02-18T16:33:55.159Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/786/0*NSUiQH4LoDYNOkAy.jpg" /></figure><h3>Introduction</h3><p>Android Application performance metrics include ( Memory, CPU, Network, Systrace Analysis and many more .. ) Out of all memory is most important metric and can be used to create initial data</p><p><strong>Which part of memory is the most important one ?</strong></p><p>Screenshot from Android Profiler :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iVw1iEHAuKmr1o-u.png" /></figure><ul><li><strong>Java</strong>: Memory from objects allocated from Java or Kotlin code</li><li><strong>Code</strong>: Memory that your app uses for code and resources, such as dex bytecode, optimized or compiled dex code, .so libraries, and fonts</li></ul><p>Java and Code are the most important ones. We will concentrate on two for this blog</p><p><strong>How to perform Machine Learning in Android ?</strong><br>We will analyse Application Memory ( Java and Code ) of Benchmark App and Test App using Data Science</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*lhgPCBX67bbEVx0T.png" /><figcaption>Data Science Flow</figcaption></figure><p><strong>Steps involved :</strong></p><p>I have divided Blog into 3 parts : <br><strong>Part 1:</strong> Extracting data from Android , Creating Database , Inserting data which includes Classes and Features<br><strong>Part 2</strong>: Reading Data from database , Creating Dataframe, Doing Exploratory Data Analysis , Visualisation using Matplotlib, Creating Machine Learning model , Predicting Accuracy, Analysing using Confusion Matrix<br><strong>Part 3</strong>: Best Practices in Machine Learning, Framework to use …</p><h3>Part 1</h3><ol><li>Get data from Phone using Memory dumpsys ( Adb shell dumpsys meminfo — Package name)</li><li>Save data in database (Sqlite3)</li><li>Read data from db, convert into pandas dataframe</li></ol><p><strong>Get data from Android :</strong></p><p><strong>Command</strong> : adb shell dumpsys meminfo package_name|pid<br>The output lists all of your app’s current allocations, measured in kilobytes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*wfY0KGmFgdsTe1TC.png" /></figure><p><strong>Proportional Set Size (PSS) : </strong>This is a measurement of your app’s RAM use that takes into account sharing pages across processes.In general, be concerned with only the Pss Total and Private Dirty columns</p><p>Python Function which outputs a dictionary of memory distribution :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*1HPV3Qd7lkjWofZN.png" /></figure><p><strong>Save data in database (Sqlite3):</strong><br>Every android app contains multiple activities , For Android app performance analysis we should check memory consumption for each activity. Generally apps contain following screens :<br>1. Pin Screen <br>2. Home Screen <br>3. Detail Screen<br>4. Search Screen<br>and many more …</p><p>Now in terms of Machine Learning we can use each screen as an <strong>unique class</strong> and Memory details ( Native_Pss , Native_Private_Dirty , Native_Heap_Alloc, Native_Heap_Free, Code_Pss and Code_Private_Dirty ) as <strong>Features</strong></p><p><strong>Table looks like </strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*QjWc6CLc1WGaBfhM.png" /></figure><p>Python Function to save data in sqlite database :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*FHkiNB19jofjuHYN.png" /></figure><p>For every class we can insert data using above insertTable function of DatabaseClass<br>This ends Part1. I will be soon sharing Part2 and Part3<br>Part2 : <a href="https://analysingpatterns.blogspot.com/2019/02/exploratory-data-analysis-using-numpy.html">https://analysingpatterns.blogspot.com/2019/02/exploratory-data-analysis-using-numpy.html</a></p><p>Other paths are coming up soon! Stay tuned. Please share your valuable feedbacks !</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60b0fde7d629" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>