<?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 Dmitry Yemelyanov on Medium]]></title>
        <description><![CDATA[Stories by Dmitry Yemelyanov on Medium]]></description>
        <link>https://medium.com/@dmitrijs.jemeljanovs?source=rss-efefa934944------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*aFQjNjhdps9Tqr2VX6xT1A.jpeg</url>
            <title>Stories by Dmitry Yemelyanov on Medium</title>
            <link>https://medium.com/@dmitrijs.jemeljanovs?source=rss-efefa934944------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:54:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dmitrijs.jemeljanovs/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[Textual data augmentation with back-translation]]></title>
            <link>https://medium.com/riga-data-science-club/textual-data-augmentation-with-back-translation-34c02f47dcd1?source=rss-efefa934944------2</link>
            <guid isPermaLink="false">https://medium.com/p/34c02f47dcd1</guid>
            <category><![CDATA[data-augmentation]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Dmitry Yemelyanov]]></dc:creator>
            <pubDate>Fri, 11 Sep 2020 18:43:26 GMT</pubDate>
            <atom:updated>2020-09-11T18:43:26.379Z</atom:updated>
            <content:encoded><![CDATA[<p>You are probably familiar with numerous computer vision augmentation techniques like image random flipping, rotating, cropping. In Natural Language Processing domain data augmentation is a much more challenging task!</p><p>Let’s get familiar with one of the powerful text augmentation techniques: Back Translation. In this approach, one makes use of machine translation to paraphrase a text while retaining the meaning.</p><p>The back-translation process is following:</p><ul><li>Take some sentence and translate to another language</li><li>Translate the output sentence back to original language</li><li>Check if the new sentence is different from the original sentence. If it is, then we use this new sentence as an augmented version of the original text.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*m9WLq4P3kNOU1sytcMWeUA.png" /><figcaption>Back-translation with a single language: French</figcaption></figure><p>In case the sentence is still the same, you can take advantage of several intermediate languages, for example:</p><p>1. English: Riga is a beautiful city near the Baltic Sea</p><p>2. Latvian: Rīga ir skaista pilsēta netālu no Baltijas jūras</p><p>3. Russian: Рига — красивый город на берегу Балтийского моря</p><p>4. Back to English: Riga is a beautiful city on the shores of the Baltic Sea</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l10GSUHeemEe7QZHR23F5A.png" /><figcaption>Back-translation with multiple intermediate languages</figcaption></figure><p>Having this process automated for your training set you might achieve much better performance of your NLP model!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34c02f47dcd1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riga-data-science-club/textual-data-augmentation-with-back-translation-34c02f47dcd1">Textual data augmentation with back-translation</a> was originally published in <a href="https://medium.com/riga-data-science-club">Riga Data Science Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TensorFlow model deployment options]]></title>
            <link>https://medium.com/riga-data-science-club/tensorflow-model-deployment-options-32ec56342a8e?source=rss-efefa934944------2</link>
            <guid isPermaLink="false">https://medium.com/p/32ec56342a8e</guid>
            <category><![CDATA[devops-and-mlops]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[tensorflowjs]]></category>
            <category><![CDATA[tensorflow-lite]]></category>
            <category><![CDATA[tensorflow]]></category>
            <dc:creator><![CDATA[Dmitry Yemelyanov]]></dc:creator>
            <pubDate>Tue, 01 Sep 2020 19:34:45 GMT</pubDate>
            <atom:updated>2020-09-01T19:34:45.326Z</atom:updated>
            <content:encoded><![CDATA[<p>Moving TensorFlow model from a Python notebook to production might be a challenging task. Read this post to learn three major deployment options available, their strong sides and weaknesses!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*BwJvfzIt1JlW2QTXB-PZBg.png" /></figure><h3>Client-side</h3><p>TensorFlow.js is a JavaScript library that allows running TensorFlow models in a web browser</p><h4>Pros</h4><ul><li>No network latency for model inference</li><li>Offline inference once model downloaded</li><li>Safe for privacy and GDPR considerations</li><li>No server costs</li></ul><h4>Cons</h4><ul><li>Initial loading time of a model (especially if it’s a big model)</li><li>Device storage and battery consumption limitations</li><li>Lots of modern TensorFlow features are not supported</li></ul><h3>Serverless</h3><p>Deploy TensorFlow model as a serverless application, for example as Amazon Lambda functions or using Google Cloud Functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5G8tNGjQB8gfUDasjo4w5w.png" /></figure><h4>Pros:</h4><ul><li>Cheap (pay-as-you-go)</li><li>Scalable</li><li>Reliable</li></ul><h4>Cons:</h4><ul><li>Response latency on a “cold start” — this approach requires some time to initialize and load dependencies. This negative effect could be eliminated by having a constant pool of “warmed up” functions, but requires additional effort to set up.</li><li>Function execution timeout limit</li><li>Environment memory limitations</li><li>Deployment package size limitations</li></ul><h3>Server-based</h3><p>Deploy a full-fledged server with Flask, FastAPI, TensorFlow Serving used to serve the model via the API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*fPZyFuDRYYIL606iYfP2nQ.png" /><figcaption>TensorFlow Serving on Google Kubernetes cluster</figcaption></figure><h4>Pros:</h4><ul><li>Smaller latency (compared to serverless).</li><li>Scalable infrastructure and costs (if set up properly)</li><li>API and model versioning out-of-the-box (TensorFlow Serving)</li></ul><h4>Cons:</h4><ul><li>Require solid DevOps skills to set up</li><li>Maintenance time</li><li>Idle server will still cost you some money</li></ul><h3>Conclusion</h3><p>TensorFlow.js seems to be well behind of the TensorFlow library and lack of feature support is a main issue with it. Unless your model is using some primitive layers only, be ready that this option might cause some trouble for you.</p><p>Serverless is a great choice for proof-of-concept projects or a minimum viable product of some startup. This option might suit you well also if you are not worried about latency and “cold start” or ready to deal with it by “warming up” functions beforehand. In this case, most importantly, be careful to fit memory and timeout limits of your platform!</p><p>Server-based choice is the best one for professional projects with high request throughput expected. It requires certain skills to set up, but will pay off with great response time and same scalability if configured properly. Please evaluate possible request count per day for your deployment first: if it is low, even an efficient and scalable infrastructure with single idle virtual machine might cost more compared to a serverless deployment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32ec56342a8e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riga-data-science-club/tensorflow-model-deployment-options-32ec56342a8e">TensorFlow model deployment options</a> was originally published in <a href="https://medium.com/riga-data-science-club">Riga Data Science Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dimensionality Reduction with t-SNE]]></title>
            <link>https://medium.com/riga-data-science-club/dimensionality-reduction-with-t-sne-1a3abbe6c6e?source=rss-efefa934944------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a3abbe6c6e</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Dmitry Yemelyanov]]></dc:creator>
            <pubDate>Fri, 28 Aug 2020 19:12:59 GMT</pubDate>
            <atom:updated>2020-08-28T19:12:59.178Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>How do you imagine four dimensions? My best attempt to it is drawing a hypercube, but what about five, six and more? We have to admit that our mind is limited to the 3D world, however in the data science, you are constantly facing data of all sort of the dimensions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NIMZ255zhupRgkuH8rM04A.jpeg" /><figcaption>Tesseract, a four-dimensional hypercube</figcaption></figure><p>Dimensionality reduction comes to the rescue! This article is a brief overview of t-SNE, popular algorithm to reduce dimensions of your data.</p><h3>Word embeddings</h3><p>In this post I will take a look at dimensionality reduction though the prism of word embeddings. Long story short, these are words encoded into multidimensional vectors. Common sizes of embeddings are ranging from 50 to 300. Sometimes it is important to understand what are relationships between particular words vectors, which is nearly impossible in their original multidimensional form. Dimensionality reduction comes to the resque!</p><p>If you are new to word embeddings, please take a look at my two-minute explanation of this term by example:</p><p><a href="https://medium.com/riga-data-science-club/word-embeddings-by-example-9b067c1d0d33">Word Embeddings by example</a></p><h3>Riga is the capital of Latvia</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*S96zTLa5v_M0yZe9D6r-yg.jpeg" /><figcaption>Riga, Latvia</figcaption></figure><p>For the demonstration purpose we will use four GloVe word vectors: “Riga”, “Latvia”, “Capital” and “Country”. Looking at original 300D word vectors gives no clue to the relationships between words, however following short code snippet enables t-SNE reduce word vectors to the size of 2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W0ETJNwueHJZURKB3JovLg.png" /><figcaption>Downsizing 300D GloVe word vectors to 2D</figcaption></figure><p>This trick allows us to make a scatter plot of 2D vectors and build a deeper understanding of the relationship between words: “Riga” to “Latvia” is as “Capital” to “Country”. In other words “Riga is the capital of Latvia”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sraG6w18Yd1sXmYa01BqfA.png" /><figcaption>2D scatter plot of “t-SNEed” word vectors</figcaption></figure><p>Dimensionality reduction is a handy technique apart from the word embedding visualization you will find useful, for example, when dealing with multidimensional feature input.</p><h3>Code</h3><p><a href="https://www.kaggle.com/dmitryyemelyanov/word-vector-dimensionality-reduction-with-t-sne">https://www.kaggle.com/dmitryyemelyanov/word-vector-dimensionality-reduction-with-t-sne</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a3abbe6c6e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riga-data-science-club/dimensionality-reduction-with-t-sne-1a3abbe6c6e">Dimensionality Reduction with t-SNE</a> was originally published in <a href="https://medium.com/riga-data-science-club">Riga Data Science Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Word Embeddings by example]]></title>
            <link>https://medium.com/riga-data-science-club/word-embeddings-by-example-9b067c1d0d33?source=rss-efefa934944------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b067c1d0d33</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <dc:creator><![CDATA[Dmitry Yemelyanov]]></dc:creator>
            <pubDate>Thu, 27 Aug 2020 11:37:47 GMT</pubDate>
            <atom:updated>2020-08-27T11:37:47.424Z</atom:updated>
            <content:encoded><![CDATA[<p>This post is a gentle introduction to the word embeddings, key concept of Natural Language Processing.</p><p>Neural networks are designed to operate on real numbers, so in order to run them on a textual input some preprocessing is required. The common approach used is to convert words into numeric vectors, that would <em>embed</em> word meaning, hence the name of the term: <em>Embeddings</em>.</p><p>Let’s learn this by a simple example:<br>MAN -&gt; [3,4]<br>WOMAN -&gt; [4,6]<br>KING -&gt; [8,4]<br>QUEEN -&gt; [9,6]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*98ay3FzwyNYO6nh1APQ1pQ.png" /></figure><p>The numbers seem random at first, but at a closer look you may notice the same difference between MAN-KING and WOMAN-QUEEN pairs. Similar principle applies to MAN-WOMAN and KING-QUEEN. This demonstrates that vectors represent the meaning by relationship between words: in this case gender and royalty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*vhXRF_vkdsPtN_tGSm1X_w.png" /><figcaption>Word meaning represented by relationship between words</figcaption></figure><p>In practice, word embeddings are usually of a much higher dimensionality. For example, GloVe project is offering word vectors of variable size up to 300 dimensions!</p><p>Luckily you do not have to navigate 300d space to make use of them — neural network will do that for you.</p><p>Happy Machine Learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b067c1d0d33" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riga-data-science-club/word-embeddings-by-example-9b067c1d0d33">Word Embeddings by example</a> was originally published in <a href="https://medium.com/riga-data-science-club">Riga Data Science Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn Heteroskedasticity in 2 minutes]]></title>
            <link>https://medium.com/riga-data-science-club/learn-heteroskedasticity-in-1-minute-42f678911389?source=rss-efefa934944------2</link>
            <guid isPermaLink="false">https://medium.com/p/42f678911389</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-science-training]]></category>
            <dc:creator><![CDATA[Dmitry Yemelyanov]]></dc:creator>
            <pubDate>Wed, 26 Aug 2020 18:45:12 GMT</pubDate>
            <atom:updated>2020-08-26T18:51:05.526Z</atom:updated>
            <content:encoded><![CDATA[<h3>Definition</h3><p>Heteroskedasticity. Scary word, isn’t it? Nothing to be afraid of. This term refers to the circumstance in which the variability of a variable is unequal across the range of values of a second variable that predicts it. Still scary?</p><h3>Intuition</h3><p>Let’s skip complex definitions and try to get intuition by example. Suppose you have a dataset consisting of annual income vs age. Most probably you will observe people in their twenties having little variance in income, as at this point of life they are all equal at the very beginning of their career. You will see much higher variance among people in their thirties and forties due to some people being more fortunate to get successful and other not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*LGxkEnfHCfSsc3dm3W_1bA.jpeg" /><figcaption>Heteroskedasticity example: Income vs Age (data is not real)</figcaption></figure><p>The easiest way to observe this effect visually is by making a scatter plot. If the graph has a cone shape as seen above, you are probably dealing with heteroscedasticity. The opposite is homoscedasticity:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*M2187QiB0o0I6r0JfM0JBg.jpeg" /><figcaption>Homoscedasticity vs Heteroscedasticity</figcaption></figure><h3>Why should you care</h3><p>You may ask “why should I care about this?”. Heteroscedasticity might make linear regression modeling ineffective, therefore you will have to make sure your data doesn’t have this condition or choose another model. Stay safe!</p><h3>Resources</h3><p>You can find a real-life example of Heteroskedasticity in the Kaggle kernel written by Riga Data Science Club member, Dan Yachmenev: <a href="https://www.kaggle.com/danilyachmenev13/riga-eda-geopy-and-model-comparison">https://www.kaggle.com/danilyachmenev13/riga-eda-geopy-and-model-comparison</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i65WpAFABlSZEWcVTj9f4g.png" /><figcaption>Apartment price vs area</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42f678911389" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riga-data-science-club/learn-heteroskedasticity-in-1-minute-42f678911389">Learn Heteroskedasticity in 2 minutes</a> was originally published in <a href="https://medium.com/riga-data-science-club">Riga Data Science Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Geographic coordinate encoding with TensorFlow feature columns]]></title>
            <link>https://medium.com/riga-data-science-club/geographic-coordinate-encoding-with-tensorflow-feature-columns-e750ae338b7c?source=rss-efefa934944------2</link>
            <guid isPermaLink="false">https://medium.com/p/e750ae338b7c</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[geospatial-analytics]]></category>
            <category><![CDATA[geospatial-data]]></category>
            <dc:creator><![CDATA[Dmitry Yemelyanov]]></dc:creator>
            <pubDate>Tue, 28 Apr 2020 21:01:28 GMT</pubDate>
            <atom:updated>2020-05-18T07:16:22.045Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RzlOnUFuRC0MN5kanBMnSg.jpeg" /></figure><h3>Geographic coordinate encoding using TensorFlow feature columns</h3><h3>Introduction</h3><p>Feature engineering is an essential technique to improve the performance of machine learning algorithms. This article deals with encoding geographic coordinate features to make TensorFlow model training more efficient.</p><h3>Geographic coordinates</h3><p>It is quite common to deal with structured data holding geolocation. Usually geo coordinates are stored each in a separate column and expressed with decimal degrees. Let’s take a look at the popular New York City Airbnb Open data <a href="https://www.kaggle.com/dgomonov/new-york-city-airbnb-open-data">dataset</a> as an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a42355c8cff8685a3c3f902713517ee7/href">https://medium.com/media/a42355c8cff8685a3c3f902713517ee7/href</a></iframe><p>No doubt, geographic coordinates hold very important information. In case of Airbnb listings, location of real estate property has huge impact on the rent price. It is essential to make TensorFlow model get most out of this data!</p><h3>Feature Columns</h3><p>The easiest way to input structured data into TensorFlow is using so-called feature columns. TensorFlow documentation states:</p><blockquote>Feature column (tf.feature_column) is a function that specifies how a model should interpret a particular feature.</blockquote><p>In simple words you can think of it as of a bridge between raw input data and your model — the output of a feature column becomes the input to the model.</p><p>Tensorflow offers several types of feature columns that have some specifics in how they are mapping input data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KU_-0ROQZmEDu-NnkZ_sVg.jpeg" /></figure><h3>Numeric Columns</h3><p>Every neuron in a neural network performs multiplication and addition operations on weights and input data, so the best format to input data into model is numeric.</p><p>So does a <a href="https://www.tensorflow.org/api_docs/python/tf/feature_column/numeric_column">numeric column</a> — the simplest type of feature column. It is used to represent real valued features. When using this column, your model will receive the column value from the dataframe unchanged.</p><p>Decimal degrees of geographic coordinates are perfect values for neural network to deal with from a mathematical point of view, so the most tempting solution would be to construct two numeric columns as following:</p><pre>from tensorflow import feature_column<br>latitude = feature_column.numeric_column(&quot;latitude&quot;)<br>longitude = feature_column.numeric_column(&quot;longitude&quot;)</pre><p>This straightforward approach has some major downsides:</p><ul><li>Exact coordinates might introduce noise to the model and increase the risk of overfitting to specific locations instead of finding real patterns.</li><li>A continuous (scalar) representation of coordinates might have a complex non-linear correlation that would be hard for the model to find using such inputs.</li><li>The distribution of coordinate values in the dataset might be skewed, so directly using these features can adversely affect the model.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XcHE0HMdVcdHKyD6oKsdEQ.jpeg" /></figure><h3>Bucketized columns</h3><p>Geographic coordinates are better understood by a model when discretized into meaningful groups — buckets (bins).</p><blockquote>The transformation of numeric features into categorical features, using a set of thresholds, is called <a href="https://developers.google.com/machine-learning/glossary#bucketing"><strong>bucketing</strong></a> (or binning)</blockquote><p>The concept of bucketing perfectly fits geographic data encoding:</p><ol><li>Reduces the impact of small coordinate fluctuations on the model — each bucket smooths out the noise of the data.</li><li>Provides model with a richer input comparing to a scalar value — the model now can learn individual weights for each bucket.</li><li>Allows defining unequally spaced buckets that eliminate negative effect of coordinate distribution skew within a dataset.</li></ol><p>Bucketing has been used in cartography and navigation for centuries widely known in the form of grid reference maps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*vgS15IpxNFKUPmhM97_umg.png" /></figure><blockquote>The same way as lines are dividing up space on the grid map to ease orienteering and geospatial analysis for humans, bucketized columns are dividing continuous value of coordinates into bins to ease machine learning.</blockquote><p>TensorFlow’s feature_column provides bucketized_column method that constructs bucketized column by taking numeric column as an input. The control of binning is available by using <strong>boundaries</strong> parameter:</p><pre>from tensorflow import feature_column<br>latitude = feature_column.numeric_column(&quot;latitude&quot;)<br>longitude = feature_column.numeric_column(&quot;longitude&quot;)<br>latitude = feature_column.bucketized_column(latitude, boundaries=[...])<br>longitude = feature_column.bucketized_column(longitude, boundaries=[...])</pre><p>Defining right boundaries is a crucial decision. There are two options:</p><ul><li><strong>Buckets with equally spaced boundaries</strong>: the boundaries are fixed and encompass the same range (for example, 0–4 degrees, 5–9 degrees, and 10–14 degrees).</li><li><strong>Buckets with quantile boundaries</strong>: each bucket has the same number of points. The boundaries are not fixed and could encompass a narrow or wide span of values.</li></ul><p>Make sure to choose right boundaries depending on coordinate distribution within a dataset — imbalanced dataset requires quantile boundaries, otherwise equally spaced boundaries should work fine.</p><p>The granularity of the boundaries should be evaluated carefully depending on the business value of the model: fine-grained boundaries might allow to learn neighborhood-specific or even block-specific effects, while coarse-grained boundaries will result in learning country-specific or city-specific correlations.</p><blockquote>Model is still lacking insight that geographic location is in fact a concatenation of both coordinates.</blockquote><p>With properly designed buckets the model will learn faster and will get better understanding of coordinate features, however there is still one last thing two improve — latitude and longitude are treated as separate inputs and model needs to put additional effort to build understanding that geographic location is in fact a concatenation of both coordinates.</p><p>Luckily for us, TensorFlow has a feature column that allows us to explicitly define connection between values of two numeric columns.</p><p>Feature crosses come to the rescue!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VerMxklyC4di0lwA3XTcWg.jpeg" /></figure><h3>Feature Crosses</h3><p>Combining features into a single feature, known as <a href="https://developers.google.com/machine-learning/glossary/#feature_cross">feature crosses</a>, enables a model to learn separate weights for each combination of features.</p><pre>feature_column.crossed_column([bucketized_lat, bucketized_lon])</pre><p>This way, instead of having separate latitude and longitude inputs we are explicitly telling the model that both values from these two columns should be treated as a whole.</p><blockquote>Feature crossing coordinates enables model to “see” 2D picture of the map making training much more efficient</blockquote><p>Using the grid map analogy presented earlier, bucketized columns allow model to “see” distinct coordinate axis thus providing model with 1D information for latitude and longitude separately. Feature cross enables model to “see” the whole 2D picture of the map making training much more efficient.</p><h3>Summary</h3><p>Geographic coordinates hold very important information that require careful feature engineering decisions. TensorFlow feature columns API provides all the necessary tools to build efficient data input pipeline.</p><p>Follow these three rules:</p><ol><li>Bucketize latitude and longitude using:<br>a). equally spaced boundaries when dealing with balanced dataset<br>b). quantile boundaries when dealing with skewed coordinate distribution</li><li>Choose granularity of boundaries depending on the map zoom level you are expecting learn the correlations from:<br>a). fine-grained boundaries to learn effects on the local level<br>b). coarse-grained boundaries to learn effects on a city or country level</li><li>Feature cross bucketized coordinates.</li></ol><p>Good luck!</p><h3>References</h3><ul><li><a href="https://www.tensorflow.org/tutorials/structured_data/feature_columns">https://www.tensorflow.org/tutorials/structured_data/feature_columns</a></li><li><a href="https://developers.google.com/machine-learning/data-prep/transform/bucketing">https://developers.google.com/machine-learning/data-prep/transform/bucketing</a></li><li><a href="https://developers.googleblog.com/2017/11/introducing-tensorflow-feature-columns.html">https://developers.googleblog.com/2017/11/introducing-tensorflow-feature-columns.html</a></li><li><a href="https://towardsdatascience.com/tagged/tds-feature-engineering">https://towardsdatascience.com/tagged/tds-feature-engineering</a></li><li><a href="https://datascience.stackexchange.com/questions/19782/what-is-the-rationale-for-discretization-of-continuous-features-and-when-should">https://datascience.stackexchange.com/questions/19782/what-is-the-rationale-for-discretization-of-continuous-features-and-when-should</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e750ae338b7c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/riga-data-science-club/geographic-coordinate-encoding-with-tensorflow-feature-columns-e750ae338b7c">Geographic coordinate encoding with TensorFlow feature columns</a> was originally published in <a href="https://medium.com/riga-data-science-club">Riga Data Science Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>