Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: pub@towardsai.net
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Take our 85+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

Publication

What Do You Prefer? Python or R? Why Not Both?
Latest

What Do You Prefer? Python or R? Why Not Both?

Last Updated on March 17, 2021 by Editorial Team

Author(s): Kunal Ajay Kulkarni

Programming

Data is everywhere. The amount of data we’re generating every day is enormous. According to a report by Forbes, we’re generating 2.5 quintillion bytes of data each day. The main reason behind this is that more than 3.7 billion humans are using the internet every day. Therefore, Data Science & Machine Learning are considered two of the most advanced and in-demand technologies of this century.

This ever-rising demand for data scientists and machine learning engineers has forced everyone to learn the programming languages required for these technologies. Be it about recommending movies on Netflix, spam filtering, critical business decisions, or forecasting weather. All of these situations involve a multidisciplinary field of Computer Science, Statistics, Algorithms, and Systems to extract meaningful insights from the data. So we need programming languages that can easily cater to all these needs of data science and machine learning.

Although there are many programming languages for fulfilling the given purpose, Python and R have been consistently used as favorite tools for data science and machine learning operations. This blog post covers how these two languages can be used to make a successful career in data science and machine learning. Also, we will look at some of the most widely used libraries to carry out data science and machine learning tasks. These are the languages you would want to learn for a successful career in data science and machine learning.

Photo by David Pupaza on Unsplash

Here is the list of topics that we will cover in this article —

  1. Introduction to Data Science and Machine Learning
  2. Why Python and R are essential for learning Data Science and Machine Learning?
  3. Python libraries for Data Science and Machine Learning
  4. R libraries for Data Science and Machine Learning
Photo by Christina @ wocintechchat.com on Unsplash

Introduction to Data Science and Machine Learning

When I first started my research about data science and machine learning, the first question came to my mind was why there is so much hype around machine learning and data science?

After researching and going through a lot of articles on the internet, I realized that this has a lot to do with the amount of data that is being generated by netizens every day. Data is the fuel required to drive machine learning models, and since we are living in this era of Big Data, it is a no-brainer as to why Data Science is the hottest job of the 21st century!

I would say that Data Science and Machine Learning are two of the most important skills and not just technologies. These skills are needed to extract meaningful insights from a large amount of data to gain a competitive advantage.

Data Science is the field that involves extracting meaningful information from a large amount of data to solve real-world challenges. Machine Learning is the branch of computer science that gives machines the ability to learn without being explicitly programmed.

Why Python and R are essential for learning Data Science and Machine Learning?

Python

As a beginner, you know that your journey to learn data science and ML begins with programming languages you need to learn. Among all languages available, Python is the number one choice for Data Scientists. Python is the most popular programming language used by most programmers throughout the world. So what makes Python so popular? Let us first understand why Python is the first choice for most of the Data Scientists and Machine Learning Engineers out there.

Python is a general-purpose programming language, which means it can be used in the development of the web as well as desktop applications. It’s also useful in the development of various numeric and scientific applications. With this sort of versatility, it comes as no surprise that Python is one of the fastest-growing and widely used programming languages in the world.

Also, Python is easy to learn and it uses simple syntax. It is one of the easiest languages to start your journey as a data scientist or MLE. There are multiple factors that give Python this flexibility over other languages, such as –

  1. Python is open-source and it is free to use across all operating systems
  2. It requires less code
  3. Python is the most productive language
  4. There is no limit to the things you can do with Python
  5. It has a vast community
  6. Python can easily run on multiple independent operating systems such as Windows, Linux, Unix, and macOS.

Python has hundreds of in-built libraries and frameworks to successfully develop, test, train, and implement various complex machine learning and deep learning algorithms. So, if you want to train a dataset, you can just install them with a single command, which saves a lot of time. These libraries are mainly focused on machine learning, big data, and data science. Some of the examples are Pandas, NumPy, Matplotlib, Seaborn, SciPy, Keras, TensorFlow, PyTorch, and so on.

Another reason for choosing Python is that it has a huge and active community. It has multiple groups, forums such as StackOverflow, Slack, and Kaggle if you have any problems. You can always ask for help on these platforms if you are stuck anywhere in your journey.

Now you know that why Python is the most popular language for data science and machine learning, let us look at the R programming language.

Photo by Hitesh Choudhary on Unsplash

R –

