<?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 TULASI RAM LAGHUMAVARAPU on Medium]]></title>
        <description><![CDATA[Stories by TULASI RAM LAGHUMAVARAPU on Medium]]></description>
        <link>https://medium.com/@tulasiram11729?source=rss-173331d18a4f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GWoKhKnJ4YTDmA3sdssJXg.png</url>
            <title>Stories by TULASI RAM LAGHUMAVARAPU on Medium</title>
            <link>https://medium.com/@tulasiram11729?source=rss-173331d18a4f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 02:30:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tulasiram11729/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[HYPOTHESIS TESTING]]></title>
            <link>https://medium.com/@tulasiram11729/hypothesis-testing-ae07cc8a397d?source=rss-173331d18a4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae07cc8a397d</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[hypothesis-testing]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[TULASI RAM LAGHUMAVARAPU]]></dc:creator>
            <pubDate>Sat, 10 Nov 2018 05:56:28 GMT</pubDate>
            <atom:updated>2018-11-10T09:56:25.409Z</atom:updated>
            <content:encoded><![CDATA[<h3>HYPOTHESIS TESTING WITH REAL WORLD EXAMPLES</h3><p>It is one of the most important concepts in the whole statistics. This concept has many real-world applications from medicine to e-commerce.</p><p>Warning: Each and every point should be read very carefully for the complete understanding of the concept.</p><p>Firstly, let us see some analogous explanation to hypothesis testing in the real world. The judiciary system in the world follows a rule or assumes that one is <strong>Innocent until he is proven guilty.</strong> Analogous to that in the world of statistics, the statisticians also do not attempt or try to prove the particular statement or hypothesis is true. Rather they assume that statement or hypothesis is incorrect (like not guilty) and then try to work or find the statistical evidence that would allow them to overturn their assumption. This works on the principle of Proof by Contradiction. I hope this gives some intuition what actually hypothesis testing does. It will be more clear when we go forward.</p><p>Let me introduce some terminology through the same analogy which I discussed before. In the courtroom trial, we have two hypothesis or statements “whether the defendant is not guilty(innocent)” or “whether the defendant is guilty”.These are two hypothesis.</p><p><strong>Null Hypothesis(H0 called as “H zero”): </strong>The defendant is not guilty or innocent.</p><p><strong>Alternate Hypothesis(H1 or Ha):</strong> The defendant is guilty</p><p>Now, to test the hypothesis i.e to find whether the defendant is guilty or not the judge will examine the evidence produced by the prosecutor which is called the <strong>test statistic</strong>.</p><p><strong>Test Statistic:</strong> In this example, it is evidence produced by the prosecutor.</p><p>Now, the prosecutor will convince the judge if he(defendant) is innocent it is very unlikely to find the evidence. Now the decision of the judge depends on how much unlikely to find the evidence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*7ZJrGUelUikzvBQqyHk-0w.png" /></figure><p>Here we have to make sure that until and unless we are <strong>very sure</strong> on the evidence we don&#39;t want to make him guilty.</p><p>HOW UNLIKELY?</p><p>Suppose, 50 percent chance he is innocent and yet we found that evidence which seems to condemn him. Should we call him guilty? The answer is definitely NO. Because we don&#39;t want to send an innocent man to jail on a coin flip.</p><p>What about 20 percent? It means out of 100 times still 20 of the times he is innocent.</p><p>5%, 2%, 1%, 0.1% all these are likelihoods.In this example, I should be very confident about his innocence so we set the <strong>significance level</strong> to 0.1%. Setting it to 0.1% says that if there are 1000 chances on the evidence out of that 999 times he found guilty.</p><p><strong>Significance Level: </strong>It varies from application to application. Typically, we set it at 5 percent. In domains such as medicine, we set it to 0.1%.</p><p>Now we use this significance level to accept or reject the null hypothesis(to find whether he is innocent or not).</p><p>Suppose if the significance level is 0.1% and the unlikeliness we found out is 10% as the unlikeliness is greater than threshold or significance level we will accept null hypothesis(H0) and reject the alternate hypothesis(H1 or Ha). Here the calculation of unlikeliness(also called p-value) will be done through Resampling and permutation test which will be explained later. I hope all the terms <strong>Test Statistic, Null Hypothesis, Alternate Hypothesis, p-value</strong> are clear as of now.</p><p><strong>Hypothesis Testing Process:</strong></p><ol><li>Defining a statistic which will be used to test the null hypothesis.</li><li>Create a Null Hypothesis(H0) and Alternate Hypothesis(H1 or Ha).</li><li>Specify the significance level. Typically we use 5 %.</li><li>Collect the data and perform associated calculations(finding p-value).</li><li>Apply the significance level to accept or reject the null hypothesis.</li></ol><p>p-value: The probability, assuming the null hypothesis is true, of observing a result at least as extreme as the test statistic.</p><p>Now, let us take one dataset and will flow through the above testing process, which will give a clear view on how to use hypothesis testing.</p><p>Suppose we want to watch a movie. There are 3 movies that caught your eye, but you&#39;re not really sure if they&#39;re good or not. Then you contacted your family and friends for recommendations and ask them to rate(1–5) those movies. You have got ratings from 20 people. One thing we have to remember is a particular person may give a rating to any number of movies one or two or three. So ratings are given by a particular set of people to a particular movie may not be same as ratings given to another movie.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*pTg9YBwTxwEVSTzy-sD8ug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*MfXIW4WRnTYdPZfB1B83iA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*YwU1ZP7wevmACqYhB--nMw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QxqoAu7-JHaqNGC7E2QLQg.png" /></figure><p>This is great!. But the Escape Plan movie doesn&#39;t seem that appealing, and there’s a clear competition between Infinity War and Commuters…Instead of just seeing the average values of both Infinity War and Commuters and confirming we would rather use hypothesis testing to confirm.</p><p><strong>Null Hypothesis:</strong> No difference in watching any of the two movies.</p><p><strong>Alternate Hypothesis:</strong> Alternate to the null hypothesis. (Here seeing Infinity War because of average values..)</p><p><strong>Test Statistic:</strong> Difference in the means(average values) of the ratings of each movie. (Difference in means:0.27 which is already observed from the data.)</p><p><strong>Significance Level:</strong> 5 percent. (0.05)</p><p><strong>Calculation of p-value(Resampling and permutation Test) :</strong></p><p>We use the same rating from those 20 people. Now we divide into two groups(10 and 10) randomly and for each group, we give different movie(Infinity War for one group and Commuters for another group) and check the ratings. After collecting the ratings compute the difference in the <strong>means(averages)</strong> from the two groups. Now repeat the same process for 10,000 times. Sort those 10,000 values.</p><p>After sorting, let&#39;s say the values are like:</p><p>0.2,0.21,0.21,0.22,…………………………………………………..0.4,0.41.</p><p>Now, let&#39;s say the value of <strong>test statistic</strong>(0.27 which is observed from the actual data) is at the 9600th position out of those 10,000 positions. The p-value is the probability of test statistic greater than 0.27 assuming null hypothesis is true. From the above data, the p-value is found out to be 400/10000 which is 0.04. p-value(0.04) is found out to be less than the <strong>significance level </strong>(which is 0.05). So we reject the null hypothesis and accept alternate hypothesis.</p><p>If, suppose the value is greater than <strong>test statistic </strong>then we accept the null hypothesis.</p><p>If you find any difficulty in understanding the concept you can reach at tulasiram11729@gmail.com</p><p><em>Thanks for reading!</em></p><h4>If you enjoyed this article clap, clap, clap👏👏👏 Share this with your friends, if you think they’d be interested in this topic!</h4><p><em>Here are a few other articles I wrote that might also like</em></p><ul><li><a href="https://medium.com/@tulasiram11729/personalized-cancer-diagnosis-3d6f09a6b8c9">Personalized Cancer Diagnosis</a></li><li><a href="https://medium.com/@tulasiram11729/intrepretability-of-k-nn-44831578dd68">INTREPRETABILITY OF K-NN</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae07cc8a397d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[INTREPRETABILITY OF K-NN]]></title>
            <link>https://medium.com/@tulasiram11729/intrepretability-of-k-nn-44831578dd68?source=rss-173331d18a4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/44831578dd68</guid>
            <category><![CDATA[interpretability-of-knn]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[TULASI RAM LAGHUMAVARAPU]]></dc:creator>
            <pubDate>Tue, 03 Apr 2018 14:15:25 GMT</pubDate>
            <atom:updated>2018-04-03T14:15:25.852Z</atom:updated>
            <content:encoded><![CDATA[<p>INTREPRETABILITY OF K-NN</p><p>Cancer is an abnormal disease.As in olden days it is very hard to detect cancer.But when the ML is used in medical domain it is found easy to detect some of the dangerous diseases like pneumonia,cancer etc…The ambit of ML is extended to detect cancer.From the past 20 years Machine Learning is been using to detect cancers.But in medical domains the black box models(models which take input and provide output without giving any reasons) are not useful as they do not give any reasons behind . It is very absurd to say to the patient that you are suffering from a cancer without a reason.This is where intrepretability matters. Intrepretability helps to win trust in algorithms that try to improve on suggestions rather than just predicting.So our model should intrepret the reason behind the output it is giving.One of such model is K-NN(K-NEAREST NEIGHBORS).<br>HOW K-NN WORKS?<br> We will not go more technical into it so just don’t worry. It is just a simple majority based problem.Given a data set it just simply project every data point into an n-dim space where n is columns or features that each data point has.I think its better to go with example which makes life easy.Suppose we have a data of cancer patients from a hospital for the past 30 years in which we are maintaining the age of patient,symptoms of cancer when he joined(mutations),the year patient died,and some tests performed on the patient.These all details can be treated as dimensions(or) features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*5vs66zXL2HW56YE_jKaenw.png" /></figure><p>The above table is just an random example.The columns in the above table treated as dimensions and projected into an n-dim space.</p><p>Now the question is what does our model(K-NN) do with this data?<br> Let me answer this without going into technical details.Our model(K-NN) take those data and just simply project into a n-dim space where n is just the no of features which I mentioned in above example.Now just say if a new patient is joined in that cancer hospital by taking all the data which are available with us we can easily predict whether he has cancer or not based on the results of tests performed on that particular patient such as age,no. of auxiliary nodes detected etc… Here K is just with how many nearest patients we should compare in the n-dim space .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*xFYSE1gmaYoRQGXESiZb4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*rlB2v4dNyD_LJhOvr_KGow.png" /></figure><p>The above figures are from some random data.But this is what looks when we change values of k.Here k must be preferably odd so that we can easily decide the majority.Suppose if our model detects our test point as a cancer based on the nearest points in n-dim space then we compare the features of test point with the nearest points and we can exactly reason out which features are coinciding and give them to the doctor.Now the doctor who has domain knowledge on all the features check the features given by algorithm and explains the patient clearly.<br>But if the features are too many it is very hard to intrepret. Since it creates ambiguity to doctor when more features are present in data</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44831578dd68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Personalized Cancer Diagnosis using Machine Learning]]></title>
            <link>https://medium.com/analytics-vidhya/personalized-cancer-diagnosis-3d6f09a6b8c9?source=rss-173331d18a4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d6f09a6b8c9</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[cancer-diagnosis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[TULASI RAM LAGHUMAVARAPU]]></dc:creator>
            <pubDate>Tue, 03 Apr 2018 04:55:51 GMT</pubDate>
            <atom:updated>2020-12-04T13:22:06.503Z</atom:updated>
            <content:encoded><![CDATA[<h4>Exploratory Data Analysis and diverse machine learning models applied to diagnose cancerous tumors.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1b88wdy0KFYH2ef5" /><figcaption>Photo by <a href="https://unsplash.com/@drew_hays?utm_source=medium&amp;utm_medium=referral">Drew Hays</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you are more interested in code you can directly jump into this <a href="https://github.com/tulasiram58827/Cancer-Diagnosis">repository</a></p><h3>What is Cancer basically?</h3><p>Our body is made up of trillions of cells, which are constantly dying and regenerating. Normally, a cell divides and make a perfect copy of itself using a genetic blueprint called DNA. Once in a while, the DNA blueprint gets damaged sometimes so that cell doesn’t listen to body signals and keeps on dividing forming a tumor.</p><h3>What is the business problem we need to solve?</h3><p>Let us discuss briefly the data and the business problem since it is very important to understand the business problem we are solving.</p><p>When a patient seems to have cancer, we take a tumor sample from the patient and we go through genetic sequencing of DNA. Once sequenced, a tumor can have thousands of genetic mutations. Here briefly, a ‘mutation’ is small change in gene which causes cancer. One more important thing is that for every gene, there is a variation associated with it. Now with the help of the gene and its variation, we have to classify which class(total we have 9 classes) it belongs to. Only some classes belong to cancer.</p><p>Let us go through the workflow more clearly.</p><p>Source:<a href="https://www.kaggle.com/c/msk-redefining-cancer-treatment/discussion/35336#198462">https://www.kaggle.com/c/msk-redefining-cancer-treatment/discussion/35336#198462</a></p><ol><li>A molecular pathologist selects a list of genetic variations of interest that he/she want to analyze.</li><li>The molecular pathologist searches for evidence in the medical literature that somehow are relevant to the genetic variations of interest.</li><li>Finally the molecular pathologist spends a huge amount of time analyzing the evidence related to each of the variations to classify them.</li></ol><p>Here going through Steps 1 and 2 can be done easily and with less time. But Step 3 is very time consuming. Our goal is to replace Step 3 with a machine learning model.</p><p>So, the problem statement is to classify genetic variations based on evidence from the text-based clinical literature or research papers.</p><p>As we said, we have to classify genetic variations — meaning that it is a classification problem. As there are 9 classes it is a multi class classification problem.</p><p>Knowing the business constraints of the problem is most important. If we don’t know the business constraints, we train models which cannot be put in production.</p><h4><strong>BUSINESS CONSTRAINTS OF THIS PROBLEM:</strong></h4><ol><li>Interpretability of the algorithm is must because a cancer specialist should understand why the model is given particular class so that he can explain to the patient.</li><li>No low-latency requirement which means patient can wait for the results. As there is no low-latency requirement, we can apply complex machine learning models.</li><li>Errors are very costly.</li><li>Probability of belonging to class is needed rather than it belonging to particular class.</li></ol><p><strong>MAPPING REAL WORLD/BUSINESS PROBLEM TO MACHINE LEARNING PROBLEM:</strong></p><ol><li>As we already mentioned that there are 9 classes to classify. Therefore, it is a multi class classification problem.</li><li>Performance metric:- Multi class Log-Loss, confusion matrix(Log-Loss is chosen because it actually uses probability which is our business constraint)</li></ol><p><strong>Machine Learning Objective:</strong> Predict the probability of each data point belonging to each of the 9 classes.</p><p><strong>Machine Learning Constraints: </strong>These are same as business constraints which I mentioned previously.</p><p>After reading the data, we preprocessed the data like removing stopwords, converting to lower case and removing punctuations etc…Preprocessing is a very important stage.</p><p><strong>Splitting the data: </strong>As the data is not temporal in nature which means it is not changing with time we can split the data randomly for training, cross validation and testing. Then after splitting the data it is also found out that training and test data have almost similar distributions and from the distributions it is clear that data is imbalanced.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*Tz4-ztm0-HTnIrRvvbSiPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*Ep1KnKcDAyVSTeXq6Y2FyA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*jAYl1_FUmwSHUp62vV_LFQ.png" /></figure><p>As we know that log-loss is ranging from 0 to infinite. So we first define a random model so that if our ML model has a log-loss less than our random model, then we can consider that our ML model is good. After giving data to our random model it gives a log loss ofroughly 2.5.</p><p>We even checked precision and recall matrix in which diagonal elements(which are precision and recall of all classes) seemed to be very low because of a random model. Precision and recall matrices are attached below. From the above distributions it is also very clear that 1,2,4,7 classes are majority classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dSoHfKBEfsv3VHJNepOLPg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XuVY8WCOjHMfWy0f-2D5Ig.png" /></figure><h4><strong>UNIVARIATE ANALYSIS:</strong></h4><p>We take each feature and check whether it is useful for predicting in class label by various ways so that we can use that feature. If it is not useful, we can simply remove that feature</p><ol><li><strong>Gene Feature</strong></li></ol><p>As we know that gene is a categorical feature. From that we observe that there are 235 types of unique genes out of which top 50 most frequent genes nearly contribute to 75 percent of data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*eVOrzPcM2l8_MkfoxU041w.png" /></figure><p>Now we feature the gene into vector by one hot encoding and response coding. Then we build one simple Logistic Regression model with Calibrated Classifier and applied gene feature and class labels to it. We find that Train, CV, Test log-loss values are roughly same and also find out that log loss value is less than 2.5(Random Classifier value). Hence we can say that Gene is an important feature for our classification. We can also conclude that gene is stable feature because CV and Test errors are roughly equal to Train Errors.</p><p><strong>2. Variation Feature</strong></p><p>Here variation is also a categorical feature and we observed that 1927 unique variations out of 2124 present in training data which means most of variations occurred once or twice.</p><p>CDF of variations looks as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*rdZ3GkGJohVkoSz2uXZViQ.png" /></figure><p>Cumulative Distribution is straight line which means most variations occur once or twice in training data. We feature the Variation into vector by one hot encoding and response coding. As we did earlier for the gene feature, we build a simple LR model and apply data to it and find that log loss values of Train, CV, Test found to be less than Random Model.</p><p>But the difference between Train log loss and CV, Test log loss is significantly more than gene feature which means variation feature is unstable. But as the log loss is less than the Random Model we still use the variation feature but be careful since it is not stable.</p><p><strong>3. Text Feature</strong></p><p>In text data there are total 53,000 unique words which are present in training data. We also observe that most words occur very few times which is common in text data. We convert the text data into vector by BOW(one hot encoding) and Response Coding.</p><p>As we did in previous cases we apply it to simple model LR and log loss values of Train, CV, Test are found to be less than Random Model. From the distributions of CV, Test data it is found out that test feature is a stable feature.</p><p>Now combine all the features by two ways</p><ol><li>One hot encoding: It is found out that by one hot encoding the dimensionality is 55,517 which is because of text data.</li><li>Response Coding: It is found out that by Response Coding the dimensionality is 27 (each feature corresponds to 9 dimensions).</li></ol><h3>BASELINE MODEL</h3><p><strong>APPROACH 1:</strong></p><ol><li><strong>NAIVE BAYES:</strong></li></ol><p>We know that for text data NB model is a baseline model. Now we apply the training data to the model and used the CV data for finding best hyper-parameter(alpha)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*uBcREPgROc_Hiotq-AY2sg.png" /></figure><p>With the best alpha we fit the model. The test data is then applied to the model and we found out that the log-loss value is 1.27 which is quite less than Random Model. Here we also find out that the total number of mis-classified cases is 39.8 percent. We also checked the probabilities of each class for each data and interpreted each point. This is to check why it is predicting particular class randomly. We conclude that for mis-classified points, the probability that the point belongs to a predicted class is very low. From the precision and recall matrix it is found out that most of points from class 2 predicted as 7. Similarly most points from class 1 are predicted as 4.</p><p><strong>APPROACH 2:</strong></p><p><strong>2. K Nearest Neighbors:</strong></p><p>As we know that the k-NN model is not interpretable(which is our business constraint) but we still use this model just to find out the log loss values. Since k-NN suffers from the curse of dimensionality, we use response coding instead of one-hot encoding. After applying the data to the model we obtain the best hyper-parameter(k)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*SC5VnZZ3rXpEeoxHlJ4GnQ.png" /></figure><p>With the best k we fit the model and test data is applied to the model. The the log-loss value is 1.002 which is less than NB model. But number of mis-classified points are 39.47 percent(almost equal to NB model). In k-nn model it is found out that most of points from class 2 predicted as 7. Similarly most of points from class 1 predicted as 4.</p><p><strong>APPROACH 3:</strong></p><p><strong>3.LOGISTIC REGRESSION:</strong></p><p>As we have already seen, the LR model worked very well with univariate analysis. So we did some thorough analysis on LR by taking both imbalanced data and balanced data.</p><ol><li><strong>With Class Balancing</strong>: We also know that LR works well with high dimension data and it is also interpretable. So we did oversampling of lower class points and applied the training data to the model and used the CV data for finding best hyper-parameter (lambda)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*pkTCZWh0IUd3ev0yxISOsg.png" /></figure><p>With the best lambda we fitted the model and test data is applied to the model. The log-loss value is 1.048(close to k-nn). But number of mis-classified points are 34.77 percent(which are less than NB and K-nn). As LR is interpretable and mis-classified points are less than other models(k-NN and NB)it is better than k-NN and NB.</p><p>Without class balancing log loss and mis-classified points are increased. Therefore, we use class balancing.</p><p><strong>APPROACH 4:</strong></p><p><strong>4. SVM:</strong></p><p>We use Linear SVM(with class balancing) because it is interpretable and works very well with high dimension data. RBF Kernel SVM is not interpretable so we cannot use it. Now we apply the training data to the model and use the CV data for finding best hyper-parameter (C)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*cCm-p3MNJ_89ZBmVAi_P9Q.png" /></figure><p>With the best C we fit the model and test data is applied to the model. Now, the log-loss value is 1.06(near to LR) which is quite less than Random Model. Here, the total number of mis-classified cases is 36.47 percent(more than LR). Since we used class balancing we got good performance for minor classes.</p><p><strong>APPROACH 5:</strong></p><p><strong>5. RANDOM FOREST:</strong></p><p><strong>5.1) One-hot encoding:</strong> Normally Decision Tree works well with low-dimension data. It is also interpretable. By changing the number of base learners and max depth in Random Forest Classifier, we get best base learners=2000 and max depth=10.Then we fit the model with best hyper-parameters and test data is applied to it. The resultant log loss value is 1.097(near to LR) and total number of mis-classified points is 36.84 percent(more than LR).</p><p><strong>5.2) Response Coding:</strong> By changing the number of base learners and max depth in Random Forest Classifier we find that best base learners=100 and max depth=5. We then fit the model with best hyper-parameters and found that train log loss is 0.052,and CV log loss is 1.325 which says that model is overfitted even with best hyper-parameters. That is why we don’t use RF+Response Coding .</p><p><strong>APPROACH 6:</strong></p><p><strong>6. STACKING CLASSIFIER:</strong></p><p>We stacked three classifiers — LR, SVM, NB and kept LR as the meta classifier. Now we apply the training data to the model and used the CV data for finding best hyper-parameter. With the best hyperparameter we fit the model apply the test data to the model. The log-loss value is 1.08 which is very much less than Random Model. Here we also find out that total number of mis-classified cases is 36.2 percent. Here, even though we used complex model, we got the results nearly similar to LR. Additionally, we know that the stacking classifier is not interpretable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*vE-9pPg14IAPFSfd_vN_YA.png" /></figure><p>From the above table it is clear that RF(Response Coding), there is a drastic change in the train and CV log loss(nearly 20 times). This means that the model is over-fitted, and thus, we remove that model. In Stacking Classifier (which is ensemble) log loss values are nearly same as LR+Balancing. From the above table LR+Balancing suits our business or real world constraints such as interpretability and having a better log loss values than any other models.</p><p><strong>APPROACH 7:</strong></p><p>After this, now I also checked with TF-IDF Vectorizer(for one-hot encoding of features) instead of CountVectorizer and the results are pretty good.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3uEKYGuu_fWbZnvYavxL7g.jpeg" /></figure><p>We can see that results of TF-IDF Vectorizer are slightly better when compared to CountVectorizer. Here also we can see that Logistic Regression is working well compared to other algorithms and Random Forest with response coding is overfitted as there is huge difference in train and CV loss.</p><p>Lets see one more interesting analysis:</p><p><strong>APPROACH 8:</strong></p><p>I selected the top 1000 words from text data excluding gene and variation based on the TF-IDF score of each word. Now I remove the words from text data which are not present in those top 1000 words. Interestingly I got good results compared to the results of above analysis. Lets see the results once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C38Ys9MGaVCVSgo6im1ahw.jpeg" /></figure><p>We can see that results are much improved. As it is, Logistic Regression is performing well compared to other algorithms and Random Forest with response coding is overfitted as usual. But the results have improved.</p><p>As we can see that in all the above analysis, Logistic Regression is outperforming all algorithms. So, I tried applying Logistic Regression on unigrams and bigrams instead of using only unigrams. However, the results are not fruitful.</p><p><strong>APPROACH 9:</strong></p><p><strong>LOGISTIC REGRESSION(WITH UNIGRAMS AND BIGRAMS)</strong></p><p>TRAIN LOG LOSS:0.83</p><p>CV LOG LOSS:1.17</p><p>TEST LOG LOSS:1.19</p><p>PERCENTAGE OF MISCLASSIFIED POINTS:40.7</p><p>Finally, after trying different approaches, log loss value is finally reduced to less than 1. That is Logistic Regression with 4 grams and extracted top 2000 features from 1–4 grams and applied Logistic Regression with class = balanced .</p><p><strong>APPROACH 10:</strong></p><p>LOGISTIC REGRESSION(1–4 GRAMS) TOP 2000 TF-IDF FEATURES:</p><p>TRAIN LOG LOSS: 0.439</p><p>CV LOG LOSS: 0.957</p><p>TEST LOG LOSS: 0.982.</p><p>I will keep update this blog with new analysis.</p><p>For detailed code analysis check this <a href="https://github.com/tulasiram58827/Cancer-Diagnosis">repo</a>.</p><p>If you have any queries contact tulasiram11729@gmail.com</p><p>Thank your reading. Please share your comments and feedback below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d6f09a6b8c9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/personalized-cancer-diagnosis-3d6f09a6b8c9">Personalized Cancer Diagnosis using Machine Learning</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>