<?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 Farzeen Zehra on Medium]]></title>
        <description><![CDATA[Stories by Farzeen Zehra on Medium]]></description>
        <link>https://medium.com/@farzeenzehra.fz?source=rss-f7faf7af860f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YRPgYtMy7F0HVKmq</url>
            <title>Stories by Farzeen Zehra on Medium</title>
            <link>https://medium.com/@farzeenzehra.fz?source=rss-f7faf7af860f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 13:40:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@farzeenzehra.fz/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[Symptoms to Disease Prediction Model]]></title>
            <link>https://medium.com/@farzeenzehra.fz/symptoms-to-disease-prediction-model-521c4715c15e?source=rss-f7faf7af860f------2</link>
            <guid isPermaLink="false">https://medium.com/p/521c4715c15e</guid>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Farzeen Zehra]]></dc:creator>
            <pubDate>Wed, 24 Jun 2020 14:10:01 GMT</pubDate>
            <atom:updated>2020-06-25T06:35:29.250Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*naYqlvpSAZ8_JxSL.jpg" /><figcaption>Machine Learning In Medical Field</figcaption></figure><blockquote>Are you also searching for a proper medical dataset to predict disease based on symptoms?</blockquote><p>I wanted to make a health care system in which we will input symptoms to predict the disease. I searched a lot on the internet to get a big and proper dataset to train my model but unfortunately, I was not able to find the perfect one. Then I used a relatively smaller one which I found on Kaggle <a href="https://www.kaggle.com/itachi9604/disease-symptom-description-dataset">Here</a>. Then I found a cleaned version of it <a href="https://www.kaggle.com/neelima98/disease-prediction-using-machine-learning">Here</a> and by using both, I decided to make a symptoms to disease prediction system and then integrate it with <strong>flask</strong> to make a web app.</p><p>In this story, I am just making and training the model and if you want me to post about how to integrate it with flask (python framework for web apps) then give it a clap 👏</p><h3><strong>Getting Started:</strong></h3><p>To train the model, I will use PyTorch logistic regression. Pytorch is a library managed by Facebook for deep learning. It has a lot of features built-in. Here I am using a simple Logistic Regression Model to make predictions since the data is not much complex here.</p><h3>Importing Utilities</h3><p>First of all, we need to import all the utilities that will be used in the future. Read the comments, they will help you understand the purpose of using these libraries.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D3&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D3&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/1db5f4b5f39c98566c5df6a891c9239c/href">https://medium.com/media/1db5f4b5f39c98566c5df6a891c9239c/href</a></iframe><h3>Handling CSV Files</h3><p>Now I am defining the links to my training and testing CSV files.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D5%26hideOutput%3Dtrue&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D5%26hideOutput%3Dtrue&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a39e961da57be8378c287746a16f85b/href">https://medium.com/media/0a39e961da57be8378c287746a16f85b/href</a></iframe><p>Now we will read CSV files into data frames. (Dataframes are Pandas Object). Keep reading the comments along the code to understand each and every line.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D7&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D7&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/136883df4b562b13e4411b48544df50f/href">https://medium.com/media/136883df4b562b13e4411b48544df50f/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D8&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D8&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ea773890cef12d5401beb6e99f1f743/href">https://medium.com/media/3ea773890cef12d5401beb6e99f1f743/href</a></iframe><p>Now we are getting the number of diseases in which we are going to classify. These are needed because the logistic regression model will give probabilities for each disease after processing inputs.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D10&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D10&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/37fc08e81bb13de9d234272758de5293/href">https://medium.com/media/37fc08e81bb13de9d234272758de5293/href</a></iframe><p>Now we are getting the names of columns for inputs and outputs.<br><em>Reminder: Keep reading the comments to know about each line of code.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D12&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D12&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/a406848421c10c76899e1602b390b881/href">https://medium.com/media/a406848421c10c76899e1602b390b881/href</a></iframe><p><strong>The below code will make a dictionary in which numeric values are mapped to categories. </strong>For further info: check <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.cat.categories.html">pandas cat.categories</a> and <a href="https://www.geeksforgeeks.org/enumerate-in-python/">enumerate</a> function of python.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D14&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D14&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/beb4dec84987eb0811bfef3a9336680e/href">https://medium.com/media/beb4dec84987eb0811bfef3a9336680e/href</a></iframe><p>Now we have to convert data frame to NumPy arrays and then we will convert that to tensors because <strong>PYTORCH WORKS IN TENSORS</strong>.<br>For this, we are defining a function that takes a data frame and converts that into input and output features.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D16&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D16&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec55b855b4d85f1467cb3d4f751a9522/href">https://medium.com/media/ec55b855b4d85f1467cb3d4f751a9522/href</a></iframe><p>The above function will give NumPy arrays so we will convert that into tensors by using a PyTorch function torch.from_numpy() which takes a NumPy array and converts it into a tensor.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D17&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D17&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/1dc8a92d598e4acabf1169d40951e4e2/href">https://medium.com/media/1dc8a92d598e4acabf1169d40951e4e2/href</a></iframe><p>Repeating the same process with the test data frame:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D18&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D18&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b77b934da6b5a730056b5f4b0974d46/href">https://medium.com/media/2b77b934da6b5a730056b5f4b0974d46/href</a></iframe><h3>Datasets</h3><p>The test CSV is very small and contains only one example of each disease to predict but the train CSV file is large and we will break that into three for training, validating, and testing. And then join both the test datasets into one test dataset.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D20&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D20&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/494c6a1efcf252a2c452f0c30310afee/href">https://medium.com/media/494c6a1efcf252a2c452f0c30310afee/href</a></iframe><p>Now we will set the sizes for training, validating, and testing data.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D21&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D21&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/6515f8c72d43b9e2170d459dc452a5a0/href">https://medium.com/media/6515f8c72d43b9e2170d459dc452a5a0/href</a></iframe><p>In the above cell, I have set the manual seed value. We set this value so that whenever we split the data into train, test, validate then we get the same sample so that we can compare our models and hyperparameters (learning rates, number of epochs ).</p><p>Now we will get the test dataset from the test CSV file</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D22&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D22&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/21765f5e2216bc8318234bd65158d6e1/href">https://medium.com/media/21765f5e2216bc8318234bd65158d6e1/href</a></iframe><p>Now will concatenate both test dataset to make a fairly large dataset for testing by using ConcatDataset from PyTorch that concatenates two datasets into one.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D24&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D24&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/3706ea558308fa1969d74cfffb75214e/href">https://medium.com/media/3706ea558308fa1969d74cfffb75214e/href</a></iframe><h3>DataLoaders</h3><p>Now we will make data loaders to pass data into the model in form of batches</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D26&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F5%26cellId%3D26&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f21c9fbd83b85b8e27ae16360550189/href">https://medium.com/media/1f21c9fbd83b85b8e27ae16360550189/href</a></iframe><p>Batch size depends upon the complexity of data. Since the data here is simple we can use a higher batch size. In image processing, a higher batch size is not possible due to memory. If you have a lot of GPUs, go for the higher batch size 😉. The higher the batch size, the better it is.</p><h3>Defining Utility Functions</h3><p>Now we will define the functions to train, validate, and fit the model.<br><strong>Accuracy Function:<br></strong>We are using softmax which will convert the outputs to probabilities which will sum up to be 1, then we take the maximum out of them and match with the original targets. If they are equal, then add 1 to the list. torch.sum adds them and that they are divided by the total to give accuracy value.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D29&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D29&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef7a0a3ebab8a87af3eb36eda2d8d4f2/href">https://medium.com/media/ef7a0a3ebab8a87af3eb36eda2d8d4f2/href</a></iframe><h4>Optimizer and Loss Function</h4><ul><li>loss function calculates the loss, here we are using cross_entropy loss</li></ul><blockquote><strong>Remember :</strong> Cross entropy loss in pytorch takes flattened array of targets with datatype long.</blockquote><ul><li>Optimizer change the weights and biases according to loss calculated, here we are using SGD (Stochastic Gradient Descent)</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D30&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D30&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/267cb6f2eee2026136433cea35284dca/href">https://medium.com/media/267cb6f2eee2026136433cea35284dca/href</a></iframe><p><strong>Fit Function:<br></strong>This will print the epoch status every 20th epoch.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D31&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D31&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/29596b3bf15915f7eb466c542b6b09f7/href">https://medium.com/media/29596b3bf15915f7eb466c542b6b09f7/href</a></iframe><h3>Model</h3><p>Now we will use nn.Module class of PyTorch and extend it to make our own model class.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D34&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D34&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/b728abf33ffa9a4e882a9b3dba3e294f/href">https://medium.com/media/b728abf33ffa9a4e882a9b3dba3e294f/href</a></iframe><blockquote><strong>Predict_Single Function Explanation<br></strong><em>Sigmoid vs Softmax</em></blockquote><ol><li>Sigmoid converts all numbers to list of probabilities, each out of 1</li><li>Softmax converts all numbers to probabilities summing up to 1</li><li>Sigmoid is usually used for multi labels classification</li><li>Softmax is used for single-label classification.</li><li>You might be wondering why I am using Sigmoid here?? So the answer is that I also want my system to tell the chances of disease to people. If I use softmax then my system is predicting a disease with relative probability like maybe it’s 0.6 whereas sigmoid will predict the probability of each disease with respect to 1. so my system can tell all the disease chances which are greater than 80% and if none of them is greater than 80% then gives the maximum.</li><li>Read all the comments in the above cell. Each line is explained there.</li></ol><h4>Initializing a model</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D35&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D35&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e881c41c6a708e474f537e881ff914f/href">https://medium.com/media/6e881c41c6a708e474f537e881ff914f/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D37&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D37&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/501091a5eb15730f1e112a2d04409be3/href">https://medium.com/media/501091a5eb15730f1e112a2d04409be3/href</a></iframe><h4>Training the model</h4><ul><li>learning rate = 0.1</li><li>epochs = 100</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D39&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D39&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0e631dfeb5214be4d1476fb0e9482f1/href">https://medium.com/media/f0e631dfeb5214be4d1476fb0e9482f1/href</a></iframe><h3>Testing</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D41&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D41&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab4fefc36ceabebb0331cd26c246e36f/href">https://medium.com/media/ab4fefc36ceabebb0331cd26c246e36f/href</a></iframe><h4>Predicting Single Value to check</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D43&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D43&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7fa7c2ea424f9c38ef3d24ba3234153/href">https://medium.com/media/c7fa7c2ea424f9c38ef3d24ba3234153/href</a></iframe><h3>Save the model</h3><ul><li><strong>Method 1</strong><br>This will save the whole model to a file<br>torch.save(model,&#39;model.pth&#39;)</li><li><strong>Method 2</strong><br>This will save the model state dict (weights and biases) to a file<br>torch.save(model.state_dict(), &#39;model_st_dict.pth&#39;)</li></ul><h3>Graphs</h3><p>Using matplotlib to plot the losses and accuracies</p><h4>Loss Graph:</h4><pre>val_losses = [his[&#39;validation_loss&#39;] for his in history]<br>train_losses = [his[&#39;training_loss&#39;] for his in history]<br>val_acc = [his[&#39;validation_acc&#39;] for his in history]</pre><pre>plt.figure(figsize=(6,4))<br>plt.plot(val_losses, &#39;-r&#39;, label=&quot;val_loss&quot;)<br>plt.plot(train_losses , &#39;-b&#39;, label = &quot;train_loss&quot;)<br>plt.xlabel(&quot;Epochs&quot;)<br>plt.ylabel(&quot;Losses&quot;)<br>plt.legend()<br>plt.show()</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D50%26hideInput%3Dtrue&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D50%26hideInput%3Dtrue&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/c61eb2a0756f89a9540d47d98bf376d7/href">https://medium.com/media/c61eb2a0756f89a9540d47d98bf376d7/href</a></iframe><h4>Accuracy Graph</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D52&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Ffarzeenzehra-fz%2Fcourse-project%2Fv%2F6%26cellId%3D52&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Fjvn%2Fassets%2Ffarzeenzehra-fz%2Fprofile_images%2F248836aec3284238a59e2739df61fc19%2Fmedium.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="200" frameborder="0" scrolling="no"><a href="https://medium.com/media/801f1629093f14270f483248410a6267/href">https://medium.com/media/801f1629093f14270f483248410a6267/href</a></iframe><h4>Conclusion:</h4><p>We trained a logistic regression model to predict disease with symptoms.<br>If you want to ask anything, you can do that in the comment section below.<br>If you find anything wrong here, please comment it down it will be highly appreciated because I am just a beginner in machine learning. This course was the first step in this field.</p><h4>References:</h4><p>Check out these documentations to learn more about these libraries</p><ol><li><a href="https://pytorch.org/docs/stable/index.html">Pytorch Documentation</a></li><li><a href="https://pandas.pydata.org/docs/">Pandas Documentation</a></li><li><a href="https://matplotlib.org/3.2.2/contents.html">Matpltlib Documentation</a></li><li><a href="https://numpy.org/doc/">Numpy Documentation</a></li><li>or you can use <a href="https://stackoverflow.com/">Stackoverflow</a> to search the queries</li><li>Check out full notebook <a href="https://jovian.ml/farzeenzehra-fz/course-project">here</a></li></ol><p>THANK YOU ❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=521c4715c15e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>