We all know that the exponential increase in data has led to the exponential rise in demand for skilled data scientists worldwide. So, those who are interested in learning data science and ML may be interested in learning the R programming language. R is one of the most important tools for Data Science and ML. It is a highly popular programming language and is the first choice of many statisticians and data scientists. But what makes R so popular and demanding? Why and How to use R for Data Science?

Let's look at some of the salient features of the R programming language –

  1. R programming language was developed by Ross Ihaka and Robert Gentleman in 1995 at the University of Auckland in New Zealand, where the name “R” was derived from the first letters of their names.
  2. R is free and open-source software. Its open interface allows users to integrate with other applications and systems.
  3. As a programming language, R is object-oriented, it has various operators and functions that allow users to explore, and visualize data.
  4. R is used to collect, store, clean, analyze, and visualize data. It can also be used for data analysis and statistical computing.
  5. R has various graphical and statistical capabilities. It can be used for classification, clustering, and linear and non-linear modeling.
  6. R has a collection of over 10,000 packages in its CRAN repository.
  7. Like Python, R also has a large community. It has multiple groups, forums such as Stack Overflow, Slack, and Kaggle if you have any problems. You can always ask for help on these platforms if you are stuck anywhere in your journey.

R mainly focuses on its statistical and graphical uses. When you learn R for data science, you’ll learn how to use the language to perform statistical analyses and develop stunning data visualizations. R’s statistical functions also make it easy for users to clean, import, and analyze data.

R is equipped with an Integrated Development Environment (IDE). According to GitHub, having an IDE makes it easier to write and work with software packages. RStudio is a simple and unique IDE for R that improves the accessibility of graphics and includes a syntax-highlighting editor that helps with code execution. This may come in handy as you begin to learn R for data science.

Image Source

So, what are the major differences between Python and R?

As we know, both Python and R have large software ecosystems and vibrant communities, so either language is suitable for almost any data science and machine learning task. But, there are times, when one language is more suitable or stronger than the other.

Where Python excels R –

Python is often praised for being a general-purpose language with its easy-to-understand syntax. Most of the machine learning and deep learning algorithms are being developed in Python with tools such as TensorFlow, Keras, and PyTorch. There are multiple resources available on the internet to learn how to do this. Python has an edge over R in deploying ML models and algorithms to other pieces of software. It is a primary language for machine learning workflows.

Where R excels Python –

R is one of the programming languages that provide an IDE to collect, store, manipulate, analyze, and visualize data. It is the primary choice for many statisticians who wants to design complex statistical models for solving complex problems. A lot of statistical computing is done in R, so there is a wide variety of models to choose from. If you wonder about how to model your data in the best way, R is the better option.

The other advantage R has over Python is that its ability to create web applications using R Shiny. This helps people to develop web applications without having much technical experience. Python does have Dash as an alternative, but that’s still a work in progress.

The list above is never-ending and people debate endlessly on which tasks can be performed better in which language over another. Further, Python programmers and R programmers always tend to borrow some good ideas from each other. For example, Python’s plotnine data visualization package was inspired by R’s ggplot2 package, and R’s rvest web scraping package was inspired by Python’s BeautifulSoup package.

Also, there is an excellent language inter-operability between both Python and R. which means, you can run your Python code from R using reticulate and your R code from Python using the rpy2 package. This means that all the features present in one language can be accessed from the other. i.e. the R’s version of the deep learning package Keras actually uses Python. Likewise, rTorch uses PyTorch.

Photo by Tim Mossholder on Unsplash

Some of the famous Python libraries used for Data Science and Machine Learning –

  1. Pandas (See Documentation)
  2. NumPy (See Documentation)
  3. SciPy (See Documentation)
  4. Matplotlib (See Documentation)
  5. Seaborn (See Documentation)
  6. Scikit learn (See Documentation)
  7. Statsmodels (See Documentation)

Famous R libraries used for Data Science and Machine Learning –

  1. Dplyr (See Documentation)
  2. Ggplot2 (See Documentation)
  3. Tidyverse (See Documentation)
  4. Lubridate (See Documentation)
  5. Shiny (See Documentation)
  6. Knitr (See Documentation)
  7. Rvest (See Documentation)
  8. Data tables (See Documentation)
  9. Caret (See Documentation)
  10. R Markdown (See Documentation)
  11. RMySQL (See Documentation)
  12. RSQLite (See Documentation)

Conclusion –

