<?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 Ajay Unagar on Medium]]></title>
        <description><![CDATA[Stories by Ajay Unagar on Medium]]></description>
        <link>https://medium.com/@unagar?source=rss-ffd0563b6405------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gJfrzCDdFEgv2ZaC.</url>
            <title>Stories by Ajay Unagar on Medium</title>
            <link>https://medium.com/@unagar?source=rss-ffd0563b6405------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 14:58:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@unagar/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[Baby steps with Tensoflow #2]]></title>
            <link>https://medium.com/data-science-group-iitr/baby-steps-with-tensoflow-2-88fc83205262?source=rss-ffd0563b6405------2</link>
            <guid isPermaLink="false">https://medium.com/p/88fc83205262</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Ajay Unagar]]></dc:creator>
            <pubDate>Wed, 07 Jun 2017 08:05:16 GMT</pubDate>
            <atom:updated>2017-06-10T06:48:11.963Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog we will understand how to use Tensoflow for Linear and Logistic Regression. I hope you have read 1st blog of this series, if not please give it <a href="https://medium.com/data-science-group-iitr/baby-steps-with-tensorflow-1-b29091d502fd">a read</a>.</p><blockquote>Why in the world would I use Tensorflow for regression?</blockquote><p>No. you will not. Though to understand each function of Tensorflow properly I suggest you go through this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*ZBRUL9BfVbxmyv8CGgcR_A.jpeg" /><figcaption>Tensorflow all the way! :D</figcaption></figure><h3>Linear Regression</h3><p>Start with generating the data.</p><pre># Generate X_data of shape [1000, 4]<br>X_data = np.random.normal(loc=10, scale=10, size=(1000,4))</pre><p>Equation of Y in terms of X_data</p><pre>Y_data = 0.5 * X_data[:, 0] - 52 * X_data[:, 1] +12*X_data[:, 2] - X_data[:, 3]</pre><pre>Y_data = Y_data.reshape(-1,1)</pre><p>Now, to start with we need to define Place holders for the data feeding while training. We have seen what placeholders do in the last blog.</p><pre>x = tf.placeholder(tf.float32, shape=[None, 4])<br>y = tf.placeholder(tf.float32, shape = [None,1])</pre><p>Here shape is [None, 4]. What does this mean? It means we can provide any value in place of None. So while feeding we can provide as many examples we want. This is very useful in mini batch training, which we will see in the subsequent blogs. So, basically we feed training data through placeholders.</p><p>Now we will define weight variable and intercept term. This will be tf.Variable because we need to find the value of W and b. So, we will initialize it randomly and then using optimization algorithm we will reach to the true value.</p><pre>W = tf.Variable(tf.random_normal([4,1]), name=&quot;Weight&quot;)<br>b = tf.Variable(tf.random_normal([1,1]), name=&quot;Intercept&quot;)</pre><p>Next we generate our hypothesis. Read more about more matrix functions like matmul <a href="https://www.tensorflow.org/api_guides/python/math_ops#Matrix_Math_Functions">here</a>.</p><pre>hypothesis = tf.matmul(x, W) + b</pre><p>Now we will define our loss function. We will be using <a href="https://www.kaggle.com/wiki/RootMeanSquaredError">RMSE</a> (reduced mean squared error) loss.</p><pre>Loss = tf.reduce_mean(tf.square(y - hypothesis))</pre><p>Next we will use Stochastic Gradient Optimizer to minimize this loss. If you don’t know how this optimization is carried out, I strongly suggest you to read this <a href="http://sebastianruder.com/optimizing-gradient-descent/">great blog</a> on gradient descent optimization.</p><pre>optimizer = tf.train.GradientDescentOptimizer(learning_rate= 0.0001)<br>train = optimizer.minimize(Loss)</pre><p>Now as we’ve seen in previous blog, tensorflow is Static graph. We need to start Tensorflow session to pass data through this graph.</p><pre>sess = tf.Session()<br># Initialize all the variables<br>sess.run(tf.global_variables_initializer())</pre><p>Now everything is set. We need to feed data to the graph and find the optimal values for W and b</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*5wjWC39_zrNmTZrv2X-5dA.png" /></figure><p>Now here you need to understand what sess.run() does? It basically computes the values of the quantities you specified (in our case Loss, hypothesis, W, b, train). But look train is not a quantity, it’s just an optimizer trying to minimize error. So, based on the current error when you run train, it will update values of W and b. This will continue for all 20000 epochs.</p><p>As you can see at the end W and b values are very close to its original values.</p><p>You can find a full code <a href="https://github.com/ajayunagar/Baby-Steps-With-Tensorflow/tree/master/Linear%20Regression">here</a>.</p><h3>Logistic Regression</h3><p>We will use iris data for logistic regression. Iris data has three classes (setosa, versicolor and virginica). I used setosa as class “0” and versicolor and virginica as class “1”.</p><p>Here is how you import data using tensorflow. We have two files iris_training.csv and iris_test.csv</p><pre>iris_training = &quot;iris_training.csv&quot;<br>iris_testing = &quot;iris_test.csv&quot;</pre><p>Now to import data from these csv. More about reading data in tensorflow <a href="https://www.tensorflow.org/programmers_guide/reading_data">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*W35JiskZ7bmKj61SdAhoMA.png" /></figure><p>Now logistic regression is useful can do binary classification only! So, we need to merge two classes.</p><pre># We have three classes, we will merge class = 1 and class = 2. <br># So, now we will have binary classification problem (0, 1)</pre><pre>X_train_data = training_set.data<br>Y_train = training_set.target<br>Y_train[Y_train &gt; 1] = 1</pre><pre>X_test_data = testing_set.data<br>Y_test = testing_set.target<br>Y_test[Y_test &gt; 1] = 1</pre><p>Again it’s the same as before. Define placeholders, variables, Hypothesis, Loss function and Optimizer.</p><pre># tf.placeholder is used for data<br>X = tf.placeholder(tf.float32, shape = [None, 4])<br>Y = tf.placeholder(tf.float32, shape = [None])</pre><pre># tf.Variable is used for Variable<br>W = tf.Variable(tf.random_normal([4,1]), name=&quot;weights&quot; )<br>b = tf.Variable(tf.random_normal([1]), name = &quot;bias&quot;)</pre><pre># Hypothesis<br>hypothesis = tf.sigmoid(tf.matmul(X, W) + b)</pre><pre># Use categorical cross entropy loss (or log loss)<br>cost = -tf.reduce_mean(Y * tf.log(hypothesis) + (1 - Y)*tf.log(1 - hypothesis))</pre><pre># We will define an optimizer (Gradient Descent Optimizer)<br>optimizer = tf.train.GradientDescentOptimizer(learning_rate= 0.001)<br>train = optimizer.minimize(cost)</pre><p>This all steps are self explaining. Here loss in categorical cross entropy loss, you can read about it <a href="https://www.kaggle.com/wiki/LogLoss">here</a></p><p>If hypothesis value is &gt; 0.5, class ‘1’ otherwise class 0. And accuracy is simple classification accuracy.</p><pre># Predict if output probability &gt; 0.5<br>predicted = tf.cast(hypothesis &gt; 0.5, dtype= tf.float32)</pre><pre>#Define accuracy<br>accuracy = tf.reduce_mean(tf.cast(tf.equal(predicted, Y), dtype = tf.float32))</pre><p>Let’s train:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*Kz__goWSomxlaP41X0syhA.png" /></figure><p>Check the accuracy on test data. It is about 0.73</p><pre>_, acc_test = sess.run([predicted, accuracy], feed_dict = {X: X_test_data, Y: Y_test})</pre><pre>print(acc_test)</pre><p>Let’s check the result with sklearn Logistic Regression</p><pre>from sklearn.linear_model import LogisticRegression</pre><pre># Define a logistic regression<br># We will use very small C value because we are not adding any    #  penalty<br>logistic_regression = LogisticRegression(max_iter=20000, C = 1e-9, verbose = True)</pre><pre># fit on training data<br>logistic_regression.fit(X_train_data, Y_train)</pre><pre>print(&quot;test accuracy using sklearn is &quot;, logistic_regression.score(X_test_data, Y_test))</pre><p>Both accuracies are comparable, but sklearn is surprisingly fast. I have to look into it.</p><p>In my full code <a href="https://github.com/ajayunagar/Baby-Steps-With-Tensorflow/tree/master/LogisticRegression">here</a>, I have even tried regularization at the end, but it didn’t improve accuracy.</p><h3>REFERENCES:</h3><ol><li><a href="https://github.com/nfmcclure/tensorflow_cookbook/tree/master/03_Linear_Regression">Tensorflow cookbook</a></li><li><a href="http://sebastianruder.com/optimizing-gradient-descent/">Optimization Algorithms</a></li><li><a href="https://medium.com/all-of-us-are-belong-to-machines/gentlest-intro-to-tensorflow-part-3-matrices-multi-feature-linear-regression-30a81ebaaa6c">Blog</a> and <a href="https://medium.com/all-of-us-are-belong-to-machines/gentlest-intro-to-tensorflow-4-logistic-regression-2afd0cabc54">blog</a></li><li><a href="http://web.stanford.edu/class/cs20si/lectures/notes_03.pdf">Stanford notes</a></li><li><a href="https://www.tensorflow.org/tutorials/wide">Tensorflow tutorial</a></li></ol><p>Note: I strongly suggest to go deep into references. Whatever I’ve written here is just to make you feel comfortable with tensorflow, but all the magics lie in References.</p><p>Happy learning! :D</p><p>Hit ❤ if this was useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88fc83205262" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-group-iitr/baby-steps-with-tensoflow-2-88fc83205262">Baby steps with Tensoflow #2</a> was originally published in <a href="https://medium.com/data-science-group-iitr">Data Science Group, IITR</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Baby steps with Tensorflow #1]]></title>
            <link>https://medium.com/data-science-group-iitr/baby-steps-with-tensorflow-1-b29091d502fd?source=rss-ffd0563b6405------2</link>
            <guid isPermaLink="false">https://medium.com/p/b29091d502fd</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Ajay Unagar]]></dc:creator>
            <pubDate>Thu, 01 Jun 2017 11:55:09 GMT</pubDate>
            <atom:updated>2017-06-01T12:07:47.751Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Deep Learning is a Mandate for Humans, Not Just Machines — Andrew Ng</blockquote><p>Yes, Deep learning is a <a href="https://www.quora.com/Is-Deep-Learning-the-next-big-thing-in-AI">next big thing</a>. Yes, AI is changing <a href="https://www.wired.com/insights/2014/07/artificial-intelligence-changing-world-humankind-must-adapt/">the world</a>. Yes, It will <a href="http://www.huffingtonpost.com/quora/what-jobs-sectors-will-ar_b_14498720.html">take over your jobs</a>. All fuss aside, you need to sit down and write a code on your own to see things working. Practical knowledge is as much important as Theoretical knowledge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*11la7wgbiwa1tKPS.png" /><figcaption>Fact: I’m not a coder.</figcaption></figure><p>There are many deep learning frameworks which make it really easy and fast to train different models and deploy it. Tensorflow, PyTorch, Theano, Keras, Caffe, Tiny-dnn and list goes on. <a href="https://deeplearning4j.org/compare-dl4j-torch7-pylearn">Here</a> is the great comparison for those want to know pros and cons of each one.</p><p>We will focus on Tensorflow. (For all the great debaters out there, I’m not a supporter of anyone. Turns out tensorflow is relatively new with really great resources to learn and most of the industries seems to use it.) I’m learning tensorflow from other resources, so I will try to merge them here in best way possible. This will surely help those who haven’t used Tensorflow before, I can not say anything for others. Though it is assumed that you all have basic under standing of Neural Networks, Loss functions, Optimization techniques, Backpropagation, etc. If not I suggest you go through <a href="http://neuralnetworksanddeeplearning.com/">this great book</a> by Michael Nielsen. I will also be mentioning more often other libraries like numpy, sklearn, matplotlib, etc.</p><h4>Constants, Variables, Placeholders and Operations</h4><p><strong>Constants</strong>: Here constants has same meaning as in any other programming language. They stores constant value. (Integer, float, etc.)</p><pre>c1 = tf.constant(value = 32, dtype = tf.float32, name = &#39;a&#39;)<br>c2 = tf.constant(value = 20, dtype = tf.float32, name = &#39;b&#39;)</pre><p>Where will you be using constants? Value which are not supposed to change! Like number of layers, shape of the weight vectors, shape of each layer, etc. Some of the great constant initializers are <a href="https://www.tensorflow.org/api_guides/python/constant_op">here</a> (most like numpy). Thing to notice is that you can not even get a value of tensor until you initialize a session. What is session? We will get to it.</p><p><strong>Variables</strong>:</p><p>Variables are those, which will be updated in Tensorflow graph. For example: Weights and biases. More about variables <a href="https://www.tensorflow.org/programmers_guide/variables">here</a>.</p><pre># variable 1 with initial value 100<br>v1 = tf.Variable(initial_value=[100], name = &#39;v1&#39;)</pre><pre># variable 3 with initial value initialized by a constant<br>v3 = tf.Variable(initial_value= tf.random_normal(shape= [100 , 4], mean= 0.0, stddev= 1), name = &#39;v3&#39;)</pre><p><strong>Placeholders</strong>:</p><p>Placeholders are as name suggest reserve space for the data. So, while feed forwarding you can feed data into network through placeholders. Placeholders have defined shape. If your input data has n-dimensions, you need to specify n-1 dimensions and then while feeding, you can feed data into batches in the network. More about placeholders <a href="https://www.tensorflow.org/versions/r0.11/api_docs/python/io_ops/placeholders">here</a>.</p><pre># For example lets say you have MNIST data<br># MNIST digits are 28*28 pixels, so you need to specify this <br>#dimension in placeholder.<br>#Here shape = [None, 28*28], where None can take any value.<br>ph1 = tf.placeholder(dtype= tf.float32, shape= [None, 28*28])</pre><p><strong>Operations:</strong></p><p>Operation are basic function we define on variables, constants and placeholders. More about operations <a href="https://www.tensorflow.org/api_guides/python/math_ops">here</a></p><pre># multiply c1 and c2<br>o1 = tf.multiply(c1, c2)</pre><pre># sum of elements of v3<br>o4 =tf.reduce_sum(v3)</pre><h4>Session</h4><p>Session is a class implemented in Tensorflow for running operations, and evaluating constants and variables. More about session <a href="https://www.tensorflow.org/api_docs/python/tf/Session">here</a>.</p><pre># Start a session<br>sess = tf.Session()</pre><pre># We can evaludate o1 and o2<br>print(sess.run(o1), sess.run(o2))</pre><pre># We need to initialize all the variables defined<br># before evaluating operations which contain variables<br>sess.run(tf.global_variables_initializer())</pre><pre># Now we can evaluate operation on variables<br>print(sess.run(o4))</pre><h4>How Tensoflow works?</h4><p>What are the main steps of any machine learning algorithm in Tensorflow?</p><ol><li>Import the data, normalize it, or create data input pipeline.</li><li>Define an algorithm — Define variables, structure of the algo, loss function, optimization technique, etc. Tensorflow creates static computational graphs for this.</li><li>Feed the data through this computation graph, compute loss from loss function and and update the weights (variables) by backpropagating the error.</li><li>Stop when you reach some stopping criteria.</li></ol><p>Here is vary simple example for multiply operation on two constants.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/0*uvXAUUtje1B01o_s.png" /></figure><p>And here is other simple computation graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*UUJDu2UBCDv0tWJuW19syQ.png" /><figcaption>Simple computation Graph</figcaption></figure><p>That’s it for now!</p><h4>Source Code:</h4><p>You can find source code for this assignment on my <a href="https://github.com/ajayunagar/Baby-Steps-With-Tensorflow/tree/master/Tensorflow%20Basics">github repo.</a></p><h3>References:</h3><ol><li>Really good and detailed <a href="https://medium.com/@camrongodbout/tensorflow-in-a-nutshell-part-one-basics-3f4403709c9d">blog</a>.</li><li><a href="https://github.com/nfmcclure/tensorflow_cookbook/tree/master/01_Introduction">Github</a></li><li><a href="https://www.tensorflow.org/get_started/get_started">Getting Started with Tensorflow</a></li></ol><p>Next we will see Linear and Logistic Regression.</p><p>Hit ❤ if you find this useful. :D</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b29091d502fd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-group-iitr/baby-steps-with-tensorflow-1-b29091d502fd">Baby steps with Tensorflow #1</a> was originally published in <a href="https://medium.com/data-science-group-iitr">Data Science Group, IITR</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Support Vector Machines. Unwinded.]]></title>
            <link>https://medium.com/data-science-group-iitr/support-vector-machines-svm-unraveled-e0e7e3ccd49b?source=rss-ffd0563b6405------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0e7e3ccd49b</guid>
            <category><![CDATA[predictive-modeling]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[svm]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Ajay Unagar]]></dc:creator>
            <pubDate>Sat, 25 Mar 2017 22:25:01 GMT</pubDate>
            <atom:updated>2018-07-03T17:46:49.713Z</atom:updated>
            <content:encoded><![CDATA[<p>After completing 4 Algos of our <a href="https://medium.com/data-science-group-iitr/algos-algos-everywhere-f4e684473f14#.69wr65ek8">12 Algos in 12 Days</a> series, here is one of the most popular and most talked about Algorithm since its development. Best thing I like about SVM is that it’s completely based on Mathematical Optimization problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*glwFhnB3OAupN4oZP4LBxA.jpeg" /><figcaption>Don’t look at the trees. Focus on Supports for now :D</figcaption></figure><p>Support Vector Machine is a supervised machine learning algorithm which can be used for both classification and regression problems. SVM is a generalization of a simple classifier called maximum margin classifier.</p><h3><strong>Mathematics behind Algorithm:</strong></h3><p>Mathematics of SVM is little bit tricky. And I can not avoid it. Sorry for little bit more maths for this Blog. But then one should remember,</p><blockquote>Small minds discuss persons. Average minds discuss events. Great minds discuss ideas. Really great minds discuss mathematics.</blockquote><p>The goal of SVM is to identify an optimal separating hyperplane which maximizes the margin between different classes of the training data.</p><p><strong>Hyperplane: </strong>It is basically a generalization of plane.</p><ul><li>in one dimension, an hyperplane is called a point</li><li>in two dimensions, it is a line</li><li>in three dimensions, it is a plane</li><li>in more dimensions you can call it an hyperplane</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*7pS12cmdNItZoDVJpc5iGw.png" /><figcaption>Green one is plane! Sadly we can not only imagine hyper plane! Dimensionality sucks ;/</figcaption></figure><p>We can define <strong>margin</strong> in two ways.</p><ul><li><strong>Functional Margin</strong>: Let’s focus on binary classification {-1, 1} problem for now. We’ll write our classifier as</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*LPFdhngvF1pYqu5NuByFDA.png" /><figcaption>g(z) = 1 if z ≥0, -1 otherwise</figcaption></figure><p>Now functional margin of an ith observation is defined by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/190/1*6es1qMFJi-uarkNOTemNcQ.png" /></figure><p>Now functional margin of classifier is smallest of the functional margins of individuals training examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/167/1*3SJhcOu2dTFXaDUXy-osTg.png" /></figure><ul><li><strong>Geometric Margin: </strong>It is defined by,</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*5hAh5Umf45uvC_DLZ8VPRQ.png" /></figure><p><strong>Optimal Separating Hyperplane:</strong> Idea is to choose the hyperplane which is at maximize margin from both the classes of training data. Maximizing the distance between the nearest points of each class (minimum of functional margins of all the examples) and the hyperplane would result in an optimal separating hyperplane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*PkjwU5TSRqrAFfzaVCOdDQ.png" /><figcaption>All in one!</figcaption></figure><p><strong>Support Vectors: </strong>Support Vectors are simply the co-ordinates of data points which are nearest to the optimal separating hyperplane.</p><blockquote><strong>How to find this optimal separating Hyperplane?</strong></blockquote><p>So, basically what we want to do is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*MFNBblLgDgm9bHuU6zuD3w.png" /></figure><p>But now, for us we can set functional margin to 1. Because it’s nothing but a scaling which should not affect optimization problem. So, this maximization problem converges to minimization problem. Which is,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*YexEnTz7pJwORiO8PPfy2Q.png" /></figure><p>I know by now you’ll be feeling</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*W-LUd1fYkoIzXybomzi6JQ.jpeg" /></figure><p>Okay I admit it. This was too much, but much needed as well. After this you can read <a href="http://cs229.stanford.edu/notes/cs229-notes3.pdf">Andrew Ng’s notes</a> on SVM.</p><blockquote><strong>What if Data is not completely separable?</strong></blockquote><p>In practice, real data is messy and cannot be separated perfectly with a hyperplane. Now in this case there are no two hyperplanes which separate the data with no points between them.</p><p>So, the constraint of maximizing the margin of the line that separates the classes must be relaxed. This is called the soft margin classifier. This allows some points in the training data to violate the separating line. A tuning parameter is introduced called C which defines the amount of violation of the margin allowed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*2JYKSM0Kr-212MsSfbTfdA.png" /></figure><p>So, now relaxed constraint looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*N8iHo0RqN2H1tsmSc9XFUg.png" /></figure><p>Where C is a penalty parameter. This is called a soft margin classifier, because we allow that data of one class can be in the region of the other class but we’ll put a penalty on that. The smaller the value of C, the lesser the sensitivity of an algorithm to the training data and it tries to find separating plane with largest margin which results in lower variance but higher bias. On the other hand The larger the value of C, the higher the sensitivity of an algorithm is to the training data because it plane tries to separate all classes correctly which results in higher variance and lower bias.</p><blockquote><strong>What if Data is not Linearly separable?</strong></blockquote><p>In the case of non-linearly separable data points SVM uses the <strong>kernel trick</strong>. The idea stems from the fact that if the data cannot be partitioned by a linear boundary in its current dimension, then projecting the data into a higher dimensional space may make it linearly separable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*L7hJrjmrt-JyaHs8YHvk9A.jpeg" /><figcaption>Function used to project data in higher dimension is called Kernel function.</figcaption></figure><p><strong>Type of Kernels</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/0*DdzGfZNYG2OH7mGq.png" /><figcaption>Where Xi and Xj are observation points.</figcaption></figure><p>Here, controlling parameter is gamma for all the kernels, except linear. From my experience, RBF is the most popular kernel choice in SVM.</p><p><strong>SVM for multiclass Classification:</strong></p><p>We have talked about binary classification problem using SVM. But, how to extend it for multiclass classification problem is still an ongoing research.</p><p>Mainly there are two methods for Multiclass classification in SVM.</p><ul><li><strong>One-against-one method</strong>: This method constructs k(k − 1)/2 classifiers where each one is trained on data from two classes.</li><li><strong>One-against-all method</strong>: It constructs k SVM models where k is the number of classes. The mth SVM is trained with all of the examples in the mth class with positive labels, and all other examples with negative labels.</li></ul><h3><strong>Is it really beautiful?</strong></h3><p><strong>Pros:</strong></p><ul><li>It is really effective in higher dimension. If you have more features than training examples, most of the algorithms perform very bad, but SVM is the only algorithm which can saves you in this situation.</li><li>Best algorithm if you data are separable. That two classes are not mixed.</li><li>Only support vectors affect the optimally spaced hyperplane. So, it is less affected by outliers.</li></ul><p><strong>Cons:</strong></p><ul><li>On large dataset it takes too much time. Mainly because of kernel function calculations and finding optimal hyperplane in higher dimensions.</li><li>Can not perform well in case of overlapping classes.</li><li>Can only give you 0–1 classification. Probably estimates computation are really expensive.</li></ul><h3>PARAMETERS:</h3><ul><li><strong>kernel</strong>: ‘linear’, ‘polynomial’ or ‘rbf’. Type of kernel you want to use</li><li><strong>C</strong>: penalty on data point on the opposite side of separating Hyperplane.</li><li><strong>gamma</strong>: Kernel parameter. Not applicable for linear kernel though.</li><li><strong>degree</strong>: In case of polynomial kernel you can specify degree of polynomial you want to use.</li></ul><p>Yes, SVM has very less parameter to tune on. And generally it works best with default values.</p><h3>Implementation in Python:</h3><p>In Python, scikit-learn is a widely used library for implementing machine learning algorithms, SVM is also available in scikit-learn library.SVM assumes that your inputs are numeric. If data have categorical inputs you may need to convert them to binary dummy variables . Here, SVM is applied on a Image segmentation data in which there are 19 continuous variables used to predict the type of Image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Fw5kPk52VU06btAjfnKadg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*aaMSgmDXakIq5ArtCWdopA.png" /></figure><p>Accuracy =0.94</p><p>Tuning parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Y0o6kZu1Zb5L3nR2zRGVaQ.png" /></figure><p>The best parameters- C=100 and kernel=”linear”</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*F0hbLeEVAsD0_v9bDxSuaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*De_w5e2QtAoinzZ5v90Bnw.png" /></figure><p>This is simple python implementation of SVM using sklearn library.</p><h3>REFERENCES:</h3><ul><li><a href="http://scikit-learn.org/stable/modules/svm.html">sklearn page for SVM.</a></li><li><a href="http://cs229.stanford.edu/notes/cs229-notes3.pdf">Andrew Ng’s notes on SVM.</a></li><li><a href="https://www.analyticsvidhya.com/blog/2015/10/understaing-support-vector-machine-example-code/">AV Blog</a></li><li><a href="http://www.statsoft.com/Textbook/Support-Vector-Machines">STASTICA</a></li></ul><p><strong>Footnotes</strong>:</p><p>This is so far the longest Blog of the <a href="https://medium.com/data-science-group-iitr/algos-algos-everywhere-f4e684473f14#.69wr65ek8">series</a>. This blog has tried to touch the basics of each aspect of Support vector machines. To understand it thoroughly refer to links above.</p><p>Thanks for reading :)</p><p>Hit ❤ if you enjoy reading this.</p><p>Co-author: <a href="https://medium.com/u/db6778c071e1">Roopkishor</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0e7e3ccd49b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-group-iitr/support-vector-machines-svm-unraveled-e0e7e3ccd49b">Support Vector Machines. Unwinded.</a> was originally published in <a href="https://medium.com/data-science-group-iitr">Data Science Group, IITR</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Samsung India VP has to say about Data Science?]]></title>
            <link>https://medium.com/data-science-group-iitr/what-does-samsung-india-vp-has-to-say-about-data-science-9e1e5df21dc8?source=rss-ffd0563b6405------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e1e5df21dc8</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[miscellanous]]></category>
            <category><![CDATA[careers]]></category>
            <dc:creator><![CDATA[Ajay Unagar]]></dc:creator>
            <pubDate>Sat, 25 Mar 2017 16:30:19 GMT</pubDate>
            <atom:updated>2017-10-14T10:25:18.386Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://cognizance.org.in/">Cognizance</a>, IIT Roorkee invites many good speakers during their event.</p><p>This time, I got a chance to listen to <a href="https://www.linkedin.com/in/balaji-holur-3711291/"><em>Mr. Balaji Holur</em></a>, senior Vice President of Android Platform and Multimedia System Division at Samsung Research India. And, it turned out to be one of the best talks I have attended so far.</p><h4><strong>What does he have to offer to a Data Science Enthusiast?</strong></h4><blockquote>“Big Data, Data Intelligence, Machine Learning, Vision, IoT all comes down to three basic concepts: Mathematics, Statistics and Probability” — Mr. Balaji Holur</blockquote><p>This is what we were focusing from the beginning. As senior members of <a href="https://medium.com/data-science-group-iitr">DSG, IITR</a>, we have advised all our juniors to strengthen their Statistics and Probability concepts. Everything else shall follow.<br><em>This somehow give us a relief that we were right all this while.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gwj8Rm1ySQjNoHUpg1zwSA.jpeg" /><figcaption><strong>Sorry for the blurry Image. But, this is all I have. He used the word MATHEMATICS at least 100 times in his talk!</strong></figcaption></figure><p>According to him, all of us are on the same page in the world of AI and Machine Learning because these are relatively new fields and it is possible that you know more about AI than your company VP. And I second that. When you are learning from same Coursera course as your senior, why would there be a knowledge gap.</p><blockquote><strong>All that matters is the time put in by you, or the effort.</strong></blockquote><h4><strong>Why should his views matter?</strong></h4><p>When you are diving in a new line of study, it is always better to see a bigger picture. And, listening to VP of one of the BIG BOYS of Silicon Valley will give you a rough estimate(gotta cope anyway).</p><p>In his presentation, he briefed about all the technologies which Samsung is working on currently. Not surprisingly, <strong><em>they are centered around Advanced Machine Learning and Applied Artificial Intelligence</em></strong>. <br>And these skills are going to be most important for at least next 50 Years. Deep Learning which has evolved rapidly in last 5 years is going to stay and those who excel in it will be the one who’ll succeed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*LdnJWkiI31Ru_z876GEG_w.jpeg" /><figcaption><strong>If you don’t use data driven approach for business problems.</strong></figcaption></figure><p>Apart from business side, all the products use Advance Machine Learning capabilities to understand and serve their users best. <strong>Intelligent Apps</strong>, <strong>Internet of Things</strong>, <strong>Chat bots</strong> and even simple simple photo storing tech like Google photos use ML and AI technologies to serve you better at every step.</p><p>In a nutshell, next 30 Years are going to be the best for Data Economy. Those who can use Data well are going to win. Simple. <br>And if you want to remain competitive in technical field, it is high time that you start learning about Data Science. Noobs can start with <a href="https://www.coursera.org/learn/machine-learning">Machine Learning Coursera course</a> or you can follow our <a href="https://medium.com/data-science-group-iitr/algos-algos-everywhere-f4e684473f14#.hhefbpsf8">12A-12D series</a>!</p><blockquote><strong>Key Notes</strong></blockquote><ul><li>Learn <strong>Mathematics, Statistics and Probability</strong>.</li><li>Learn more of 1.</li><li>If you are still thinking “whether ML is right choice for you”,You are really a confusing personality.</li><li>If you are thinking that ML is only for Computer Science majors, Mr. Balaji is Mechanical Engineering major from IIT Kanpur and he is leading hundreds of employees from Computer Science major.</li><li>Put an effort in learning.</li></ul><p>This gave me more enthusiasm than ever to work in this field and work for other juniors who are seeking help through <a href="https://www.facebook.com/dsgiitr">DSG</a>.</p><p>Thank you for reading!<br>Hit ❤ if this clears some of your doubts.</p><p>Edited by: <a href="https://medium.com/u/ae175187b1b9">Akhil Gupta</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e1e5df21dc8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-group-iitr/what-does-samsung-india-vp-has-to-say-about-data-science-9e1e5df21dc8">What Samsung India VP has to say about Data Science?</a> was originally published in <a href="https://medium.com/data-science-group-iitr">Data Science Group, IITR</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[In my perfect world! Himalayas.]]></title>
            <link>https://medium.com/@unagar/in-my-perfect-world-himalayas-e726e923e092?source=rss-ffd0563b6405------2</link>
            <guid isPermaLink="false">https://medium.com/p/e726e923e092</guid>
            <category><![CDATA[himalayas]]></category>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[india]]></category>
            <category><![CDATA[nature]]></category>
            <category><![CDATA[adventure]]></category>
            <dc:creator><![CDATA[Ajay Unagar]]></dc:creator>
            <pubDate>Sun, 26 Feb 2017 18:46:54 GMT</pubDate>
            <atom:updated>2017-02-28T09:11:38.110Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>I don’t want to travel the world. I want to be in one place at a time.</blockquote><p>When people ask me what’s the best thing you like about your college, my answer is always the same “proximity of the Himalayas”. I’ve never been on a trip except some small family trips before coming to IITR. But these four years I’ve traveled a lot and experienced the life of mountains. Sometimes I get those kick-ins when I need to be out on the mountains. Friends are not always ready when you want to. So, lets go Solo! This time I ended up in Kasol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*z7IGWWM1IFKe32b6_gM34Q.jpeg" /><figcaption>View from my room at Hosteller in Kasol!</figcaption></figure><p>Kasol is lively place with the best food and good people. You can roam around, make friends and experience food at different cafes nearby. Or if you fill cozy, take your favorite book or put on your earphones in and let yourself glide into that moment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*f-6p_KhoAEkZnmCoQE6Rjw.jpeg" /><figcaption>Roaming around and clicking clicks!</figcaption></figure><p>There are many places around Kasol you can visit. The next day I started for Tosh. Never hire a taxi if you meant to complete an affordable trip. Public transport is easily available in Himachal. Bus will drop you at Barsheni, from there Kasol is 3 km trek.</p><p>Tosh is a beautiful little village surrounded by mountains and full of lovely peoples. When I was on trek I saw a guest house on the top of a hill. It was decided. Just hoped that it wouldn’t be much costly. Well, where would you use your gujju skills if not for bargaining :P Got 300rs a day room in this heaven!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*HRM0d3zFfiycxTPMDOSgLQ.jpeg" /><figcaption>“THE LAST RESORT” ~ Dream house on the mountain ❤</figcaption></figure><p>Aunty who operates this guest house (famously known as pinki didi) cooks delicious food, just what you need in this serenity. Service is pretty good and this house has one of the best views I’ve ever seen. You can not close your eyes watching those mighty and calm mountains at a distance! You get an urge to go there and climb one. But again you are lazy enough that you sit on that comfy chair and just close your eyes and sleep like never before!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*UHOttIHuVNOzoCGUoPuyNA.jpeg" /><figcaption>Morning coffee! View from window of my room ❤</figcaption></figure><p>How do you describe this! Out of my league. Even the great writers would have to put up some efforts in writing about the greatness of the mountains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*Pe25CrfjP8eAf3elw_69SQ.jpeg" /><figcaption>High on Nature!</figcaption></figure><p>The next morning I was sitting outside in the garden and I felt eternal moments of silence and peace. Those moments when you start asking the purpose of your existence and start questioning on Life, Universe and Everything. These moments are to remember. Just close your eyes, let the sun shine upon you and let yourself fly with the wind freely far from here in your <em>perfect world.</em></p><p>While returning after trekking down to Barsheni, I got to know that I missed 12am bus, and next bus is on 4 pm. And I don’t travel in taxi (Just my thing). So, I thought of trekking down all the way to Manikaran which is around 14 km from Barsheni. Within 3 hrs I was in Manikaran. And from there I returned with heavy heart and mind full of memories.</p><p>Some suggestions for solo traveling in Himalayas:</p><ol><li>Never ever hire taxi unless you want to make your trip same as everyone else. Try to use public transport as much as possible, the best way to understand locals and discover new places away from the crowd.</li><li>Stay away from the hotels. Try guest houses, hostels or homestays for that matter. You’ll meet like minded people there. And remember to behave Indian while talking with locals, best way you can bargain :P. They also respect travelers who actually there to understand them rather then just clicking selfies.</li><li>Don’t rush through places. It doesn’t matter how many places you cover. Try to explore one at a time and enjoy it fully.</li><li>Eat local food. You’ll understand subtle savor of their food!</li><li>Keep nature clean.</li></ol><p>Hit ❤ if it was worth a reading! And yes GET OUT!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e726e923e092" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Placement Experience.]]></title>
            <link>https://medium.com/data-science-group-iitr/interview-experience-1-ab7a7aa8a0a1?source=rss-ffd0563b6405------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab7a7aa8a0a1</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[experience]]></category>
            <category><![CDATA[campus-placements]]></category>
            <dc:creator><![CDATA[Ajay Unagar]]></dc:creator>
            <pubDate>Thu, 12 Jan 2017 17:25:10 GMT</pubDate>
            <atom:updated>2017-03-28T08:34:54.183Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Placement season is like GOT, you never know what will happen in the next episode. Sometimes it’s quite random. But if you apply pragmatic approach you might find some spoilers :P</blockquote><p>My first advice is that give your best, and do not get disheartened. This is just a beginning of your professional career.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*Q3P5vUvT9ed1qrPngElGDw.jpeg" /><figcaption><strong>Feeling you get after 2–3 rejections in placement!</strong></figcaption></figure><p>Placement process has two parts. First, you need to give a test to be shortlisted for an Interview. This test is generally basic coding+ Aptitude test (for IT field) and core questions (for others). So, it is must that you learn coding, if you decide to go for an IT company. (be it SDE, Data Science or Analyst)</p><p>I was shortlisted for four Interviews, out of which I had PPI (Pre Placement Interview) in two. For the interviews, be clear about what you are interested in. I was shortlisted in Citi Group. Interviewer asked me questions on Data Structure and Algorithms. I am not good in this, so I requested him to ask me about Machine Learning (after all that’s all it was on my resume). The profile offered did not require any ML knowledge. I was out of the room in five minutes, but believe me I didn’t feel bad about it at all. The next morning I got an offer from ZS. So, be patient and wait for an Interview where you need to hit hard.</p><p>For ZS, I had three interview rounds (I had a PPI in this, so no test). First round was technical. Interviewer was a Manager of Data Science team. He asked me about my internship (I did my intern in Data Science). I described my work and things I could complete and the ones I could not. And then he started grilling me on my Machine Learning knowledge. The questions were not that hard but you need to understand ML basics very well. We had conversation for an hour starting from Logistic Regression to Convolution Neural Nets.</p><p>The next round was practical implementation round. Interviewer (he was a member of Advance Data Science team) gave me a dataset and I needed to analyze it in half hour. I did my best with different strategies on imbalanced handling, missing value imputation, feature engineering and selection, model selection etc. Then we had discussion on each of this for half an hour. Here, your EDA skills are tested. The one key thing about interview is “never lie”. Be confident to say “NO” if you don’t know something.</p><p>The last round was HR. He asked me about my interests and motivation for Data Science field. When you are a student from non-circuit branch you need to find a solid reason that why you are not pursuing career in your core field. So, give them your true motivation. It need not be any big project, but be honest in this.</p><blockquote><strong>How to prepare for DS Interview:</strong></blockquote><p>Astute understanding of ML is a must. Participate in various competitions to get understanding of EDA and ML model selection. You need to give your time to crack an Interview. For the beginners, read <a href="https://medium.com/data-science-group-iitr/stop-thinking-start-learning-cb74629bca3a#.gemzg219z">this great post</a> by <a href="https://medium.com/u/ae175187b1b9">Akhil Gupta</a>.</p><p>All the best for your future endeavors. <br>Hit ❤ if this was worth a read for you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab7a7aa8a0a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-group-iitr/interview-experience-1-ab7a7aa8a0a1">Placement Experience.</a> was originally published in <a href="https://medium.com/data-science-group-iitr">Data Science Group, IITR</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>