One thing critical for success in the age of AI (and who has it)

[This article was first published on r-bloggers – SHARP SIGHT LABS, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.



Data science, artificial intelligence, automation, and other advanced technologies are reshaping the world.

We’re starting to see glimpses of it, for example the rapid emergence of self driving cars. Moreover, the changes brought about by technology will likely become more frequent and more dramatic in the next few years.

In fact, two MIT economist, Erik Brynjolfsson and Andrew McAfee, think that the emergence of AI and data driven technologies may be one of the most important events in all of human history.

Risk and opportunity in the age of AI

They suggest that AI and automation will dramatically increase productivity and human development. In essence, AI, machine learning, and data-driven technology will free us from our cognitive limitations much like the engine freed us from our physical limitations. This will in turn lead to large gains in productivity.

But while AI and data-driven tech will likely increase productivity, they are also likely to lead to high levels of unemployment. As software and technology become more intelligent, they will replace people who don’t have the right skills.

A critical factor for success: human capital

How can someone succeed in such an era?

Brynjolfsson and McAfee point out that one of the keys to success in the age of data, AI, and automation will be human capital.

As technology increasingly substitutes for people, one of the keys to success will be cutting-edge knowledge, judgement (particularly in complex domains), and creativity.

Mapping Human Capital

In thinking about this, I decided to map which countries have the highest levels of human capital, as measured by the World Economic Forum.

While the WEF’s Human Capital Index is not a perfect index of cutting edge skill, it does provide a high-level view of the countries that may be better prepared for a changing, high-tech world.

One thing in particular that I’ll note, is that this map effectively shows averages of national performance. Having said that, talent and innovation are known to be highly uneven geographically. There are “spikes.” So even though this map shows countries’ average performance, we’d likely see an even different story if we looked at cities (or even zip codes).

R Code: mapping human capital

The following R code generates a map of the WEF’s Human Capital Index.

The data are scraped from the WEF and then joined to a map of the world generated by the map_data() function.

Pay close attention to the join itself. The join was a little tricky, because the country names in the WEF data were not all identical to the names in the world map. Specifically, I had to first identify the countries that did not match, and then recode them.

R code

#==============
# LOAD PACKAGES
#==============
library(tidyverse)
library(stringr)
library(readr)
library(rvest)
library(viridis)


#============
# SCRAPE DATA
#============

#-----------------------
# ESTABLISH URL LOCATION
#-----------------------
html.human_capital <- read_html("http://reports.weforum.org/human-capital-report-2016/rankings/")


#-------------------------------
# SCRAPE: Extract table from URL
#-------------------------------
df.human_capital <- html.human_capital %>%
                        html_node("table") %>%
                        html_table()


# inspect
glimpse(df.human_capital)



#========================
# RENAME VARIABLES
# - convert to lower case
#========================

df.human_capital <- df.human_capital %>%
                        rename(rank = `Overall Rank`
                               ,country_nm = Economy
                               ,human_cap_score = `Overall Score`
                               )



# INSPECT
glimpse(df.human_capital)


#==============
# GET WORLD MAP
#==============

map.world <- map_data("world")

# INSPECT
glimpse(map.world)




#===================================================================
# RECODE COUNTRY NAMES
#  some of the countries in the data frame df.human_capital don't 
#  exactly match the names in map.world.
#  This prohibits a proper join.  
#  We're going to hard-code (i.e. recode) these values to make sure
#  that the join works properly
#===================================================================

#------------------------------------------
# GET LIST OF COUNTRIES IN df.human_capital
#------------------------------------------
df.hcap_countries <- df.human_capital %>% 
  select(country_nm)


#-----------------------------------
# GET LIST OF COUNTRIES IN map.world
#-----------------------------------
df.map_countries <- map.world %>%
  select(region) %>% 
  group_by(region) %>%
  summarise(match = 1) 


#-----------------------------
# LOOK FOR MATCH or NO-MATCH
#  - we'll use a join for this
#    and inspect the output
#-----------------------------

df.check_match <- left_join(df.hcap_countries, df.map_countries, by = c('country_nm' = 'region'))

df.check_match %>%
  filter(is.na(match))


#------------------------------
# THESE ARE THE COUNTRIES THAT
# DO NOT MATCH:
#             country_nm  match
# 1   Russian Federation     NA
# 2       United Kingdom     NA
# 3        United States     NA
# 4           Korea Rep.     NA
# 5      Kyrgyz Republic     NA
# 6      Slovak Republic     NA
# 7        Macedonia FYR     NA
# 8    Iran Islamic Rep.     NA
# 9  Trinidad and Tobago     NA
# 10             Lao PDR     NA
# 11       CÙte d’Ivoire     NA
#------------------------------


#---------------------------------------------------------
# RECODE COUNTRY NAMES
#  - now that we have the names from df.human_capital that
#    don't match map.world, we can recode them
#  - to get the "new" names that we need to use,
#    inspect the names in df.map_countries
#---------------------------------------------------------

df.human_capital$country_nm <- recode(df.human_capital$country_nm
                                       ,'Russian Federation'    = 'Russia'
                                       ,'United Kingdom'        = 'UK'
                                       ,'United States'         = 'USA'
                                       ,'Korea, Rep.'           = 'South Korea'
                                       ,'Kyrgyz Republic'       = 'Kyrgyzstan'
                                       ,'Slovak Republic'       = 'Slovakia'
                                       ,'Macedonia, FYR'        = 'Macedonia'
                                       ,'Iran, Islamic Rep.'    = 'Iran'
                                       ,'Trinidad and Tobago'   = 'Trinidad'
                                       ,'Lao PDR'               = 'Laos'
                                       ,'CÙte d’Ivoire'         = 'Ivory Coast'
                                       )



#====================================================
# JOIN HUMAN CAPITAL DATA TO MAP
# - now we can join the human capital data to the map
#====================================================

map.world <- left_join(map.world, df.human_capital, by = c('region' = 'country_nm'))

glimpse(map.world)


#=====================================
# PLOT: BASIC MAP
# - this is a simple first iteration
#=====================================
ggplot(data = map.world, aes(x = long, y = lat, group = group)) +
  geom_polygon(aes(fill = human_cap_score)) 



#=======================================
# PLOT FINAL MAP
# - this is the finalized version after 
#   much iteration
#=======================================


ggplot(data = map.world, aes(x = long, y = lat, group = group)) +
  geom_polygon(aes(fill = human_cap_score)) +
  scale_fill_viridis(name = "Human Capital\nIndex") +
  labs(title = "Human Capital Index, by country"
       ,subtitle = "source: World Economic Forum, 2016\n            reports.weforum.org/human-capital-report-2016/") +
  theme(panel.background = element_rect(fill = "#3E3E3E")
        ,plot.background = element_rect(fill = "#3E3E3E")
        ,legend.background = element_blank()
        ,axis.title = element_blank()
        ,axis.text = element_blank()
        ,axis.ticks = element_blank()
        ,panel.grid = element_blank()
        ,text = element_text(family = "Gill Sans", color = "#DDDDDD")
        ,plot.title = element_text(size = 32)
        ,legend.position = c(.18,.375)
        ) 

Sign up to learn data science

People who know data science and machine learning will have massive opportunities in the age of AI and data-driven tech.

Sign up now to get our free Data Science Crash Course, where you’ll learn:

  • a step-by-step data science learning plan

  • the 1 programming language you need to learn

  • 3 essential data visualizations
  • how to do data manipulation in R
  • how to get started with machine learning
  • and more …

SIGN UP NOW

The post One thing critical for success in the age of AI (and who has it) appeared first on SHARP SIGHT LABS.

To leave a comment for the author, please follow the link and comment on their blog: r-bloggers – SHARP SIGHT LABS.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)