Wrapping-up, both R and Python are free, and open-source programming languages that have been used by programmers and software developers worldwide. Though it may be very hard to know whether to use Python or R for data science and machine learning, we can say that both are great options. One language isn’t better than the other — it all depends on the user’s perspective and his or her needs. These languages are sometimes used by different individuals and businesses based on their requirements.

In terms of R and Python IDEs, the R’s IDE is ideal for data manipulation, graphing, and statistical computing. Some Python applications include web development, numeric computing, and software development. Additionally, while R has numerous packages, Python has many libraries devoted to machine learning.

It doesn’t matter which language is better, being proficient in both languages can be very useful in data science and ML. In fact, RStudio notes that many data science teams around the world are “bilingual,” using both R and Python.

Thanks for reading!


What Do You Prefer? Python or R? Why Not Both? was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

Published via Towards AI

Feedback ↓

Sign Up for the Course
`; } else { console.error('Element with id="subscribe" not found within the page with class "home".'); } } }); // Remove duplicate text from articles /* Backup: 09/11/24 function removeDuplicateText() { const elements = document.querySelectorAll('h1, h2, h3, h4, h5, strong'); // Select the desired elements const seenTexts = new Set(); // A set to keep track of seen texts const tagCounters = {}; // Object to track instances of each tag elements.forEach(el => { const tagName = el.tagName.toLowerCase(); // Get the tag name (e.g., 'h1', 'h2', etc.) // Initialize a counter for each tag if not already done if (!tagCounters[tagName]) { tagCounters[tagName] = 0; } // Only process the first 10 elements of each tag type if (tagCounters[tagName] >= 2) { return; // Skip if the number of elements exceeds 10 } const text = el.textContent.trim(); // Get the text content const words = text.split(/\s+/); // Split the text into words if (words.length >= 4) { // Ensure at least 4 words const significantPart = words.slice(0, 5).join(' '); // Get first 5 words for matching // Check if the text (not the tag) has been seen before if (seenTexts.has(significantPart)) { // console.log('Duplicate found, removing:', el); // Log duplicate el.remove(); // Remove duplicate element } else { seenTexts.add(significantPart); // Add the text to the set } } tagCounters[tagName]++; // Increment the counter for this tag }); } removeDuplicateText(); */ // Remove duplicate text from articles function removeDuplicateText() { const elements = document.querySelectorAll('h1, h2, h3, h4, h5, strong'); // Select the desired elements const seenTexts = new Set(); // A set to keep track of seen texts const tagCounters = {}; // Object to track instances of each tag // List of classes to be excluded const excludedClasses = ['medium-author', 'post-widget-title']; elements.forEach(el => { // Skip elements with any of the excluded classes if (excludedClasses.some(cls => el.classList.contains(cls))) { return; // Skip this element if it has any of the excluded classes } const tagName = el.tagName.toLowerCase(); // Get the tag name (e.g., 'h1', 'h2', etc.) // Initialize a counter for each tag if not already done if (!tagCounters[tagName]) { tagCounters[tagName] = 0; } // Only process the first 10 elements of each tag type if (tagCounters[tagName] >= 10) { return; // Skip if the number of elements exceeds 10 } const text = el.textContent.trim(); // Get the text content const words = text.split(/\s+/); // Split the text into words if (words.length >= 4) { // Ensure at least 4 words const significantPart = words.slice(0, 5).join(' '); // Get first 5 words for matching // Check if the text (not the tag) has been seen before if (seenTexts.has(significantPart)) { // console.log('Duplicate found, removing:', el); // Log duplicate el.remove(); // Remove duplicate element } else { seenTexts.add(significantPart); // Add the text to the set } } tagCounters[tagName]++; // Increment the counter for this tag }); } removeDuplicateText(); //Remove unnecessary text in blog excerpts document.querySelectorAll('.blog p').forEach(function(paragraph) { // Replace the unwanted text pattern for each paragraph paragraph.innerHTML = paragraph.innerHTML .replace(/Author\(s\): [\w\s]+ Originally published on Towards AI\.?/g, '') // Removes 'Author(s): XYZ Originally published on Towards AI' .replace(/This member-only story is on us\. Upgrade to access all of Medium\./g, ''); // Removes 'This member-only story...' }); //Load ionic icons and cache them if ('localStorage' in window && window['localStorage'] !== null) { const cssLink = 'https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css'; const storedCss = localStorage.getItem('ionicons'); if (storedCss) { loadCSS(storedCss); } else { fetch(cssLink).then(response => response.text()).then(css => { localStorage.setItem('ionicons', css); loadCSS(css); }); } } function loadCSS(css) { const style = document.createElement('style'); style.innerHTML = css; document.head.appendChild(style); } //Remove elements from imported content automatically function removeStrongFromHeadings() { const elements = document.querySelectorAll('h1, h2, h3, h4, h5, h6, span'); elements.forEach(el => { const strongTags = el.querySelectorAll('strong'); strongTags.forEach(strongTag => { while (strongTag.firstChild) { strongTag.parentNode.insertBefore(strongTag.firstChild, strongTag); } strongTag.remove(); }); }); } removeStrongFromHeadings(); "use strict"; window.onload = () => { /* //This is an object for each category of subjects and in that there are kewords and link to the keywods let keywordsAndLinks = { //you can add more categories and define their keywords and add a link ds: { keywords: [ //you can add more keywords here they are detected and replaced with achor tag automatically 'data science', 'Data science', 'Data Science', 'data Science', 'DATA SCIENCE', ], //we will replace the linktext with the keyword later on in the code //you can easily change links for each category here //(include class="ml-link" and linktext) link: 'linktext', }, ml: { keywords: [ //Add more keywords 'machine learning', 'Machine learning', 'Machine Learning', 'machine Learning', 'MACHINE LEARNING', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, ai: { keywords: [ 'artificial intelligence', 'Artificial intelligence', 'Artificial Intelligence', 'artificial Intelligence', 'ARTIFICIAL INTELLIGENCE', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, nl: { keywords: [ 'NLP', 'nlp', 'natural language processing', 'Natural Language Processing', 'NATURAL LANGUAGE PROCESSING', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, des: { keywords: [ 'data engineering services', 'Data Engineering Services', 'DATA ENGINEERING SERVICES', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, td: { keywords: [ 'training data', 'Training Data', 'training Data', 'TRAINING DATA', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, ias: { keywords: [ 'image annotation services', 'Image annotation services', 'image Annotation services', 'image annotation Services', 'Image Annotation Services', 'IMAGE ANNOTATION SERVICES', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, l: { keywords: [ 'labeling', 'labelling', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, pbp: { keywords: [ 'previous blog posts', 'previous blog post', 'latest', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, mlc: { keywords: [ 'machine learning course', 'machine learning class', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, }; //Articles to skip let articleIdsToSkip = ['post-2651', 'post-3414', 'post-3540']; //keyword with its related achortag is recieved here along with article id function searchAndReplace(keyword, anchorTag, articleId) { //selects the h3 h4 and p tags that are inside of the article let content = document.querySelector(`#${articleId} .entry-content`); //replaces the "linktext" in achor tag with the keyword that will be searched and replaced let newLink = anchorTag.replace('linktext', keyword); //regular expression to search keyword var re = new RegExp('(' + keyword + ')', 'g'); //this replaces the keywords in h3 h4 and p tags content with achor tag content.innerHTML = content.innerHTML.replace(re, newLink); } function articleFilter(keyword, anchorTag) { //gets all the articles var articles = document.querySelectorAll('article'); //if its zero or less then there are no articles if (articles.length > 0) { for (let x = 0; x < articles.length; x++) { //articles to skip is an array in which there are ids of articles which should not get effected //if the current article's id is also in that array then do not call search and replace with its data if (!articleIdsToSkip.includes(articles[x].id)) { //search and replace is called on articles which should get effected searchAndReplace(keyword, anchorTag, articles[x].id, key); } else { console.log( `Cannot replace the keywords in article with id ${articles[x].id}` ); } } } else { console.log('No articles found.'); } } let key; //not part of script, added for (key in keywordsAndLinks) { //key is the object in keywords and links object i.e ds, ml, ai for (let i = 0; i < keywordsAndLinks[key].keywords.length; i++) { //keywordsAndLinks[key].keywords is the array of keywords for key (ds, ml, ai) //keywordsAndLinks[key].keywords[i] is the keyword and keywordsAndLinks[key].link is the link //keyword and link is sent to searchreplace where it is then replaced using regular expression and replace function articleFilter( keywordsAndLinks[key].keywords[i], keywordsAndLinks[key].link ); } } function cleanLinks() { // (making smal functions is for DRY) this function gets the links and only keeps the first 2 and from the rest removes the anchor tag and replaces it with its text function removeLinks(links) { if (links.length > 1) { for (let i = 2; i < links.length; i++) { links[i].outerHTML = links[i].textContent; } } } //arrays which will contain all the achor tags found with the class (ds-link, ml-link, ailink) in each article inserted using search and replace let dslinks; let mllinks; let ailinks; let nllinks; let deslinks; let tdlinks; let iaslinks; let llinks; let pbplinks; let mlclinks; const content = document.querySelectorAll('article'); //all articles content.forEach((c) => { //to skip the articles with specific ids if (!articleIdsToSkip.includes(c.id)) { //getting all the anchor tags in each article one by one dslinks = document.querySelectorAll(`#${c.id} .entry-content a.ds-link`); mllinks = document.querySelectorAll(`#${c.id} .entry-content a.ml-link`); ailinks = document.querySelectorAll(`#${c.id} .entry-content a.ai-link`); nllinks = document.querySelectorAll(`#${c.id} .entry-content a.ntrl-link`); deslinks = document.querySelectorAll(`#${c.id} .entry-content a.des-link`); tdlinks = document.querySelectorAll(`#${c.id} .entry-content a.td-link`); iaslinks = document.querySelectorAll(`#${c.id} .entry-content a.ias-link`); mlclinks = document.querySelectorAll(`#${c.id} .entry-content a.mlc-link`); llinks = document.querySelectorAll(`#${c.id} .entry-content a.l-link`); pbplinks = document.querySelectorAll(`#${c.id} .entry-content a.pbp-link`); //sending the anchor tags list of each article one by one to remove extra anchor tags removeLinks(dslinks); removeLinks(mllinks); removeLinks(ailinks); removeLinks(nllinks); removeLinks(deslinks); removeLinks(tdlinks); removeLinks(iaslinks); removeLinks(mlclinks); removeLinks(llinks); removeLinks(pbplinks); } }); } //To remove extra achor tags of each category (ds, ml, ai) and only have 2 of each category per article cleanLinks(); */ //Recommended Articles var ctaLinks = [ /* ' ' + '

