<?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 Gad Benram on Medium]]></title>
        <description><![CDATA[Stories by Gad Benram on Medium]]></description>
        <link>https://medium.com/@gidutz?source=rss-b45fa95a7293------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sKREfePenX4FxtYE5wFwgw.jpeg</url>
            <title>Stories by Gad Benram on Medium</title>
            <link>https://medium.com/@gidutz?source=rss-b45fa95a7293------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 23:48:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gidutz/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[Taking Google’s Generative Studio to a Test Drive]]></title>
            <link>https://gidutz.medium.com/taking-googles-generative-studio-on-a-test-drive-c059113a4371?source=rss-b45fa95a7293------2</link>
            <guid isPermaLink="false">https://medium.com/p/c059113a4371</guid>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Gad Benram]]></dc:creator>
            <pubDate>Thu, 13 Apr 2023 11:56:50 GMT</pubDate>
            <atom:updated>2023-06-15T01:31:06.625Z</atom:updated>
            <content:encoded><![CDATA[<h3>What&#39;s inside Google’s Generative AI Studio?</h3><h4>The long expected competition to OpenAI’s chatGPT was clearly going to come from Google Cloud. At <a href="http://www.tensorops.ai/">TensorOps</a> we received early access to the studio and decided to take it to a trail run and tell you what we found.</h4><blockquote><strong>Data scientist working on Google Cloud</strong>? Read how you can <a href="https://www.tensorops.ai/post/almost-free-jupyter-notebooks-on-google-cloud">get (almost) free jupyter notebooks on GCP</a> 💸</blockquote><p>In the past decades Google has been leading the global advance in AI, although it felt like the company is lagging in the past months, the <a href="https://cloud.google.com/blog/products/ai-machine-learning/generative-ai-for-businesses-and-governments">recently announced</a> Generative AI Studio as part of Vertex AI definitely puts them back in the lead. We got an exclusive preview of the new features and this is what you can expect from it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*pn95iRFl8pbjSkcuRWe0Dg.gif" /><figcaption>the features of GCP’s Vertex AI</figcaption></figure><h3>What’s in the box?</h3><p>Let’s start with the “grocery” list of features. Generative AI studio started with only text support but has grown its offering since. In the UI you will find some usage examples of the services, these include:</p><ul><li><strong>Image generation</strong></li><li><strong>Code chat</strong></li><li><strong>Speech to text and text to speech</strong></li><li><strong>Various text application</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/0*BRqAtEdFzox7kXka.png" /></figure><p>Examples of using the Studio for Ideation — Google will provide optimized settings for the case</p><p>Behind all these examples is typically a growing set of models. Google initially used the Text-Bison model that was offered in two versions 001 and alpha. Since then more models were introduced. Some of them have bigger and better architectures and some are fine tuned to specific tasks such as code.</p><p>Additionally, Google assists the users in discovering the potential of the studio by providing some examples of how different API calls can adjust the service to their business use case with pre-built prompt templates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/0*mSlVSjc4HE_EiciV.png" /></figure><p>Google explains the differences between the backend model that you can choose</p><p>The chat app is based on <strong>PaLM-2</strong>. This is the older brother of PaLM that was released in April 2022 by google. PaLM-2’s 340B parameters make it capable of accomplishing complex tasks like coding and participating in conversations. The model will likely to get improved as it will be used more, we can also expect Google to release more advanced backed models in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mjbBdZ1-p7cKQkp-bU7aCg.gif" /><figcaption>Palm — 540 parameters allow it to pefrom more flexible tasks. source: <a href="https://ai.googleblog.com/2022/04/pathways-language-model-palm-scaling-to.html">google research</a></figcaption></figure><h3><strong>Built for developers</strong></h3><p>The Generative AI Studio was definitely designed for developers. The UI is less playful that chatGPT, however it allows access to the model parameters that can be tuned to achieve accurate results.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FSJlYX7jL6Mc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DSJlYX7jL6Mc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FSJlYX7jL6Mc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6905db235143d17b30dc17c814132142/href">https://medium.com/media/6905db235143d17b30dc17c814132142/href</a></iframe><p>All the services in Generative AI Studio are, of course, accessible via API. Users of the <a href="https://cloud.google.com/python/docs/reference/aiplatform/latest/index.html">Vertex AI SDK for python </a>will find it easy to integrate the models into their app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yq3QSwJpLimdvKZfsrRW6w.png" /><figcaption>GCP provide code examples of how the model can be used as part of an app</figcaption></figure><h3>Tuned models</h3><p>LLMs and other models are trained on huge amounts of data, but this can make them be too generic. Tuning the LLMs on your data can lead to cost reduction. How come? As of today there are 3 main ways to make LLMs output more specific results:</p><ol><li>Prompt engineering — providing more context in the prompt and engineering the request.</li><li>Context database — referencing the model to some vector set of embedded knowledge or providing the raw data to the model before calling it.</li><li>Tune models — re-training the model on your own data.</li></ol><p>While the first two methods require engineering every request, tuning the model is the only way to persist the modification so that every API call will fit your case better with less data required to be sent to the API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KCAkUyToiJiNS3wo-N4ILQ.png" /><figcaption>Tuned models option</figcaption></figure><h3>Guide the models through examples</h3><p>Helping the models understand the user intention can be the difference between a cool tool that you play with or show to grandma vs an app that you can trust in production. Generative AI Studio allows providing examples of the expected results.</p><p>For example, the transcript summarization lets user input some examples of expected summary results. These hints refine the output of the model, allowing you to do less coding and tranformations on your data before getting the response that you wanted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qa-mB2mbOnYDO33v36ievA.png" /><figcaption>Providing examples of input output to the model</figcaption></figure><h3>UI for non AI experts</h3><p>Democrztizing AI has never been as close as it is these days. Humans with no AI or software background are capable of leveraging AI tools in order to create content, apps and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*PT53IdJAe_K2Wm-ruD9HWw.png" /><figcaption>Example of info-box, part of the GUI explaining users how they can tune their models</figcaption></figure><p>The little info-boxes that the Generative AI Studio places everywhere, provide users with more information about the parameters that they are using. This must be helpful for users who are new to AI or who are not familiar with the specific parameters (like Temperature or Top-k). These parameters are used to tune LLMs, therefore non-AI-experts can easily learn how to modify the reults even if they haven’t read the most recent scientific articles about LLMs.</p><h3>Quality of the results?</h3><p>As of now, it looks like some features are still to be improved and developed. We noticed that the chat app doesn’t take a good advantage of the provided input from previous prompts and mixes the answers with pre-traind knowledge. In a short example that we used, we asked the model to answer questions about an<a href="https://www.theportugalnews.com/news/2023-04-12/girl-power-in-portugal/76602"> article from ThePortugalNews</a> website. It seemed like the model was confusing some statistics coming from the article with other information that it was trained on or that it was over hallucinating due to high temperature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eH5TTaEnMRGoMjsXGAqgfw.png" /><figcaption>The original article</figcaption></figure><p>The model was asked which countries have less female representation in the government than Portugal. While the list of countries that it provided was correct, there were a few mismatches between the article and the answer. For example: it mentioned that the female representation in Portugal was 45.3% even though the article clearly speaks about around 35% and in the list of countries, the model outputed countries that are not mentioned in the article at all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NCoGuP0cX6MxI9JuNhR9Sg.png" /><figcaption>the generated response</figcaption></figure><h3>What’s next for LLMs on GCP?</h3><p>It appears like as more users are going to adopt the product and the usage will increase, the underlying LLMs that Google uses should improve. The design and compatibility for backend integration place Vertex AI in a front position to provide AI as a service.</p><p>In the next blog post, we will dive further into specific use cases of Vertex AI Generative Studio, and how it can be used in production systems. Follow us on <a href="https://www.linkedin.com/company/tensorops">LinkedIn</a> to get more updates content!</p><h4><a href="https://mlearning.substack.com/about">BECOME a WRITER at MLearning.ai</a></h4><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c059113a4371" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Will Google’s Bard Replace Oracle and SnowFlake?]]></title>
            <link>https://gidutz.medium.com/will-ai-replace-oracle-and-snowflake-fbf3c9decd38?source=rss-b45fa95a7293------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbf3c9decd38</guid>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Gad Benram]]></dc:creator>
            <pubDate>Fri, 10 Feb 2023 11:20:05 GMT</pubDate>
            <atom:updated>2024-02-24T22:01:58.540Z</atom:updated>
            <content:encoded><![CDATA[<p>No :) However, back in 2016 I was trying to explain to software engineers how to think about machine learning models from a software design perspective; I told them that they should think of a database. Both serve as a means of storing representations of historical data, which can later be queried.</p><p>With <a href="https://chatgptonline.net/">ChatGPT</a> and <a href="https://blog.google/technology/ai/bard-google-ai-search-updates/">Bard</a> now serving as the backend of information retrieval systems it’s possible that we simply overlooked AI’s biggest potential: replace the traditional data processing tools and big-data technologies mostly for use cases that don&#39;t require a single “correct” answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y1g6j7mDba9UQJLv" /><figcaption>Library, primitive data storage solution. Photo by <a href="https://unsplash.com/@tofi?utm_source=medium&amp;utm_medium=referral">Tobias Fischer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What are databases used for?</h3><p>If you were to run a ride-hailing business, you would need to digitally represent some of your business activities. Rides, drivers, passengers, and orders are all real-world entities that have a digital footprint. As seen with tech-giant Uber, you would build a massive data infrastructure that collects, processes, and stores this information to be used later for running the business.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tz6HewL-6W-Noy2G.png" /><figcaption>Uber’s data architecture, used to store and process ride related data. <a href="https://www.uber.com/en-PT/blog/ubers-journey-toward-better-data-culture-from-first-principles/">https://www.uber.com/en-PT/blog/ubers-journey-toward-better-data-culture-from-first-principles/</a></figcaption></figure><p>As part of this infrastructure, a collection of databases and data warehouses are used to store the data. Uber then use a query engine and a language like SQL to extract the information. This technology allows answering questions like “Is Brandon a good driver?” and “How many rides did Chana have last month?” But are there other ways of storing historical data? And are there new questions we could answer if we stored the data differently?</p><h3>How are neural networks like databases?</h3><p>As of today, neural networks and databases are two different types of systems that are used for different purposes. Neural networks are a type of machine learning algorithm that are used for tasks such as pattern recognition, classification, and prediction.</p><p>One way in which neural networks and databases can be similar is that they can both be used to store and process large amounts of data. For example, a neural network might be trained on a large dataset in order to learn to recognize patterns or make predictions. This way of storing data already allowed asking complex questions on the data that we couldn’t ask before. But the task of retrieving information is still predominantly done with databases.</p><h4>Evidence that Neural Nets know much more than we think</h4><p>During the early years of the current ML spring (2012–2016), models that performed object identification (such as classifying the type of fish from images for example) were very popular. Research on these models showed that the networks could identify patterns like shapes, colors, textures, as well as more complex figures, and used these to determine the class type when they were “asked” to make predictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*t0GhCfhj6UMzlXf_VuPodw.png" /><figcaption>Siddiqui, Shoaib &amp; Salman, Ahmad &amp; Malik, Imran &amp; Shafait, Faisal &amp; Mian, Ajmal &amp; Shortis, Mark &amp; Harvey, Euan. (2017). Automatic fish species classification in underwater videos: Exploiting pretrained deep neural network models to compensate for limited labelled data. ICES Journal of Marine Science. 75. 10.1093/icesjms/fsx109.</figcaption></figure><p>These insights about the secret knowledge of networks inspired work like <a href="https://deepdreamgenerator.com/">DeepDream</a> and other models that attempted to trigger the networks into revealing their secrets. In Transfer Learning, engineers often view networks as having two parts: the first layers are considered the “base knowledge,” while the last layers, the “application layers,” are used to learn how to perform tasks. This is especially true in language models, where the same base knowledge is used with different application layers to perform different tasks such as summarization, question answering, or text generation.</p><h3>Why search when you can ask chatGPT?</h3><p>When OpenAI trained its model language, GPT-3, they fed it with an amazing amount of data. The training itself was <a href="https://www.reddit.com/r/MachineLearning/comments/h0jwoz/d_gpt3_the_4600000_language_model/">estimated to cost more than 4M USD</a>. The model was able to write paragraphs that were barely distinguishable from those written by a human. However, prompting the networks to achieve some relevant text was difficult. There was a sense of randomness in the output of the model based on the provided prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SBzjS6rTLlUh34DLCjIt4g.png" /><figcaption><a href="https://openai.com/blog/instruction-following/">https://openai.com/blog/instruction-following/</a></figcaption></figure><p>OpenAI then made the most incredible move towards controlling what networks output. They trained ChatGPT to provide text based on feedback from users. This way, they were able to “force” the network to output its internal knowledge in a queryable way, revealing that it knew much more than previously thought. ChatGPT apparently knows what’s unique about Donald Trump’s figure of speech or the symptoms of lethal diseases. GPT-3 likely knew it all along, but we lacked the query language that allowed us to extract its knowledge from this very fancy database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*EvpM1T8pCMvqKlqBBb5anQ.png" /><figcaption>ChatGPT not only can emit correct code, but can also document it in Donald Trump&#39;s style. source: screenshot</figcaption></figure><h3>Large Language Models to Replace Data Storage</h3><p>Traditional databases and data warehouses are <strong><em>not</em></strong> going to be obsolete. They will still offer consistency and determinism. AI won’t replace ledgers for banking system or event logging. However, the amount of human work required to store such a lean representation of real-world events will make databases non sufficient for business use cases. Instead of the thousands of people and very complex data architecture that Uber uses to maintain its data, they could use in many cases a much more efficient and advanced deep learning solution. In my humble opinion, startups should consider neural networks as a new way to store foundation data, the type that doesn’t change frequently and holds information that has long term relevance.</p><h3>Large Language Models to Replace Data Processing</h3><p>Another feature of data systems such as Snowflake is their capability to process data to respond to business inquiries, typically using SQL for this purpose. Initial architectures indicate that LLMs will initially receive only relevant data due to their contextual limitations. However, as capabilities expand, it’s anticipated that LLMs could process larger volumes of data simultaneously, potentially replacing traditional SQL-based ETL processes, especially for complex textual data analysis. If the necessary data already exists within the LLM, then accessing external databases, as previously mentioned, might not even be required.</p><p>Thanks to <a href="https://www.linkedin.com/in/pedro-lapietra/">Pedro Lapietra</a> for co-editing. Gad is the founder and CTO of <a href="http://tensorops.ai/">TensorOps</a>.</p><h4><a href="https://mlearning.substack.com/about"><strong>BECOME a WRITER at MLearning.ai</strong></a></h4><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbf3c9decd38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Trick: Almost-Free Jupyter Notebooks on the Cloud!]]></title>
            <link>https://gidutz.medium.com/trick-almost-free-jupyter-notebooks-on-the-cloud-1eabcdda7914?source=rss-b45fa95a7293------2</link>
            <guid isPermaLink="false">https://medium.com/p/1eabcdda7914</guid>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Gad Benram]]></dc:creator>
            <pubDate>Thu, 30 Jun 2022 15:39:09 GMT</pubDate>
            <atom:updated>2022-07-19T13:54:45.206Z</atom:updated>
            <content:encoded><![CDATA[<h4>Google Cloud offers an excellent Jupyter Notebook managed service called Vertex AI Workbench which is relatively pricy. For some cases, I suggest using an old trick that can get you up to a 91% discount: hosting Jupyter Notebooks on Compute Engine Spot Instances using standard templates. This <strong><em>easy</em></strong> solution yields almost the same experience as Google’s managed notebook service, allowing you to be equally productive and considerably reduce costs. In fact, for short ML tasks like EDA or model experimentation, it can be an optimal solution on GCP. However, please mind the cost-SLA tradeoff here.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g6YOnXvlyRGBug_n" /><figcaption>Photo by <a href="https://unsplash.com/@emilep?utm_source=medium&amp;utm_medium=referral">Emile Perron</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Vertex Workbench — Great Experience for high Price!</h3><p>If you are new to data science or have spent the past five years on Mars, Jupyter Notebooks are the most popular coding environment for research, EDAs, and basic training models. Some companies like DataBricks and Netflix even suggest using it beyond interactive tools and integrating it in some ML/Data pipelines. 💡</p><p>In light of their usefulness, Google Cloud built a managed version of Jupyter Notebooks called Vertex AI Workbench. This fantastic service reduces Jupyter Notebooks’ launching time to under 60 seconds and various additional features to make your workflow easier. However, this service introduces a management fee and only supports on-demand instances (and not spot instances) — making it too expensive for non-critical tasks IMO.</p><h3>Deep Learning VMs — Cost Efficient Alternative!</h3><p>Luckily Google Cloud has an alternative product to Vertex AI Workbench called <a href="https://cloud.google.com/deep-learning-vm">Deep Learning VMs</a>. This product is essentially Compute Engine VMs with pre-installed ML/DL images that include popular data science python libraries, R, CUDA, and TensorFlow. Most importantly, when launching the VM, it automatically runs a Jupyter Lab server that can be accessed through the browser.</p><p>Since DL-VMs are not managed services, they are more customizable, thus opening more opportunities to perform cost optimization. When it comes to cost optimization on the cloud, it’s important to mention Spot instances — and indeed, DL-VMs support this feature! But, of course, there is a tradeoff between the user experience and cost-optimization. To learn more about this tradeoff, <a href="https://gadbenram.com/2022/06/27/what-is-the-best-cloud-jupyter-service-on-google/">you can read in this other blog post</a> about the advantages and disadvantages of using different Notebook services on Google.</p><h3>Spot Notebooks?</h3><p>Because DL-VMs are essentially Compute Engine with an image, they have the option to be launched as Spot Instances — therefore opening them to potential Spot discount and not introducing an additional service-management fee!</p><p>Spot Instances are Compute Engine VMs offered with an up to <strong>91%</strong> discount versus the on-demand pricing. Spots have the EXACT same spec as the on-demand equivalent with only one downside: they may abruptly shut down. Spot instances rely on excess hardware available in specific regions; therefore, when other customers willing to pay full price request access, Google gives them priority and ousts you from your spot machine when demand is too high. When working with Spot instances, please recall:</p><ol><li>⚠️ When the machine <strong>shuts down</strong> it happens <strong>abruptly</strong>. You can only get a short notice before it happens.</li><li>♻️ After the machine shuts down <strong>it’s possible to restart it</strong>; no need to create a new one.</li><li>🗄️ Data saved on the machine <strong>disk</strong> will NOT be affected by the shut down — it will be kept there. You will also be paying for this storage while the machine is off.</li><li>😱 On shut down the RAM will be cleared — so any <strong><em>unsaved</em> work will be lost</strong> :/</li><li>📈 If there is <strong>high demand</strong> for the instance type that you are using in that region it <strong>increases the chances of frequent shut downs</strong>.</li></ol><p>So why not use Vertex AI Workbench only with Spot machines and get a 91% discount? Well, Google just doesn’t allow it. It makes sense. Spot instances don’t benefit from SLA, and it stands against Google’s profound approach to reliable user experience. You wouldn’t expect a managed service to shut down due to outages — right? 💁‍♂️</p><p>So how can you use Jupyter Notebooks on Spot machines? Let’s have a quick walkthrough.</p><h3>Tutorial: Launching a Spot Deep Learning VM</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F_IqFfNxC-5M%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D_IqFfNxC-5M&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3193427cacc2e3985908b3853efe9a35/href">https://medium.com/media/3193427cacc2e3985908b3853efe9a35/href</a></iframe><h4><strong>Step 1: Use a shell (terminal) with gcloud tool installed</strong></h4><p>You can either use your computer’s terminal and install the gcloud command tool or use Google&#39;s managed Cloud Shell.</p><h4><strong>Step 2: SELECT an image that you want to run</strong></h4><p>You can read about selecting an image but here are the basics:</p><ul><li>Running data science? use the clean <strong>common</strong> image</li><li>Running deep learning? use the <strong>TensorFlow</strong>/<strong>PyTorch</strong> image</li></ul><h4><strong>Step3: Run the create-instance command</strong></h4><pre>export IMAGE_FAMILY=&quot;common-cpu&quot;<br>export ZONE=&quot;us-central1-b&quot;<br>export INSTANCE_NAME=&quot;notebook-vm-spot&quot;<br>export INSTANCE_TYPE=&quot;e2-standard-2&quot;<br>gcloud compute instances create $INSTANCE_NAME \ <br>       --zone=$ZONE \<br>       --image-family=$IMAGE_FAMILY \  <br>       --image-project=deeplearning-platform-release \ <br>       --maintenance-policy=TERMINATE \<br>       --machine-type=$INSTANCE_TYPE \<br>       --boot-disk-size=200GB \<br>       --provisioning-model=SPOT \<br>       --instance-termination-action=STOP</pre><h4><strong>step 4: secure the connection between your computer and the server</strong></h4><p>To ensure that all access to the notebook is authorized, Google blocks unsecured connections to the machine. Therefore, you will need to create an ssh tunnel to the notebook server from your device. Sounds difficult? Nah, it’s only one line of code.</p><p>On your local computer, run the following command:</p><pre>export PROJECT_ID=&quot;my-gcp-project-id&quot;<br>gcloud compute ssh \<br> — project $PROJECT_ID \<br> — zone $ZONE \<br> $INSTANCE_NAME \<br> — -L 8080:localhost:8080</pre><p>Just keep your terminal open otherwise the connection will be lost 😅.</p><h4><strong>Step 5: Open Jupyter Lab in your local browser</strong></h4><p>Now just go to your browser and open <a href="http://localhost:8080/">http://localhost:8080</a> and that’s it. You can work on your machine. Do remember to save your work on occasions!</p><h3>Tips and advanced tricks</h3><ol><li><strong>Low chances you will get a Spot GPU</strong>. Due to the ongoing shortage of silicone hardware GPUs are scarce resources. If you are using TensorFlow consider getting TPUs (especially Spot ones) instead!</li><li><strong>Small machines live longer</strong> — your machine leverages excess hardware. The more cores and memory used by your instance, the greater the chance it will be snatched to serve full-price paying customers.</li><li><strong>Frequently save your work!</strong> It’s not recommended to use Spot machines for long-running tasks like training neural networks. However if you do, find ways to save your work so you can restore it if the machine restarts. For example: <a href="https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/ModelCheckpoint">create a callback to save the model every few epochs</a>.</li><li><strong>Define a </strong><a href="https://cloud.google.com/compute/docs/instances/create-use-spot#handle-preemption"><strong>shut down script</strong></a> — GCP allows you to run a script just before the instance shuts down. It can allow you to gracefully finish and back up your work.</li><li><strong>Use </strong><a href="https://cloud.google.com/blog/products/compute/google-compute-engine-gets-new-e2-vm-machine-types"><strong>E2 machine types</strong></a> for EDA and non compute heavy use-cases. If you are using large datasets use the e2-highmem group to get more RAM per CPU.</li><li><em>Advanced tip:</em> <strong>Use GCP’s </strong><a href="https://cloud.google.com/deployment-manager/docs/configuration/templates/create-basic-template"><strong>Deployment Manager</strong></a> to create a template and launch the instances from there.</li></ol><p>Did you find this blog post helpful? Feel free to retweet and share! Any comments? Please share them with us here or on our <a href="https://twitter.com/gadbenram">Twitter</a>.</p><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1eabcdda7914" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Remote  development with PyCharm and Google Cloud]]></title>
            <link>https://gidutz.medium.com/remote-development-with-pycharm-and-google-cloud-1a8bdab3433f?source=rss-b45fa95a7293------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a8bdab3433f</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Gad Benram]]></dc:creator>
            <pubDate>Wed, 28 Jul 2021 15:59:58 GMT</pubDate>
            <atom:updated>2024-11-19T16:59:56.048Z</atom:updated>
            <content:encoded><![CDATA[<h3>Remote Coding with PyCharm and Google Cloud</h3><h4>A quick tutorial on how to configure your PyCharm to run on a remote GCP instance using an ssh remote interpreter</h4><h3>What are we trying to achieve?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*BdXltAQKFTYO6rUe7gD6wA.png" /><figcaption>Write code on your notebook but make it run on a remote Google Cloud machine with more RAM and CPU</figcaption></figure><p>When developing a Python application, it’s often convenient to run the code on a GCP instance (AI Notebook / Google Compute Engine). This is beneficial especially since running Machine Learning (ML) or data processing code often requires a high spec machine with multiple CPUs and RAM.</p><p>Another benefit is that running the code remotely makes it authenticate against other Google Cloud Platform services as the service account associated with the instance. Upon completing this tutorial, you will be able to run PyCharm from your Mac, with the code executed remotely on a GCP VM.</p><h3>Prerequisites</h3><p>In order to get started, you will need the following:</p><ol><li>PyCharm Pro installed on your Mac/Linux machine</li><li>An active GCP account</li></ol><h3>Let’s Do It</h3><h4>Step 1: Set up a ssh key on your Mac <a href="https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys#console_1">[1]</a></h4><p>Execute the following command to generate a new ssh key pair on your Mac/Linux terminal:</p><pre>ssh-keygen -t rsa -f ~/.ssh/[KEY_FILENAME]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R06nWVZ9WRUVWklgwJ-6yQ.png" /></figure><p>I chose not to set up a passphrase for the key and named it <strong><em>temp_key</em></strong></p><h4>Format the Public Key</h4><p>Print the content of the public key value of your ssh key pair that you created under by using the following command:</p><pre>cat ~/.ssh/temp_key.pub</pre><p>Copy the content of the key to the clipboard starting from the ssh-rsa (including) phrase until the “=” sign (before the username).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m_n27uZC8H8AivaVyczY-A.png" /></figure><p>Open any notepad and format the key starting in the following way:</p><pre>ssh-rsa [KEY VALUE]= [USER_NAME]</pre><p>Keep this text for later.</p><h4>Step 2: Create or Edit a VM on GCP</h4><p>Now you need a machine on the cloud. I like using AI Notebooks because these machines come preinstalled with an AI Python environment that includes many data science, ML and Google cloud libraries. To create a notebook follow <a href="https://cloud.google.com/notebooks/docs/create-new">this guide</a>.</p><p>Note that AI Notebooks (now part of Vertex AI) are creating an underlying Compute Engine instance. After creating either a bare Compute Engine Instance or an AI Notebook edit you will need to edit them to allow remote access via SSH. This will allow PyCharm to copy files to your machines and connect to the Python interpreter.</p><h4><strong>Editing the Machine of an AI Notebook</strong></h4><p>The notebook instance called “my-instance” has the following details:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fxpJa9FsJ-2B-ZxqwO4N7Q.png" /></figure><p>By clicking “VIEW VM DETAILS” and then “EDIT” you can change the spec of the compute engine that hosts the AI Notebook. Scroll down to SSH Keys and then open the dropdown list: “show and edit”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C_1c-vq_IzuW4nLi9ykRow.png" /></figure><p>Click “Add item” and paste the formatted ssh key adding a user name in the end. If you were successful, your username will appear to the left of the key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*P04B_cTdOjIepeTr7yF-9A.png" /></figure><p>You can also<a href="https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address"> set up a static external IP</a> for the machine, to make sure that it doesn’t change its public IP every time that you restart it.</p><h4>Step 3: Set up PyCharm!</h4><p>Now, your machine can accept SSH connections using the key-pair that you created. All that’s left to do is to allow PyCharm deploy and run the code on that remote machine. Copy the external IP of the machine. It can be viewed on the VM’s details once the VM is running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XELbs1IoRhCgvC3JNAaHJg.png" /></figure><p>Then open PyCharm &gt; Preferences &gt; Project:[name] &gt; Python interpreter &gt; Options wheel &gt; add</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LU5iZa1KXTAmoOlwg9wHGA.png" /></figure><p>Under Host, put the external IP address of the machine, and under the Username, write the name of the user that you used when created the key. Click “Next” to tell PyCharm to try to establish a connection to the VM. You will then need to provide the correct connection credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HvWJy_fdIHCgaOF_fdsC1g.png" /></figure><p>Direct the “private key file” to the location of the ssh private key (/[user]/.ssh/temp_key in our case, the one without the .pub extension)</p><p>Click next, and you’re good to go! You will see that the interpreter is now your remote Python environment at the bottom right of the screen. It may take it a few minutes for the first type to copy the PyCharm helper files to the remote machine and sync the Python environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DBX9MLWI3W44Hh2yTJNKcw.png" /></figure><h3>Advanced: Multiple Python Environments</h3><p>Sometimes, there is more than one Python environment installed on the remote machine. For example, you may have a conda environment installed on your AI Notebook. You can choose which one you want to work with by editing the configuration of your remote interpreter.</p><p>Access the interpreter settings from the bottom right menu of PyCharm:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*t4YwMlyYUmXJDp0t3jyfGg.png" /></figure><p>Again, edit your existing interpreter settings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a3qLC6QcmNNyaV5b_g7V9w.png" /></figure><p>Under “python interpreter path”, paste the location of your Python installation <strong><em>on the remote machine.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0UCMOrmtf2SKlWOcpWLp-g.png" /></figure><h3><strong>Summary</strong></h3><p>Besides the aforementioned tutorial, there are a couple of resources I wish to share with you. You can further learn about advanced set up of Python interpreter in PyCharm via this <a href="https://www.jetbrains.com/help/pycharm/configuring-remote-interpreters-via-ssh.html">guide</a> by JetBrains. Interested in advanced configuration of your SSH key on GCP instances? Access this <a href="https://stackoverflow.com/questions/27535945/how-to-get-the-ssh-keys-for-a-new-google-compute-engine-instance">resource</a>.</p><p>Stay productive!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a8bdab3433f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Seven Tips for Forecasting Cloud Costs (with Meta’s Prophet)]]></title>
            <link>https://gidutz.medium.com/seven-tips-for-predicting-the-future-with-facebooks-prophet-51cf8d6c89dc?source=rss-b45fa95a7293------2</link>
            <guid isPermaLink="false">https://medium.com/p/51cf8d6c89dc</guid>
            <category><![CDATA[time-series-forecasting]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[featured]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Gad Benram]]></dc:creator>
            <pubDate>Mon, 08 Feb 2021 14:58:39 GMT</pubDate>
            <atom:updated>2022-07-05T12:57:31.612Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*LMqJKa5se911Buw5MsXN7g.jpeg" /><figcaption>Who said that predicting the future is difficult? All you need is a Prophet (and some reliable infrastructure)</figcaption></figure><p>My team and I recently built a cloud-spend control system that helps users more-easily analyze their cloud costs. But we also wanted to go further and give users a glimpse into the future with one-click forecasts. To accomplish this, we based our solution on very capable forecasting tools, including Mata’s <a href="https://facebook.github.io/prophet/">Prophet</a>, and thought that it would be helpful to share our insights!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLKQanFts82tnjdK2d0Zsw.png" /><figcaption>Predicting daily cloud costs. Source: DoiT Internationals CMP (Screenshot)</figcaption></figure><h4>Tip #1: Know your Prophet</h4><p>Prophet is a great library for <em>certain</em> problems but it can easily underperform other tools in certain tasks. What is it good for? The Prophet is <em>very</em> good for <strong>generating forecasts for a series using the series data itself</strong>. It’s less good when you want to add more features or learn from similar series (for example: when you have multiple accounts that share a similar behavior).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nl-zcwDKrElsfB2k9g3wPg.png" /><figcaption>Summary table for Prophet. Source: Gad Benram</figcaption></figure><p>The way to work with Prophet is different than how you would usually work with services based on neural networks. Instead of maintaining a serialized trained model and invoking predictions in real-time, you actually train and predict the model per call. For this reason, it takes multiple CPU cores (around 8 cores should be fine) to handle a single request.</p><p>An additional feature of the library is its design to fit business-related trends (like daily and monthly seasonalities), out of the box Prophet may perform not so well on other types of time series (like radio signals). If you encounter a problem that Prophet is not optimized for you my want to consider <a href="http://neuralprophet.com/">NeuralProphet</a>, <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/deepar.html">DeepAR</a>, <a href="https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-create-time-series">ARIMA</a>, or other algorithms, libraries and cloud tools specialized in time series forecasting.</p><h4>Tip #2: Create Prophet Sub-Classes</h4><p>Out of the box, Prophet can generate incredibly accurate forecasts. But there is no free lunch, even in this case. Some trends have a stronger seasonality component than others while others tend to be smoother with fewer change-points, etc. While Prophet supports the same long list of frequencies as <a href="https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#timeseries-offset-aliases">pandas’ time offsets</a>, your app may not necessarily have to support all of them.</p><p>Perhaps, instead, you would only wish to support a small and finite set of frequencies such as <em>Daily</em>, <em>Weekly,</em> and <em>Monthly</em>. In this case, you may find it useful to create a subclass of Prophet-per-frequency and set it differently for each class:</p><ol><li><a href="https://facebook.github.io/prophet/docs/diagnostics.html#hyperparameter-tuning">A set of hyper-parameters</a></li><li><a href="https://facebook.github.io/prophet/docs/seasonality,_holiday_effects,_and_regressors.html#additional-regressors">Custom regressors</a></li><li><a href="https://facebook.github.io/prophet/docs/seasonality,_holiday_effects,_and_regressors.html#specifying-custom-seasonalities">Customs seasonalities</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*leSUXpZCFuDl2VvhB0qs_w.png" /><figcaption>Daily prophet inherits from Prophet, initialized with custom parameters, has a regression that fits the “first day of the month” and a month-over-month custom seasonality. Prof Trelawney would have been so proud…</figcaption></figure><p>In order to find the optimal parameters per class, you can build a dataset and <a href="https://facebook.github.io/prophet/docs/diagnostics.html#hyperparameter-tuning"><strong>run a hyperparameter tuning job</strong></a> on it. See if you can find a set of parameters that outperform others in objective metrics like mean-squared-error or mean-absolute-percentage-error.</p><p>In our case, the daily data contained recurring monthly billings (like your support bill) that show up on the first day of each month. Additionally, we noticed that the data tends to be a correlative month over month due to some underlying discount regimes that Google Cloud and AWS apply. We improved our predictions’ accuracy by creating a special Daily-Prophet object, adding a custom regressor for the beginning of the 1st of every month, and setting it up with a custom seasonality of 30.5 days. We also initialized the super() method of this object with custom hyperparameters that we optimized for daily predictions.</p><h4>Tip #3: Give the Prophet enough CPU and RAM</h4><p>Prophet’s service can be easily containerized and served on tools like Google Cloud’s <a href="https://cloud.google.com/run">Cloud Run</a>. However, this library, based on pystan, can be very resource-hungry. We found that the optimal solution in terms of ease-of-management and performance was to deploy the service onto Cloud Run over Anthos (GKE).</p><p>This way we were able to provide the service with strong, <strong>compute-optimized machines that reduced prediction time by 60% compared to native Cloud Run. </strong>Since the service utilized all the cores and the RAM we gave it, we also restricted each Cloud Run instance to handle only a handful number of requests in parallel, leveraging Cloud Run and GKE’s capability to scale up and down quickly!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ADUrGynTf27DVVIQu2s3Zg.png" /><figcaption>One fat node-pool with c2 machines, each with 8vCPUs serving as part of the dev environment</figcaption></figure><h4><strong>Tip #4: Don’t forget to plot, embed more business </strong>knowledge</h4><p>Sometimes viewing the trends that you get is more important than evaluating your results on a test-set. While you may optimize the mean-squared-error, sometimes this score will not reflect some business behavior that you failed to capture.</p><p>In our case, we learned that<strong> cloud spend doesn’t tend to grow linearly.</strong> Instead, it is better characterized as a <a href="https://facebook.github.io/prophet/docs/saturating_forecasts.html#forecasting-growth">logistic function</a> with an asymptote (capacity limit) that is derived from financial considerations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bpct7Yh9eEJfyEwV7WCBdg.png" /><figcaption>As much as we hope for our revenues to grow like this, it’s more probable that the growth is going to decay eventually and hit an asymptote. We use domain knowledge to specify this limit. Source: Gad Benram</figcaption></figure><h4><strong>Tip #5: Not sure? Express your uncertainty!</strong></h4><p>We learned that users tend to expect that the prediction will have a low margin error— often, <strong>closer than what can be realistically expected from a time-series forecasting tool</strong>.</p><p>In the above images you can clearly see that when using Prophet, the library emits an estimation of the original trend and not necessarily the real numbers. Users then get really confused when presented with a forecast that looks similar to the original trend.</p><p><strong>As a result, you may want to consider the following:</strong></p><ol><li>Express the forecast as a dotted grey line.</li><li>Add a confidence interval.</li><li>Consider replacing “yhat” (predictions) with “y” (historical observations) when possible.</li></ol><blockquote>You can control the width of the intervals by providing it as a parameter to the constructor</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SQgNJUe6JRrvD6H9C7KWsg.png" /><figcaption>Using design to distinguish between actual values and estimations while visualizing the uncertainty! Source: Gad Benram</figcaption></figure><h4>Tip #6: Use Pre-processing and Post-processing</h4><p>When sending data for predictions, we may forget that algorithms are not aware of the context in which the time series is generated.</p><p>In our case, we used to send aggregated, monthly cost data in order to generate monthly predictions. In the first weeks of each month, the last observation was significantly lower, making Prophet fit a sharp drop in the future trend. Removing data-points that we know to be corrupt can improve the results dramatically. Remember that Prophet can handle missing values well; so often it’s better to drop noise than fit it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T4m8auL29A3rQpN9JcdmAw.png" /><figcaption>Monthly data sent to the forecast service. Prophet “doesn’t know” that the drop is due to missing data. Source: Gad Benram</figcaption></figure><p>Other options of improvement by processing may include using Pandas’ <em>rolling </em>function to apply sliding-window filters on the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w0jYflAyVAzZyb33xdtnzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Eaei7hywg6AB0ZjWzpj6g.png" /><figcaption>The original data is too noisy, but we can apply a rolling mean window to it and see a more smoothed trend if it makes sense business-wise. Source: Gad Benram</figcaption></figure><h4>Tip #7: Speed up your inference by ignoring uncertainty</h4><p>Prophet fits a probabilistic model to the data and then iteratively samples the distribution in order to estimate the noise (and the prediction intervals that are associated with it).</p><p>After performing some run-profiling on my service, I discovered that this sampling process is responsible for a fairly large portion of the overall program run-time. <a href="https://github.com/facebook/prophet/blob/20f590b7263b540eb5e7a116e03360066c58de4d/python/fbprophet/forecaster.py#L1387">This iteration</a> runs many times until it can generate enough samples to estimate the noise. If you are not interested in the prediction intervals, you can reduce set the <strong>uncertainty_samples </strong>parameter to a lower number (even 0) and <strong>significantly reduce the runtime of the program!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o_lrRVKZcCZS6Rxyh9exlg.png" /><figcaption>This part of the code, used to estimate the noise of the fitted model, is very time-consuming, but if you don’t need the uncertainty estimation just skip it! Source: <a href="https://github.com/facebook/prophet/blob/20f590b7263b540eb5e7a116e03360066c58de4d/python/fbprophet/forecaster.py#L1387">github</a></figcaption></figure><blockquote>Of course, this tip goes against tip #5 that tells you how important it is to present the uncertainty. I guess that software development is always about tradeoffs, isn’t it? :)</blockquote><p>That&#39;s all folks! If you have any comments, please feel free to leave them below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51cf8d6c89dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Exposes Gender Income Inequality]]></title>
            <link>https://medium.com/swlh/ai-exposes-gender-income-inequality-2d46d9c0d372?source=rss-b45fa95a7293------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d46d9c0d372</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[jobs]]></category>
            <category><![CDATA[gender-equality]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[salary]]></category>
            <dc:creator><![CDATA[Gad Benram]]></dc:creator>
            <pubDate>Tue, 26 Jan 2021 14:28:03 GMT</pubDate>
            <atom:updated>2021-02-02T23:58:25.140Z</atom:updated>
            <content:encoded><![CDATA[<h4>An AI model that was built on income survey data exposed more than what’s used to be thought of gender income inequality. Not only that on average female employees earn less than their male counterparts but also gender is one of the key differentiators for determining one’s salary.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JWCJIvxEn3f20Xi4" /><figcaption>Photo by <a href="https://unsplash.com/@magnetme?utm_source=medium&amp;utm_medium=referral">Magnet.me</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Israel’s Machine &amp; Deep learning community has conducted an extensive survey regarding employment trends and salaries. <a href="https://www.linkedin.com/in/omri-goldstein-a46700b/">Omri Goldstein</a> and <a href="https://www.linkedin.com/in/urieliabayev/">Uri Eliabayev</a> revealed not only average salaries but also included in their work a visualization of two <a href="https://en.wikipedia.org/wiki/Decision_tree_learning#:~:text=Decision%20trees%20where%20the%20target,given%20their%20intelligibility%20and%20simplicity.">Decision Tree model</a>s that were built using the survey’s data (<a href="https://machinelearning.co.il/3721/mdli2019report/?fbclid=IwAR0BzHapvvzePadQLflPBZp_zhpG25_sBx9Nlbm3D1IAaImCZYrBO6Qpip8">see here</a> and <a href="https://towardsdatascience.com/mdli-report-the-israeli-machine-learning-review-2019-fdc408d31454">here</a>). The models clearly show <strong>how important gender is in determining the salary </strong>of a Data Scientist, a profession that was not once referenced as “the most sexy of our time”.</p><blockquote>It’s important to mention that the team that published the report didn’t intend to perform research on income inequality, hence the results should be considered with care</blockquote><p>The model presented in the report demonstrates that being “Female” indicates having lower salary. How low? For employees without a PhD, being a female was given an estimation of 32,000 ILS compared to 35,000–39,000 ILS for male. But average numbers don’t tell the whole story. In order to more profoundly understand the significance of these results it’s better to explain some more about Decision Trees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/0*tpHlqSZjyLgo2tJw.png" /><figcaption>One of the two trained models. Female appears in the top right part of the plot. Origin: <a href="https://machinelearning.co.il/3721/mdli2019report/?fbclid=IwAR0BzHapvvzePadQLflPBZp_zhpG25_sBx9Nlbm3D1IAaImCZYrBO6Qpip8">here</a></figcaption></figure><h4>How Decision Trees Work</h4><p>Like any AI model, Decision Trees are built using data, they don’t have any prior bias before being fed with data. The goal of the DTs models is to generate a tree that would determine the expected value (in this case the salary) by navigating between yes and no questions. In the example above the expected salary for a person who has more than 6 years of experience and has a PhD degree is 45,000 ILS (monthly).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*MWYdcDBt93A_mHiKfMZuUg.png" /><figcaption>Example of how a tree is built. Images by <a href="https://pixabay.com/users/pixaline-1569622/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=2762568">Pixaline</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=2762568">Pixabay</a>. Read more <a href="https://xgboost.readthedocs.io/en/latest/tutorials/model.html">here</a></figcaption></figure><p>How is it different from just calculating the average? Unfortunately, many publications show gaps between male and female average income. However, averaging sometimes blurs the details of the picture. Imagine a hypothetical case where both genders <strong><em>earn the same</em></strong> but females<strong><em> don’t get promoted to senior roles</em></strong>, in this case the average salary of males will be higher even though for the same roles both genders show no difference. Additionally, averaging salaries by gender doesn’t answer questions like: what is more statistically important when predicting one’s salary? Years of experience or education?</p><p>Answering this question is of course complicated. Some previous studies examine different angles of discrimination. In this case some light may be shed by AI “automatically”. When Decision Trees are built, the algorithms behind them try to split the population by the most informative features. If experience is “more important” than education than it should appear higher in the tree (closer to the first node). See the example above and the link for detailed explanation.</p><h4>Is gender really more important than education?</h4><p>So how highly important is gender for estimating income? Pretty up high, according to the data collected by the publishers. It means that upon trying to guess someone’s salary, the AI model thought that it would be more informative to ask for one’s gender rather than their skills or background.</p><p>If you wish to <strong><em>feel</em></strong> how outrageous the results are: just imagine a technical recruiter that doesn’t care if you have a CS degree or if you have 7 years of experience working for a corporate. One of the first questions they’d ask you is your gender.</p><p>A small comfort can be found in the fact that Gender doesn’t appear high in all of the trained models, and some sub-branches don’t include it at all. This implies that in some slices, there is not much of a difference between male and female. However, when it does appear, the tree always points to male as having higher expected salary.</p><h4>Discrimination has been here before AI</h4><p>A lot have been said and written about the fear from AI and the biases that it may generate when used irresponsibly. Nevertheless, this case demonstrates two points in my opinion:</p><ul><li><em>AI does not create biases, it merely reflects and amplifies what we as a society create.</em></li><li><em>AI can be used to learn more about the true nature of discrimination.</em></li></ul><p>In recent years several papers and projects that tackle the concept of responsible AI were published. Some companies suffered painful public criticism after it had been revealed that their AI models reflect biases against people of certain gender or ethnicity. In order to avoid falling into these traps the Data Science community works to find best practices to how it can be more careful when generating AI models. But the simple fact is: biases are strongly present in the data because they reflect who we are as humans. Unfortunately.</p><p>Feel free to contact <a href="https://www.linkedin.com/in/gad-benram-2a46928b/">Gad Benram</a> about this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d46d9c0d372" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/ai-exposes-gender-income-inequality-2d46d9c0d372">AI Exposes Gender Income Inequality</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Programming an Autonomous Car that Runs Into Objects with TensorFlow]]></title>
            <link>https://gidutz.medium.com/turning-aws-deepracer-into-an-angry-bull-powered-by-tensorflow-9dbdd6b3e9cb?source=rss-b45fa95a7293------2</link>
            <guid isPermaLink="false">https://medium.com/p/9dbdd6b3e9cb</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[autonomous-vehicles]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <dc:creator><![CDATA[Gad Benram]]></dc:creator>
            <pubDate>Mon, 25 Nov 2019 17:01:17 GMT</pubDate>
            <atom:updated>2022-04-13T14:44:53.328Z</atom:updated>
            <content:encoded><![CDATA[<h3>Programming an Autonomous Car with TensorFlow</h3><h4>AWS released an awesome tool to teach Reinforcement Learning to beginners, but only exposed a limited interface for controlling it. We’ve hacked it and turned it into a Deep Q-Learning Raging Bull, compatible with OpenAI Gym and powered by TensorFlow.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j3ozce4k-_gha8oBMAmDGA.png" /></figure><p><strong>Together with: </strong><a href="https://medium.com/u/266563bae3db"><strong>Nir Malbin</strong></a><strong> and </strong><a href="https://medium.com/u/8efc49cf3fa4"><strong>Aviv Laufer</strong></a></p><p>When AWS released its AWS <a href="https://aws.amazon.com/deepracer/">DeepRacer</a>, it was intended to teach the basics of reinforcement learning through an interactive and physical autonomous car. The car could only be controlled by specific types of models, trained using the AWS console and uploaded through the car’s interface. Little did they know that we were about to turn it into a raging bull that will learn to stampede towards objects!</p><p>The transformation required three steps: First, we had to discover the API running the car. Second, we had to develop a deep reinforcement learning environment and agent to integrate it with the controls of the car. Finally, we had to let the car learn how to steer and drive into objects.</p><p><a href="https://github.com/gidutz/DeepBullFighting">gidutz/DeepBullFighting</a></p><h3>Discovering the Car’s API</h3><p>We wanted to discover the API used by the car. By logging the HTTP requests from the browser to the car, we found out that the API calls are in car_ip/api/. Having that knowledge, we connected to the car via SSH and by using the ‘ps’ command, we found that there is a Python web server up and running. We CD’d into the directory and grep the string “/API/” in all the PY files. Now we have the list of the APIs that the car supports.</p><h3>Deep Object Detection</h3><p>Object detection is a task in which we let a machine identify objects within an image. We used a TensorFlow/Keras implementation of the <a href="https://pjreddie.com/darknet/yolo/">YOLOv3 model</a> that can detect objects to extract the center and proportions of bottles with respect to the overall frame. The goal of the Deep-Q-Agent is to perform actions so that the center of the detected object would move towards the center of the frame.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1bBzCqetaLXSDJJCOGByaw.png" /><figcaption>Frames from the car’s camera. Using YOLOv3, we find the bounding box of a bottle and calculate the center of the box from the frame’s center. The size of the frame is also calculated.</figcaption></figure><h3>The Deep-Q-Agent</h3><p>Knowing where the bottle is with respect to the car is one thing, but how will the car know how to move towards it? If you are unfamiliar with the concept of Deep Reinforcement Learning, you would probably try to write a piece of code that does some sort of geometric calculations in order to find the estimated angle in which the car needs to move in order to bring itself closer, and in front of the bottle. Be that as it may, reinforcement learning enables you to let the machine learn how to control itself in order to accomplish this goal, through a process of trial and error. In this implementation, we used a method called<a href="https://deepmind.com/research/publications/human-level-control-through-deep-reinforcement-learning"> Deep Q-Learning</a> that helped Google’s DeepMind teach computers to win at games, as tested on the classic Atari 2600.</p><h4>Deep Q-Learning</h4><p>Deep Q-Learning is an approach to solve reinforcement learning without modeling the environment; e.g., not trying to model the physics of moving the car nor the interaction between the car and the bottle. Instead, letting the machine experiment and learn which actions will earn the best reward for a given state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kkhZ_1B0pD4dv6-Q7BIKtQ.png" /></figure><h4>Reward?</h4><p>In Reinforcement Learning, the reward is a score given as a consequence of the actor performing an action, assuming that it’s possible to evaluate how “good” an action was. The actor will try to optimize it’s actions so that the rewards it receives will be maximized. In our case, we thought that bringing the center of the detected object to the center of the frame would mean that the car would be standing in front of the object while enlarging the coverage of the detected object, meaning that the car is closer to the object. Hence we combined the two-to-one formula that outputs <em>1</em> when the car is in front of the object and it covers the entire screen, and less when it gets further:</p><pre># sizes are scaled so that the frame side = 1<br>step_reward = (1-distance_to_center)*(object_coverage)</pre><h4>Applying Deep-Q-Learning to DeepRacer</h4><p>The DeepRacer movement is controlled by two parameters; angle and throttle. Both are floating-point numbers in the range of -1.0 and +1.0. An “action” would be to set angle and throttle values and let the car run for 0.3 seconds. In order to simplify the task, we discretized the continuous action space to 12 different tuples (angle, throttle), so that the task of the agent would be reduced to selecting one of 12 possible combinations given the observation.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FL2MsII6-kd8%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DL2MsII6-kd8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FL2MsII6-kd8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c6fb9e6906db386f52e64ea6da579e4/href">https://medium.com/media/0c6fb9e6906db386f52e64ea6da579e4/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/339328bb560ad201225695e90b7478ab/href">https://medium.com/media/339328bb560ad201225695e90b7478ab/href</a></iframe><p>_____________________________________________________________</p><p>Liked the story? Follow <a href="https://twitter.com/gadbenram">Gad on Twitter</a> to get the latest updates and content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9dbdd6b3e9cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Codeless ML with TensorFlow and AI Platform]]></title>
            <link>https://gidutz.medium.com/codeless-ml-with-tensorflow-4683fea8e4a0?source=rss-b45fa95a7293------2</link>
            <guid isPermaLink="false">https://medium.com/p/4683fea8e4a0</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[featured]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Gad Benram]]></dc:creator>
            <pubDate>Tue, 02 Jul 2019 15:20:47 GMT</pubDate>
            <atom:updated>2019-11-28T19:05:47.555Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Advances in AI frameworks enable developers to create and deploy deep learning models with as little effort as clicking a few buttons on the screen. Using a UI or an API based on Tensorflow Estimators, models can be built and served without writing a single line of machine learning code.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RyyK3bja967kHYim" /><figcaption>Photo by <a href="https://unsplash.com/@adigold1?utm_source=medium&amp;utm_medium=referral">Adi Goldstein</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>70 years ago, only a handful of experts knew how to create computer programs, because the process of programming required very high theoretical and technical specialization. Over the years, humans have created increasingly higher levels of abstraction and encapsulation of programming, allowing less-skilled personnel to create software with very basic tools (see<a href="https://www.wix.com/"> Wix</a> for example). The exact same process occurs these days with machine learning — only it advances extremely faster. In this blog post we will write down a simple script that will generate a full machine learning pipeline.</p><h3>Truly codeless?</h3><p>This post contains two types of code. The first is a SQL query to generate the dataset — this is the part of the code could be replaced by tools like <a href="https://cloud.google.com/dataprep/">Google Cloud Dataprep</a>. The other type involves API calls using a Python client library — all of these actions are available through the AI platform UI. When I say codeless, I mean that at no point will you need to import TensorFlow or other ML libraries.</p><p>In this demo, I will use the<a href="https://console.cloud.google.com/marketplace/details/city-of-chicago-public-data/chicago-taxi-trips"> Chicago Taxi Trips</a> open dataset in Google BigQuery to predict the travel time of a taxi based on pickup location, desired drop-off, and the time of ride start. The model will be trained and deployed using Google Cloud services that wrap Tensorflow.</p><p>The entire code sample can be found in<a href="https://github.com/doitintl/ml-specialization-examples/tree/master/chicago_travel_time"> this GitHub repository.</a></p><h3>Extract Features using BigQuery</h3><p>Based on an EDA shown<a href="https://github.com/doitintl/ml-specialization-examples/blob/master/chicago_travel_time/EDA.ipynb"> in this notebook</a>, I created a SQL query to generate a training dataset:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50b8eb30e12c6ed8b811fc8876fe5c2d/href">https://medium.com/media/50b8eb30e12c6ed8b811fc8876fe5c2d/href</a></iframe><p>In the repo, you will be able to see how I execute the query using a python client and export it to GCS.</p><p><strong>Important! </strong>In order for the AI platform to build a model with this data, the first column must be the target variable and the CSV export should not contain a header.</p><h3><strong>Submit hyper-parameter tuning job and deploy</strong></h3><p>After I have my dataset containing a few hundred thousand rides, I define a simple neural network architecture based on the TensorFlow Estimator API, with parameters space to search. This specific spec will create a 3 hidden-layers neural network that solves a regression task (the expected trip time). It will launch 50 trials to search optimal settings for the learning rate, regularization factors, and maximum steps.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6eee130ca6a37147057584a59312f767/href">https://medium.com/media/6eee130ca6a37147057584a59312f767/href</a></iframe><p>Provided the spec above I can use a Python client to launch a training job:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c90de58ad8f65449e2d3ac67fc47268/href">https://medium.com/media/9c90de58ad8f65449e2d3ac67fc47268/href</a></iframe><p>I use the API client to monitor the job run, and, when the job is done, I deploy and test the model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c391a1706845ee748ebf24488147daa1/href">https://medium.com/media/c391a1706845ee748ebf24488147daa1/href</a></iframe><p>With this, I completed the deployment of a machine learning pipeline using only API calls.</p><h3>Get predictions</h3><p>In order to get predictions, I load part of the test set records to the memory and send it to the deployed version for inference:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/abd7d5fed10fa6319ee718dbd04ee5b4/href">https://medium.com/media/abd7d5fed10fa6319ee718dbd04ee5b4/href</a></iframe><p>Want more stories? Check our blog on <a href="http://blog.doit-intl.com/">Medium</a>, or <a href="https://twitter.com/gadbenram">follow Gad on Twitter</a>.</p><p><em>Thanks to Adam Horowitz for technical advisory</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4683fea8e4a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kaggle Days Paris — Winning Solution]]></title>
            <link>https://gidutz.medium.com/say-yes-to-overfitting-3ee4a23d33d4?source=rss-b45fa95a7293------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ee4a23d33d4</guid>
            <category><![CDATA[kaggle-competition]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[featured]]></category>
            <dc:creator><![CDATA[Gad Benram]]></dc:creator>
            <pubDate>Thu, 14 Feb 2019 11:45:54 GMT</pubDate>
            <atom:updated>2019-04-26T21:37:50.590Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kaggle Days Paris — Winning Solution</h3><h4>Kaggle Days is (almost) officially the most interesting event to meet, learn and compete against the most talented data scientists worldwide. And this is how we won it.</h4><p>The city of Paris hosted this January (2019) the 2nd ever Kaggle Days event. More than 200 data scientists from all around the world gathered to learn, share knowledge and eventually compete against each other in a 11 hours in-class<a href="https://www.kaggle.com/c/kaggledays-paris"> Kaggle competition</a> that took place during the conference. This blog post describes <a href="https://github.com/gidutz/kaggle_days_solution/blob/master/solution_pipepline.ipynb">our solution</a> to the competition, that won us the 3rd place.</p><h4>Predicting Sales of LMVH’s Luxurious Products</h4><p>Challengers were provided with data from the first seven days of Louis Vuitton products after their launch on <a href="http://www.louisvuitton.com/">www.louisvuitton.com</a>. The goal was to forecast sales on each of the three months following the launch. Additional data included product descriptions, sales statistics, social media, website navigation, and image data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*JipQVUDJQxBgJjy6wzdBQQ.gif" /><figcaption>Screen capture from louisvuitton.com</figcaption></figure><h4>Strategy</h4><p>Like in many of our past Kaggle competitions we followed simple tactics:</p><ol><li><strong>Dumb features complex models </strong>— build simple features and let the ML models “understand” the complex interactions between them.</li><li><strong>Embrace diversity </strong>— train many models and ensemble best leaderboard performing models with the least<strong> </strong>overlap in their errors.</li><li><strong>Teamwork</strong> — each team member has a well defined responsibility: the <a href="https://www.kaggle.com/nuritci">Feature-Extractor</a>, the <a href="https://www.kaggle.com/gidutz">Modeler</a> and the <a href="https://www.kaggle.com/sefficohen">Integrator</a>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fw0AUTgwMmKk7je1sqaomA.png" /><figcaption>Team members: Gad Benram, Seffi Cohen and Nurit C Inger</figcaption></figure><h4>Baseline</h4><p>Before even looking at the data we stood on the shoulders of giants and used Kaggle Days’ team baseline script that included numerous features. We ran a simple <a href="https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestRegressor.html">Random Forest</a> model of <em>no more that 100 trees </em>on the entire train data, just to see the importance of each feature. The results came as an absolute surprise as the log of the first 7 days’ sales received X20 larger importance score compared to all other features. This piece of information allowed us to control the variance of the generated models to some extent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*lKJMofA1wsNlVanA0U_xAw.png" /></figure><h4>Formulating the business question</h4><p>Diving into the data, we discovered that someone had made a good job splitting the it. The training data consisted of ~1700 unique products while the test included almost the same amount different products. It made us think of the problem as follows: assuming a specific product, let’s say a women bracelet, was sold x times on the first week after it’s launch and some m1, m2, m3 on the consecutive months, How much will be sold given a similar item?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FaPuoqs-v_C-lqh4YoQvqA.png" /></figure><p>Ignoring trends — since the data was relative to the first week of launch and didn’t include the Gregorian month we neglected seasonal trends paid less attention to social media trends. Basically it came down to the question of product similarity. It’s worth mentioning that <a href="https://medium.com/u/cf63cf37a07a">Mikel Bober-Irizar</a> managed to estimate the relative reduction in sales during the test period, thus improving the score via technique we call MLE — Maximum Leaderboard Estimation.</p><h4>How to model product similarity</h4><ol><li><strong>Categories </strong>— the products were categorized by human experts to different types such as leather goods and daily bags. These features were extremely valuable in understanding the similarity between different products’ sales. Not only that these features reflect how a human would perceive these items in a passive way but also actively affect the sales because they determine the position of the item on the website and the way it is presented to customers.</li><li><strong>Text</strong> — charechtirazing the feature using its text by applying TF-IDF and PCA over the features.</li><li><strong>Image vectors </strong>— the image features were extracted by using Google’s Vision API. This API utilizes neural networks trained on very generic datasets like ImageNet — not at all useful for distinguishing between two luxurious casual hand bags. Hence, we ignored these features.</li><li><strong>Click-through rate</strong>— Data from the websites traffic included page views and item clicks. from this we extracted the average clickthrough rate and used it as a feature.</li></ol><h4>Models</h4><p>Since the data included valuable categorical features, it was important to use a library that can leverage categorical features in an efficient way. XGBoost doesn’t have a built-in categorical features mechanism vs LighGBM and Catboost. Catboost took too long to process so we ended up running LighGBM with GBDT and Random Forest as boosting methods. Neural networks failed to converge due to the relatively small amount of data.</p><h4>So, why do we say it’s overfitting?</h4><p>Assuming we were consulting LMVH on how to increase sales, we would have applied a somewhat different approach. For example, LMHV could perform A/B testing on the most important features like the categorization or textual descriptions of the products to examine whether augmenting them would affect sales. Nevertheless, when striving to win a Kaggle competition our only goal is to best fit our predictions to the test set.</p><h4>Machines and environments</h4><p>All code ran on a preemptable <a href="https://cloud.google.com/deep-learning-vm/">Google Cloud Deep Learning VM</a> with a n1-highmem-8 (8 vCPUs, 52GB RAM, 0.1$ USD / Hr) instance. The machine was located in us-central area, thus it had high availability during competition hours, since we were in Europe.</p><h4><strong>Experience</strong></h4><p>While Kaggle is an amazing platform to share knowledge and challenge yourself in very diverse and difficult competitions, Kaggle days adds an important layer to this community: <strong>in-person interaction</strong>. We had a fantastic time meeting fellow data scientist from all around the world and learn that we all share a common dream: <strong>Overfit the test data</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*33RqSyH4AJm5dAQqimZ_eQ.jpeg" /><figcaption>The team working during the competition</figcaption></figure><p>Notebook code <a href="https://github.com/gidutz/kaggle_days_solution">here</a> on Github | Kaggle profile: <a href="https://www.kaggle.com/gidutz/">Gad Benram</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ee4a23d33d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicting the Geospatial Availability of Mobility Services like Bird and Lime]]></title>
            <link>https://gidutz.medium.com/using-bigquery-ml-to-predict-car-share-availability-f929310ec662?source=rss-b45fa95a7293------2</link>
            <guid isPermaLink="false">https://medium.com/p/f929310ec662</guid>
            <category><![CDATA[geospatial]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[featured]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Gad Benram]]></dc:creator>
            <pubDate>Tue, 18 Dec 2018 21:43:50 GMT</pubDate>
            <atom:updated>2021-02-03T02:32:14.880Z</atom:updated>
            <content:encoded><![CDATA[<p>Building and deploying production-grade machine learning models can be somewhat tricky. Even with technologies like Google Cloud AutoML, Cloud ML Engine and other out-of-the-box machine learning tools, training models and using them in production systems commonly requires a vast set of skills that can include some advanced Python programming, understanding complex models, SQL and DB technologies. This blog post demonstrates how to build a prediction system for shared cars/bikes/scooters using very simple tools!</p><blockquote><a href="https://cloud.google.com/bigquery/docs/gis-intro">BigQuery GIS</a> adds new capabilities to Google BigQuery that enable the ingestion, management and analysis of geospatial data. <a href="https://cloud.google.com/bigquery/docs/bigqueryml-intro">BigQuery ML </a>facilitates the creation and execution of machine learning models from within BigQuery, using standard SQL language. In this post we will try to show how one can leverage only SQL language to deploy a complete end-to-end ML pipeline for a geospatial time-dependent use-case.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*aUXoaSXH6Zq6IKCh" /><figcaption>Using Geo Viz to visualize predictions on a map</figcaption></figure><p>In order to reduce the number of owned cars, the city of Tel Aviv launched a shared-car project, called AutoTel. Users of the service are able to reserve a car using a mobile app, and pay for it by the minute. The project that was launched in October 2017 attracted over 7500 users, with more than 50% of them <a href="https://www.autotel.co.il/%D7%A9%D7%A0%D7%94-%D7%9C%D7%90%D7%95%D7%98%D7%95%D7%AA%D7%9C-%D7%94%D7%A0%D7%94-%D7%9B%D7%9E%D7%94-%D7%A0%D7%AA%D7%95%D7%A0%D7%99%D7%9D-%D7%A9%D7%97%D7%99%D7%99%D7%91%D7%99%D7%9D-%D7%9C%D7%94%D7%9B/">using</a> the service at least once a week.</p><p>Recent data shows constant growth in the usage of the AutoTel shared-car service. In fact the usage climbed so high that new problems emerged. Like many transportation services, one key factor in the public’s adoption rate is its reliability. Passengers will refrain from adopting an unreliable transportation service, since the cost of not getting to the required destination at the desired time is usually very expensive.</p><p>In order for the service to be reliable, AutoTel has to make sure that supply and demand are geospatially balanced, meaning cars are where and when they are needed. This task is extremely difficult since cars are driven and parked by customers who are not aligned at all with this optimization task. For the most part, the distribution of cars is uncorrelated with the demand: one reason is that if a car is parked in a suburban neighborhood, it may take a long time before another user may drive it to the city center, where high demand for the cars exists; thus clusters of unused cars are very often present on the outskirts of the city.</p><p>Using machine learning, AutoTel can predict the geospatial availability of cars at given times, and use predictions to modify their business model. They could, for example, modify prices so that it would be cheaper to park cars in high demand areas, or plan the the maintenance program so that cars will be collected from high-supply-low-demand areas and returned to areas of high demand. While this model could benefit AutoTel, developing it may be expensive and complicated, so in this post we will build and deploy a model that predicts the number of available cars, and do it all using only Google BigQuery. The complete code for this demo is available<a href="https://github.com/doitintl/BigQueryML-Examples/tree/master/AutoTel"> in this GitHub repo</a>.</p><h3>Part 1 : Data Acquisition</h3><p>From the AutoTel <a href="https://en.autotel.co.il/en/">website</a> I extracted the location of the parked cars, every two minutes for several months. The raw data was saved to Google Storage in CSV format, and later loaded to a BigQuery Table. This short clip shows a visualization of the recorded data using Uber’s kepler.gl tool</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fys6PfEugYrw%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dys6PfEugYrw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fys6PfEugYrw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ecee7b1f03c2359ac4d40adb4167ef2/href">https://medium.com/media/5ecee7b1f03c2359ac4d40adb4167ef2/href</a></iframe><p>Additionally I downloaded data from the Tel Aviv Municipal open data <a href="https://opendata.tel-aviv.gov.il/#/">website</a>, and loaded tables to BQ containing information on population age, commercial areas, hotel and kindergarten locations, and neighbourhood boundaries. These features are assumed to have a linear relationship with the total number of available cars, and while we may be proven wrong after analyzing the data, we start with this assumption.</p><h3>Part 2 : Geographical Joins and Grouping</h3><p>Each row in the raw dataset represents a location of a parked car at a given time. In order to aggregate the data to neighborhood level I needed to use a spatial join statement.</p><p>The following code shows how to perform spatial joins:</p><pre>SELECT car_locs.*, ta_dis.neighbourhood_name FROM car_locs <br>  JOIN ta_dis<br>  ON <strong>ST_WITHIN(ST_GEOGPOINT(car_locs.longitude, car_locs.latitude),<br>          ST_GeogFromText(ta_dis.area_polygon))</strong></pre><h3>Part 3 : Model Training</h3><p>As of December 2018 BQML supports two types of models — linear regression for regression and logistic regression for classification tasks. We train the models with the following SQL command:</p><pre><strong>CREATE OR REPLACE MODE</strong>L <br>  `autotel_demo.free_cars_model` <em>--model save path</em><br><strong>OPTIONS</strong><br>  (model_type=&#39;linear_reg&#39;, ls_init_learn_rate=.015, l1_reg=0.1,<br>   l2_reg=0.1, data_split_method=&#39;seq&#39;, data_split_col=&#39;split_col&#39;,<br>   min_rel_progress=0.001, max_iterations=30),<br><strong>SELECT</strong> <br>    free_cars label, <em>-- declaring target variable</em><br>    timestamp split_col<br>    <em>-- independent variables:</em><br>    ,age5to14<br>     ...<br><strong>FROM</strong><br>  `autotel_demo.autotel_dataset` as dataset  <br>  <strong>WHERE</strong> dataset.timestamp &lt; <strong>TIMESTAMP</strong> &#39;2018-10-11&#39;</pre><h3>Part 4 : Model Evaluation</h3><p>After training we can use “Model.Evaluate” function to provide metrics on the model performance. While these metrics are useful in many cases, this time we are facing a geospatial prediction task, and we would like to view the model predictions on a map.</p><p>Fortunately enough this is feasible using the <a href="https://cloud.google.com/bigquery/docs/gis-visualize#product_name_short_geo_viz">BigQuery Geo Viz</a> tool. Using this tool we can display the neighborhood boundary polygons on a map, and examine the prediction vs the real number of available cars at a specific time. This method lets us examine how the error is distributed geographically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ra4DjpFmKdrd15VhtSNH3A.png" /><figcaption>Visualizing the predictions using Geo Viz</figcaption></figure><h3>Part 5 — Deploying to Production</h3><p>Let’s examine the overall architecture that was created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*WDK2QWoQk58PAy7FyoLGGQ.png" /><figcaption>Pipeline architecture</figcaption></figure><p>A scraping bot accesses the AutoTel website and uploads a CSV file with the car locations to a partitioned bucket in <a href="https://cloud.google.com/storage/">GCS</a>.</p><p>A BigQuery table is built over the raw data, and a process of dataset creation and model training is initiated manually. After the model is created, it is hosted in BigQuery and used to serve predictions, or generate a predictions table. The predictions table can then be used to create visualizations and serve other components of the production system.</p><p>The key aspect that is missing here regards the automation of the process. Loading new data to the locations table, creating new datasets, training models and generating predictions were all described as manual steps. One way to automate this process is to leverage the concept that BigQuery is actually a service that can be invoked through client calls.</p><p>We can write a very simple python code to execute all these steps and then use Google <a href="https://cloud.google.com/composer/">Cloud Composer</a> to manage them. Cloud Composer is a very good fit for this kind of task since some steps are dependent on each other; however it runs a cluster to manage the tasks, which could be quite expensive for solely handling this task.</p><p>You can think of other ways to schedule the training and prediction script, like Cron or <a href="https://cloud.google.com/solutions/jenkins-on-kubernetes-engine">Jenkins</a>, but here’s the thing: for a few dollars a day Google Cloud Composer saves you the need to go through difficult configuration and permissions settings, and the more processes that are managed with it, the more cost effective it becomes.</p><h3>Summary</h3><p>As part of the effort to simplify the integration of machine learning models to production systems, BigQuery ML serves a managed tool that can serve as an end-to-end mechanism for the core part of the pipeline. If a simple linear/logistic regression model is sufficient, you will find that BQML can support:</p><ol><li>Data hosting</li><li>Dataset creation</li><li>Model training + hosting</li><li>Inference and serving</li></ol><p>With other tools like Airflow or Jenkins, these software blocks can be managed and automated.</p><p>It is important to mention that in this process we didn’t have to worry about resource allocation or data access, since we kept most of the process inside a managed data warehouse system that does it for us.</p><p>____________________________________</p><p>Technical advising and editing: <a href="https://www.linkedin.com/in/geofocus/">Tony Braun</a></p><p>Want more stories? Check our blog on <a href="http://blog.doit-intl.com/">Medium</a>, or <a href="https://twitter.com/gadbenram">follow Gad on Twitter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f929310ec662" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>