{"id":10721,"date":"2014-02-04T11:57:57","date_gmt":"2014-02-04T10:57:57","guid":{"rendered":"https:\/\/blog.trifork.com\/?p=10721"},"modified":"2014-02-04T11:57:57","modified_gmt":"2014-02-04T10:57:57","slug":"an-introduction-to-mahouts-logistic-regression-sgd-classifier","status":"publish","type":"post","link":"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/","title":{"rendered":"An Introduction To Mahout&#039;s Logistic Regression SGD Classifier"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" style=\"float: left;margin-right: 10px\" alt=\"Mahout-logo\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/mahout-logo-400.png\" width=\"260\" height=\"120\" \/>This blog features classification in Mahout and the underlying concepts. I will explain the basic classification process, training a Logistic Regression model with Stochastic Gradient Descent and a give walkthrough of classifying the Iris flower dataset with Mahout.<\/p>\n<p><!--more--><\/p>\n<h2>Clustering versus Classification<\/h2>\n<p>One of my previous blogs focused on <a href=\"https:\/\/blog.trifork.com\/2011\/04\/04\/how-to-cluster-seinfeld-episodes-with-mahout\/\">text clustering in Mahout<\/a>. Clustering is an example of unsupervised learning. The clustering algorithm finds groups within the data without being told what to look for upfront. This contrasts with classification, an example of supervised machine learning, which is the process of determining to which class an observation belongs. A common application of classification is spam filtering. With spam filtering we use labeled data to train the classifier: e-mails marked as spam or ham. We then can test the classifier to see whether it has done a good job of detecting spam from e-mail messages it hasn&#8217;t seen during the training phase.<\/p>\n<h2>The basic classification process<\/h2>\n<p>Classification is a deep and broad subject with many different algorithms and optimizations. The basic process however remains the same:<\/p>\n<ul>\n<li>Obtain a dataset<\/li>\n<li>Transform the dataset into a set of records with a field-oriented format containing the features the classifier trains on<\/li>\n<li>Label items in the training set<\/li>\n<li>Split a dataset into test set and training set<\/li>\n<li>Encode the training set and the test set into vectors<\/li>\n<li>Create a model by training the classifier with the training set, with multiple runs and passes if necessary<\/li>\n<li>Test the classifier with the test set<\/li>\n<li>Evaluate the classifier<\/li>\n<li>Improve the classifier and repeat the process<\/li>\n<\/ul>\n<h2>Logistic Regression &amp; Stochastic Gradient Descent<\/h2>\n<p>Before we dive into Mahout let&#8217;s look at how Logistic Regression and Stochastic Gradient Descent work. This is very short and superficial introduction to this topic but I hope it gives enough of an idea how the algorithms work in order to follow the example later on. I have included links here and there to Wikipedia and videos of the Coursera Machine Learning course for more information.<\/p>\n<h3>The Logistic function<\/h3>\n<p>Before I discuss Logistic Regression and SGD let&#8217;s look it&#8217;s foundation, the logistic function. The <a href=\"http:\/\/en.wikipedia.org\/wiki\/Logistic_function\">logistic function<\/a> is an S-shaped function whose range lies between 0 and 1, which makes it useful to model probabilities. When used in classification, an output close to 1 can indicate that an item belongs to a certain class. See the formula and graph below.<\/p>\n<p>$latex \\frac{1}{1+e^{-x}}&amp;s=3$&nbsp;<\/p>\n<p><i>Logistic function<\/i><\/p>\n<p><a href=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/logistic-curve.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full\" alt=\"Logistic Function\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/logistic-curve.png\" width=\"300\" height=\"200\" \/><\/a><br \/>\n<i>Graph of the logistic function<\/i><\/p>\n<h3>Logistic Regression model<\/h3>\n<p>Logistic Regression builds upon the logistic function. In contrast to the logistic function above which has a single x value as input, a Logistic Regression model allows many input variables: a vector of variables. Additionally, it consists of weights or coefficients for each input variable. The resulting Logistic Regression model looks like this:<\/p>\n<p>$latex \\frac{1}{1+e^{-(\\beta_0 + \\beta_{1} x_{1} + \\beta_{2} x_{2} + &#8230; + \\beta_{n} x_{n})}}&amp;s=3$&nbsp;<\/p>\n<p><i>Logistic regression model<\/i><\/p>\n<p>The goal now is to find the values for $$\\beta$$s, the regression coefficients, in such a way that the model can classify data with high accuracy. The classifier is accurate if the difference between observed and actual probabilities is low. This difference is also called the cost. By minimizing the cost function of the Logistic Regression model we can learn the values of the $$\\beta$$ coefficients. See the following Coursera video on minimizing the <a href=\"https:\/\/class.coursera.org\/ml-003\/lecture\/36\">cost function<\/a>.<\/p>\n<h3>Stochastic Gradient Descent<\/h3>\n<p>The minimum of the cost function of Logistic Regression cannot be calculated directly, so we try to minimize it via <a href=\"http:\/\/en.wikipedia.org\/wiki\/Stochastic_gradient_descent\">Stochastic Gradient Descent<\/a>, also known as Online Gradient Descent. In this process we descend along the cost function towards its minimum for each training observation we encounter. As a result, the $$\\beta$$ coefficients are updated at every step and eventually as we keep taking steps closer to the minimum the cost is reduced and our model improves.<\/p>\n<h2>Classifying the Iris flower dataset<\/h2>\n<div style=\"float: left;margin-right: 10px\">\n<p><figure id=\"attachment_10814\" aria-describedby=\"caption-attachment-10814\" style=\"width: 100px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/iris_setosa.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-10814\" alt=\"Iris Setosa\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/iris_setosa.jpg\" width=\"100\" height=\"75\" srcset=\"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2014\/01\/iris_setosa.jpg 800w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2014\/01\/iris_setosa-300x225.jpg 300w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2014\/01\/iris_setosa-768x576.jpg 768w\" sizes=\"auto, (max-width: 100px) 100vw, 100px\" \/><\/a><figcaption id=\"caption-attachment-10814\" class=\"wp-caption-text\"><i>Iris Setosa<\/i><\/figcaption><\/figure><\/p>\n<p><figure id=\"attachment_10815\" aria-describedby=\"caption-attachment-10815\" style=\"width: 100px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/Iris_versicolor.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-10815\" alt=\"Iris Versicolor\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/Iris_versicolor.jpg\" width=\"100\" height=\"75\" srcset=\"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2014\/01\/Iris_versicolor.jpg 1984w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2014\/01\/Iris_versicolor-300x225.jpg 300w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2014\/01\/Iris_versicolor-1024x768.jpg 1024w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2014\/01\/Iris_versicolor-768x576.jpg 768w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2014\/01\/Iris_versicolor-1536x1152.jpg 1536w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2014\/01\/Iris_versicolor-1707x1280.jpg 1707w\" sizes=\"auto, (max-width: 100px) 100vw, 100px\" \/><\/a><figcaption id=\"caption-attachment-10815\" class=\"wp-caption-text\"><i>Iris Versicolor<\/i><\/figcaption><\/figure><\/p>\n<p><figure id=\"attachment_10815\" aria-describedby=\"caption-attachment-10815\" style=\"width: 100px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/Iris_virginica.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-10815\" alt=\"Iris Virginica\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/iris_virginica.jpg\" width=\"100\" height=\"75\" \/><\/a><figcaption id=\"caption-attachment-10815\" class=\"wp-caption-text\"><i>Iris Virginica<\/i><\/figcaption><\/figure><\/p>\n<\/div>\n<p>Now that you have a general idea about Logistic Regression and Stochastic Gradient Descent let&#8217;s look at an example. The Mahout source comes with a great example to demonstrate the classification process described above. The unit test <code>OnlineLogisticRegressionTest<\/code> contains a test case for classifying the well-known <a href=\"http:\/\/en.wikipedia.org\/wiki\/Iris_flower_data_set\">Iris flower dataset<\/a>. This is a small dataset from 1936 of 150 flowers with 3 different species: <i>Setosa<\/i>, <i>Versicolor<\/i> and <i>Virginica<\/i> and the width and length of their sepals and petals. The dataset is used as a benchmark for testing classification and clustering algorithms.<\/p>\n<p>The code follows most of the steps of the classification process described above. To follow along make sure you have checked out the <a href=\"http:\/\/svn.apache.org\/repos\/asf\/mahout\/trunk\/\">Mahout source code<\/a>. Open <code>OnlineLogisticRegressionTest<\/code> and look at the <code>iris()<\/code> test case. In the unit test a classifier is trained which can classify the flowers&#8217; species based on dimensions of the sepals and petals. In the next sections I show how Mahout can be used to train and test the classifier and finally assert its accuracy.<\/p>\n<div style=\"clear: both\"><\/div>\n<h3>Setup and parsing the dataset<\/h3>\n<p>See the code snippet below. The first part of the code concerns with setting up a few data structures and load the test and training sets. We also create two separate <code>List<\/code>s, <code>data<\/code> and <code>target<\/code>, for the features of the dataset and the classes we want to predict. Note that the type of the <code>target<\/code> <code>List<\/code> is <code>Integer<\/code> because the classes of species will be encoded to <code>Integer<\/code>s via the <code>dictionary<\/code> based on the order they are processed in the dataset. More on that later. Another <code>List<\/code> called <code>order<\/code> is created to shuffle the contents of the dataset.<\/p>\n<p>In the <code>for<\/code> loop on line 24 we iterate over the lines from the CSV file. In lines 29 to 36 each line is splitted on comma&#8217;s into separate fields and all fields put into a vector, which is added to <code>data<\/code>, the list of vectors. On line 30, the first position of the vector, which corresponds to $$\\beta_{0}$$ is set to 1. $$\\beta_{0}$$ is also known as the intercept term. Look at the regression graph on the following link to see <a href=\"http:\/\/statistiksoftware.blogspot.nl\/2013\/01\/why-we-need-intercept.html\">why we need the intercept<\/a>. The target variable is the 5th position in the CSV file, hence we use <code>Iterables.get(values, 4)<\/code> on line 39 to obtain it and add it to <code>target<\/code>. The other values of the <code>data<\/code> vector are the remaining variables.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n  @Test\n  public void iris() throws IOException {\n\n    \/\/ Snip ...\n\n    RandomUtils.useTestSeed();\n    Splitter onComma = Splitter.on(&quot;,&quot;);\n\n    \/\/ read the data\n    List raw = Resources.readLines(Resources.getResource(&quot;iris.csv&quot;), Charsets.UTF_8);\n\n    \/\/ holds features\n    List data = Lists.newArrayList();\n\n    \/\/ holds target variable\n    List target = Lists.newArrayList();\n\n    \/\/ for decoding target values\n    Dictionary dict = new Dictionary();\n\n    \/\/ for permuting data later\n    List order = Lists.newArrayList();\n\n    for (String line : raw.subList(1, raw.size())) {\n      \/\/ order gets a list of indexes\n      order.add(order.size());\n\n      \/\/ parse the predictor variables\n      Vector v = new DenseVector(5);\n      v.set(0, 1);\n      int i = 1;\n      Iterable values = onComma.split(line);\n      for (String value : Iterables.limit(values, 4)) {\n        v.set(i++, Double.parseDouble(value));\n      }\n      data.add(v);\n\n      \/\/ and the target\n      target.add(dict.intern(Iterables.get(values, 4)));\n    }\n\n    \/\/ randomize the order ... original data has each species all together\n    \/\/ note that this randomization is deterministic\n    Random random = RandomUtils.getRandom();\n    Collections.shuffle(order, random);\n\n    \/\/ select training and test data\n    List train = order.subList(0, 100);\n    List test = order.subList(100, 150);\n    logger.warn(&quot;Training set = {}&quot;, train);\n    logger.warn(&quot;Test set = {}&quot;, test);\n<\/pre>\n<h3>Training the Logistic Regression model<\/h3>\n<p>Now that all the proper data structures are in place let&#8217;s train the Logistic Regression model. The <code>iris<\/code> test will perform 200 runs. This means that it creates 200 instances of the LR algorithm. Also it will do 30 passes through the training set for each run to improve accuracy of the classifier. Mahout&#8217;s Logistic Regression code is based on the pseudocode in the appendix of <a href=\"http:\/\/citeseerx.ist.psu.edu\/viewdoc\/download?doi=10.1.1.177.3514&amp;rep=rep1&amp;type=pdf\">Bob Carpenter&#8217;s paper on Stochastic Gradient Descent<\/a>.<\/p>\n<p>The LR algorithm is created by instantiating the <code>OnlineLogisticRegression<\/code> with the number of classes and the number of features. We pass the values 3 and 5 into the constructor of <code>OnlineLogisticRegression<\/code> because we have 3 classes: <i>Setosa<\/i>, <i>Versicolor<\/i> and <i>Virginica<\/i> and 5 features: the intercept term, the petal length and width, the sepal length and width. The third constructor parameter is used for regularization. See the following Coursera video on <a href=\"https:\/\/class.coursera.org\/ml-003\/lecture\/42\">regularization<\/a>.<\/p>\n<p>In the same loop, after 30 passes over the training set we test the classifier. We iterate through the test set and call the <code>classifyFull<\/code> method which takes a single argument: an observation from the test set. Here it gets interesting: the method returns a <code>Vector<\/code> with probabilities for each of the classes. This means that the sum of all the elements in it have to add to 1, see the <code>testClassify()<\/code> method which checks this invariant. To find the class predicted by the classifier we use the method <code>maxValueIndex<\/code> to find the class with the highest probability.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n    \/\/ now train many times and collect information on accuracy each time\n    int&#x5B;] correct = new int&#x5B;test.size() + 1];\n    for (int run = 0; run &lt; 200; run++) {       OnlineLogisticRegression lr = new OnlineLogisticRegression(3, 5, new L2(1));       \/\/ 30 training passes should converge to &gt; 95% accuracy nearly always but never to 100%\n      for (int pass = 0; pass &lt; 30; pass++) {\n        Collections.shuffle(train, random);\n        for (int k : train) {\n          lr.train(target.get(k), data.get(k));\n        }\n      }\n\n      \/\/ check the accuracy on held out data\n      int x = 0;\n      int&#x5B;] count = new int&#x5B;3];\n      for (Integer k : test) {\n        int r = lr.classifyFull(data.get(k)).maxValueIndex();\n        count&#x5B;r]++;\n        x += r == target.get(k) ? 1 : 0;\n      }\n      correct&#x5B;x]++;\n    }\n<\/pre>\n<h3>Assert accuracy<\/h3>\n<p>After the we have performed 200 runs, each with 30 passes we will test for accuracy. The snippet below checks whether the <code>List<\/code> <code>correct<\/code> does not contain any entries with less than 95% accuracy. Also is checks whether there are no accuracies of 100%, too good to be true, because that would probably indicate a <i>target leak<\/i>. A target leak is information in the training set that unintentionally provides information about the target class, such as identifiers, timestamps but also very subtle pieces of information.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n    \/\/ verify we never saw worse than 95% correct,\n    for (int i = 0; i &lt; Math.floor(0.95 * test.size()); i++) {\n      assertEquals(String.format(&quot;%d trials had unacceptable accuracy of only %.0f%%: &quot;, correct&#x5B;i], 100.0 * i \/ test.size()), 0, correct&#x5B;i]);\n    }\n    \/\/ nor perfect\n    assertEquals(String.format(&quot;%d trials had unrealistic accuracy of 100%%&quot;, correct&#x5B;test.size() - 1]), 0, correct&#x5B;test.size()]);\n<\/pre>\n<h2>Next steps<\/h2>\n<p>This blog gave a short overview of Logistic Regression and Stochastic Gradient Descent in Mahout using the Iris dataset as an example. The next step would be to apply the algorithm on a more complex dataset that requires Mahout&#8217;s vector encoders. The vector encoders are used to classify text and word like variables instead of using <code>double<\/code>s used in the Iris dataset. Other things that are not covered in this blog are ways to evaluate classifiers beyond accuracy. In closing, do you have questions or other feedback? Let me know by leaving a comment!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog features classification in Mahout and the underlying concepts. I will explain the basic classification process, training a Logistic Regression model with Stochastic Gradient Descent and a give walkthrough of classifying the Iris flower dataset with Mahout.<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"categories":[40],"tags":[236,361,9],"class_list":["post-10721","post","type-post","status-publish","format-standard","hentry","category-mahout","tag-apache-mahout","tag-classification","tag-open-source"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>An Introduction To Mahout&#039;s Logistic Regression SGD Classifier - Trifork Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"An Introduction To Mahout&#039;s Logistic Regression SGD Classifier - Trifork Blog\" \/>\n<meta property=\"og:description\" content=\"This blog features classification in Mahout and the underlying concepts. I will explain the basic classification process, training a Logistic Regression model with Stochastic Gradient Descent and a give walkthrough of classifying the Iris flower dataset with Mahout.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/\" \/>\n<meta property=\"og:site_name\" content=\"Trifork Blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-02-04T10:57:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/mahout-logo-400.png\" \/>\n<meta name=\"author\" content=\"frank\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"frank\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/\",\"url\":\"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/\",\"name\":\"An Introduction To Mahout&#039;s Logistic Regression SGD Classifier - Trifork Blog\",\"isPartOf\":{\"@id\":\"https:\/\/trifork.nl\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/mahout-logo-400.png\",\"datePublished\":\"2014-02-04T10:57:57+00:00\",\"author\":{\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/00fad6c5829f6770345f23ccace2e54f\"},\"breadcrumb\":{\"@id\":\"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/#primaryimage\",\"url\":\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/mahout-logo-400.png\",\"contentUrl\":\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/mahout-logo-400.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/trifork.nl\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"An Introduction To Mahout&#039;s Logistic Regression SGD Classifier\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/trifork.nl\/blog\/#website\",\"url\":\"https:\/\/trifork.nl\/blog\/\",\"name\":\"Trifork Blog\",\"description\":\"Keep updated on the technical solutions Trifork is working on!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/trifork.nl\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/00fad6c5829f6770345f23ccace2e54f\",\"name\":\"frank\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5c39a948f2b70fa900b25dc79cde8643?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5c39a948f2b70fa900b25dc79cde8643?s=96&d=mm&r=g\",\"caption\":\"frank\"},\"url\":\"https:\/\/trifork.nl\/blog\/author\/frank\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"An Introduction To Mahout&#039;s Logistic Regression SGD Classifier - Trifork Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/","og_locale":"en_US","og_type":"article","og_title":"An Introduction To Mahout&#039;s Logistic Regression SGD Classifier - Trifork Blog","og_description":"This blog features classification in Mahout and the underlying concepts. I will explain the basic classification process, training a Logistic Regression model with Stochastic Gradient Descent and a give walkthrough of classifying the Iris flower dataset with Mahout.","og_url":"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/","og_site_name":"Trifork Blog","article_published_time":"2014-02-04T10:57:57+00:00","og_image":[{"url":"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/mahout-logo-400.png","type":"","width":"","height":""}],"author":"frank","twitter_card":"summary_large_image","twitter_misc":{"Written by":"frank","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/","url":"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/","name":"An Introduction To Mahout&#039;s Logistic Regression SGD Classifier - Trifork Blog","isPartOf":{"@id":"https:\/\/trifork.nl\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/#primaryimage"},"image":{"@id":"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/#primaryimage"},"thumbnailUrl":"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/mahout-logo-400.png","datePublished":"2014-02-04T10:57:57+00:00","author":{"@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/00fad6c5829f6770345f23ccace2e54f"},"breadcrumb":{"@id":"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/#primaryimage","url":"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/mahout-logo-400.png","contentUrl":"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/01\/mahout-logo-400.png"},{"@type":"BreadcrumbList","@id":"https:\/\/trifork.nl\/blog\/an-introduction-to-mahouts-logistic-regression-sgd-classifier\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/trifork.nl\/blog\/"},{"@type":"ListItem","position":2,"name":"An Introduction To Mahout&#039;s Logistic Regression SGD Classifier"}]},{"@type":"WebSite","@id":"https:\/\/trifork.nl\/blog\/#website","url":"https:\/\/trifork.nl\/blog\/","name":"Trifork Blog","description":"Keep updated on the technical solutions Trifork is working on!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/trifork.nl\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/00fad6c5829f6770345f23ccace2e54f","name":"frank","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5c39a948f2b70fa900b25dc79cde8643?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c39a948f2b70fa900b25dc79cde8643?s=96&d=mm&r=g","caption":"frank"},"url":"https:\/\/trifork.nl\/blog\/author\/frank\/"}]}},"_links":{"self":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts\/10721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/comments?post=10721"}],"version-history":[{"count":0,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts\/10721\/revisions"}],"wp:attachment":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/media?parent=10721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/categories?post=10721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/tags?post=10721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}