Subscribe to our AI newsletter!

' + */ '

Take our 85+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

'+ '

Towards AI has published Building LLMs for Production—our 470+ page guide to mastering LLMs with practical projects and expert insights!

' + '
' + '' + '' + '

Note: Content contains the views of the contributing authors and not Towards AI.
Disclosure: This website may contain sponsored content and affiliate links.

' + 'Discover Your Dream AI Career at Towards AI Jobs' + '

Towards AI has built a jobs board tailored specifically to Machine Learning and Data Science Jobs and Skills. Our software searches for live AI jobs each hour, labels and categorises them and makes them easily searchable. Explore over 10,000 live jobs today with Towards AI Jobs!

' + '
' + '

🔥 Recommended Articles 🔥

' + 'Why Become an LLM Developer? Launching Towards AI’s New One-Stop Conversion Course'+ 'Testing Launchpad.sh: A Container-based GPU Cloud for Inference and Fine-tuning'+ 'The Top 13 AI-Powered CRM Platforms
' + 'Top 11 AI Call Center Software for 2024
' + 'Learn Prompting 101—Prompt Engineering Course
' + 'Explore Leading Cloud Providers for GPU-Powered LLM Training
' + 'Best AI Communities for Artificial Intelligence Enthusiasts
' + 'Best Workstations for Deep Learning
' + 'Best Laptops for Deep Learning
' + 'Best Machine Learning Books
' + 'Machine Learning Algorithms
' + 'Neural Networks Tutorial
' + 'Best Public Datasets for Machine Learning
' + 'Neural Network Types
' + 'NLP Tutorial
' + 'Best Data Science Books
' + 'Monte Carlo Simulation Tutorial
' + 'Recommender System Tutorial
' + 'Linear Algebra for Deep Learning Tutorial
' + 'Google Colab Introduction
' + 'Decision Trees in Machine Learning
' + 'Principal Component Analysis (PCA) Tutorial
' + 'Linear Regression from Zero to Hero
'+ '

', /* + '

Join thousands of data leaders on the AI newsletter. It’s free, we don’t spam, and we never share your email address. Keep up to date with the latest work in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

',*/ ]; var replaceText = { '': '', '': '', '
': '
' + ctaLinks + '
', }; Object.keys(replaceText).forEach((txtorig) => { //txtorig is the key in replacetext object const txtnew = replaceText[txtorig]; //txtnew is the value of the key in replacetext object let entryFooter = document.querySelector('article .entry-footer'); if (document.querySelectorAll('.single-post').length > 0) { //console.log('Article found.'); const text = entryFooter.innerHTML; entryFooter.innerHTML = text.replace(txtorig, txtnew); } else { // console.log('Article not found.'); //removing comment 09/04/24 } }); var css = document.createElement('style'); css.type = 'text/css'; css.innerHTML = '.post-tags { display:none !important } .article-cta a { font-size: 18px; }'; document.body.appendChild(css); //Extra //This function adds some accessibility needs to the site. function addAlly() { // In this function JQuery is replaced with vanilla javascript functions const imgCont = document.querySelector('.uw-imgcont'); imgCont.setAttribute('aria-label', 'AI news, latest developments'); imgCont.title = 'AI news, latest developments'; imgCont.rel = 'noopener'; document.querySelector('.page-mobile-menu-logo a').title = 'Towards AI Home'; document.querySelector('a.social-link').rel = 'noopener'; document.querySelector('a.uw-text').rel = 'noopener'; document.querySelector('a.uw-w-branding').rel = 'noopener'; document.querySelector('.blog h2.heading').innerHTML = 'Publication'; const popupSearch = document.querySelector$('a.btn-open-popup-search'); popupSearch.setAttribute('role', 'button'); popupSearch.title = 'Search'; const searchClose = document.querySelector('a.popup-search-close'); searchClose.setAttribute('role', 'button'); searchClose.title = 'Close search page'; // document // .querySelector('a.btn-open-popup-search') // .setAttribute( // 'href', // 'https://medium.com/towards-artificial-intelligence/search' // ); } // Add external attributes to 302 sticky and editorial links function extLink() { // Sticky 302 links, this fuction opens the link we send to Medium on a new tab and adds a "noopener" rel to them var stickyLinks = document.querySelectorAll('.grid-item.sticky a'); for (var i = 0; i < stickyLinks.length; i++) { /* stickyLinks[i].setAttribute('target', '_blank'); stickyLinks[i].setAttribute('rel', 'noopener'); */ } // Editorial 302 links, same here var editLinks = document.querySelectorAll( '.grid-item.category-editorial a' ); for (var i = 0; i < editLinks.length; i++) { editLinks[i].setAttribute('target', '_blank'); editLinks[i].setAttribute('rel', 'noopener'); } } // Add current year to copyright notices document.getElementById( 'js-current-year' ).textContent = new Date().getFullYear(); // Call functions after page load extLink(); //addAlly(); setTimeout(function() { //addAlly(); //ideally we should only need to run it once ↑ }, 5000); }; function closeCookieDialog (){ document.getElementById("cookie-consent").style.display = "none"; return false; } setTimeout ( function () { closeCookieDialog(); }, 15000); console.log(`%c 🚀🚀🚀 ███ █████ ███████ █████████ ███████████ █████████████ ███████████████ ███████ ███████ ███████ ┌───────────────────────────────────────────────────────────────────┐ │ │ │ Towards AI is looking for contributors! │ │ Join us in creating awesome AI content. │ │ Let's build the future of AI together → │ │ https://towardsai.net/contribute │ │ │ └───────────────────────────────────────────────────────────────────┘ `, `background: ; color: #00adff; font-size: large`); //Remove latest category across site document.querySelectorAll('a[rel="category tag"]').forEach(function(el) { if (el.textContent.trim() === 'Latest') { // Remove the two consecutive spaces (  ) if (el.nextSibling && el.nextSibling.nodeValue.includes('\u00A0\u00A0')) { el.nextSibling.nodeValue = ''; // Remove the spaces } el.style.display = 'none'; // Hide the element } }); // Add cross-domain measurement, anonymize IPs 'use strict'; //var ga = gtag; ga('config', 'G-9D3HKKFV1Q', 'auto', { /*'allowLinker': true,*/ 'anonymize_ip': true/*, 'linker': { 'domains': [ 'medium.com/towards-artificial-intelligence', 'datasets.towardsai.net', 'rss.towardsai.net', 'feed.towardsai.net', 'contribute.towardsai.net', 'members.towardsai.net', 'pub.towardsai.net', 'news.towardsai.net' ] } */ }); ga('send', 'pageview'); -->