Why care about patents?
1. Patents play a critical role in incentivizing innovation, without
which we wouldn't have much of the technology we rely on everyday
What does your iPhone, Google's PageRank algorithm, and a butter
substitute called Smart Balance all have in common?
...They all probably wouldn't be here if not for patents. A patent
provides its owner with the ability to make money off of something that
they invented, without having to worry about someone else copying their
technology. Think Apple would spend millions of dollars developing the
iPhone if Samsung could just come along and rip it
off?
Probably not.
2. Patents offer a great opportunity for data analysis
There are two primary reasons for this:
Patent data is public. In return for the exclusive right to
profit off an invention, an individual/company has to publicly
disclose the details of their invention to the rest of the world.
Examples of those
details
include the patent's title, abstract, technology classification,
assigned organizations, etc.
Patent data can answer questions that people care about.
Companies (especially big ones like IBM and Google) have a vested
interest in extracting insights from patents, and spend a lot of
time/resources trying figure out how to best manage their
intellectual property (IP) rights. They're plagued by questions like
&quot;who should I sell my underperforming patents to,&quot; &quot;which technology
areas are open to new innovations,&quot; &quot;what's going to be the next big
thing in the world of buttery spreads,&quot; etc. Patents offer a way to
provide data-driven answers to these questions.
Combined, these two things make patents a prime target for data
analysis. However, until recently it was hard to get at the data inside
these documents. One had to either collect it manually using the
official United States Patent and Trademark
Office
(USPTO) search
engine, or figure
out a way to download, parse, and model huge XML data dumps. Enter
PatentsView.
PatentsView and the patentsview package
PatentsView is one
of USPTO's new initiatives intended to increase the usability and value
of patent data. One feature of this project is a publicly accessible API
that makes it easy to programmatically interact with the data. A few of
the reasons why I like the API (and PatentsView more generally):
The API is free (no credential required) and currently doesn't
impose rate limits/bandwidth throttling.
The project offers bulk downloads of patent
data on their website (in a
flat file format), for those who want to be closest to the data.
Both the API and the bulk download data contain disambiguated
entities such as inventors, assignees, organizations, etc. In other
words, the API will tell you whether it thinks that John Smith on
patent X is the same person as John Smith on patent Y. 1
The patentsview R package is a wrapper around the PatentsView API. It
contains a function that acts as a client to the API (search_pv()) as
well as several supporting functions. Full documentation of the package
can be found on its
website.
Installation
You can install the stable version of patentsview from CRAN:
install.packages(&quot;patentsview&quot;)
Or get the development version from GitHub:
if (!require(devtools)) install.packages(&quot;devtools&quot;)
devtools::install_github(&quot;ropensci/patentsview&quot;)
Getting started
The package has one main function, search_pv(), that makes it easy to
send requests to the API. There are two parameters to search_pv() that
you're going to want to think about just about every time you call it -
query and fields. You tell the API how you want to filter the patent
data with query, and which fields you want to retrieve with
fields. 2
query
Your query has to use the PatentsView query
language, which is
a JSON-based syntax that is similar to the one used by Lucene. You can
write the query directly and pass it as a string to search_pv():
library(patentsview)
qry_1 $data
#__ #### A list with a single data frame on the patent data level:
#__
#__ List of 1
#__ $ patents:'data.frame': 25 obs. of 3 variables:
#__ ..$ patent_id : chr [1:25] &quot;7313829&quot; ...
#__ ..$ patent_number: chr [1:25] &quot;7313829&quot; ...
#__ ..$ patent_title : chr [1:25] &quot;Sealing device for body suit and sealin&quot;..
#__
#__ $query_results
#__ #### Distinct entity counts across all downloadable pages of output:
#__
#__ total_patent_count = 100,000
...Or you can use the domain specific language (DSL) provided in the
patentsview package to help you write the query:
qry_2 {&quot;_gt&quot;:{&quot;patent_year&quot;:2007}}
search_pv(query = qry_2)
#__ $data
#__ #### A list with a single data frame on the patent data level:
#__
#__ List of 1
#__ $ patents:'data.frame': 25 obs. of 3 variables:
#__ ..$ patent_id : chr [1:25] &quot;7313829&quot; ...
#__ ..$ patent_number: chr [1:25] &quot;7313829&quot; ...
#__ ..$ patent_title : chr [1:25] &quot;Sealing device for body suit and sealin&quot;..
#__
#__ $query_results
#__ #### Distinct entity counts across all downloadable pages of output:
#__
#__ total_patent_count = 100,000
qry_1 and qry_2 will result in the same HTTP call to the API. Both
queries search for patents in USPTO that were published after 2007.
There are three gotchas to look out for when writing a query:
Field is queryable. The API has 7 endpoints (the default
endpoint is &quot;patents&quot;), and each endpoint has its own set of fields
that you can filter on. The fields that you can filter on are not
necessarily the same as the ones that you can retrieve. In other
words, the fields that you can include in query (e.g.,
patent_year) are not necessarily the same as those that you can
include in fields. To see which fields you can query on, look in
the fieldsdf data frame (View(patentsview::fieldsdf)) for fields
that have a &quot;y&quot; indicator in their can_query column for your given
endpoint.
Correct data type for field. If you're filtering on a field in
your query, you have to make sure that the value you are filtering
on is consistent with the field's data type. For example,
patent_year has type &quot;integer,&quot; so if you pass 2007 as a string
then you're going to get an error (patent_year = 2007 is good,
patent_year = &quot;2007&quot; is no good). You can find a field's data type
in the fieldsdf data frame.
Comparison function works with field's data type. The comparison
function(s) that you use (e.g., the greater-than function shown
above, qry_funs$gt()) must be consistent with the field's data
type. For example, you can't use the &quot;contains&quot; function on fields
of type &quot;integer&quot; (qry_funs$contains(patent_year = 2007) will
throw an error). See ?qry_funs for more details.
In short, use the fieldsdf data frame when you write a query and you
should be fine. Check out the writing queries
vignette
for more details.
fields
Up until now we have been using the default value for fields. This
results in the API giving us some small set of default fields. Let's see
about retrieving some more fields:
search_pv(
query = qry_funs$gt(patent_year = 2007),
fields = c(&quot;patent_abstract&quot;, &quot;patent_average_processing_time&quot;,
&quot;inventor_first_name&quot;, &quot;inventor_total_num_patents&quot;)
)
#__ $data
#__ #### A list with a single data frame (with list column(s) inside) on the patent data level:
#__
#__ List of 1
#__ $ patents:'data.frame': 25 obs. of 3 variables:
#__ ..$ patent_abstract : chr [1:25] &quot;A sealing device for a&quot;..
#__ ..$ patent_average_processing_time: chr [1:25] &quot;1324&quot; ...
#__ ..$ inventors :List of 25
#__
#__ $query_results
#__ #### Distinct entity counts across all downloadable pages of output:
#__
#__ total_patent_count = 100,000
The fields that you can retrieve depends on the endpoint that you are
hitting. We've been using the &quot;patents&quot; endpoint thus far, so all of
these are retrievable:
fieldsdf[fieldsdf$endpoint == &quot;patents&quot;, &quot;field&quot;]. You can also use
get_fields() to list the retrievable fields for a given endpoint:
search_pv(
query = qry_funs$gt(patent_year = 2007),
fields = get_fields(endpoint = &quot;patents&quot;, groups = c(&quot;patents&quot;, &quot;inventors&quot;))
)
#__ $data
#__ #### A list with a single data frame (with list column(s) inside) on the patent data level:
#__
#__ List of 1
#__ $ patents:'data.frame': 25 obs. of 31 variables:
#__ ..$ patent_abstract : chr [1:25] &quot;A sealing devi&quot;..
#__ ..$ patent_average_processing_time : chr [1:25] &quot;1324&quot; ...
#__ ..$ patent_date : chr [1:25] &quot;2008-01-01&quot; ...
#__ ..$ patent_firstnamed_assignee_city : chr [1:25] &quot;Cambridge&quot; ...
#__ ..$ patent_firstnamed_assignee_country : chr [1:25] &quot;US&quot; ...
#__ ..$ patent_firstnamed_assignee_id : chr [1:25] &quot;b9fc6599e3d60c&quot;..
#__ ..$ patent_firstnamed_assignee_latitude : chr [1:25] &quot;42.3736&quot; ...
#__ ..$ patent_firstnamed_assignee_location_id: chr [1:25] &quot;42.3736158|-71&quot;..
#__ ..$ patent_firstnamed_assignee_longitude : chr [1:25] &quot;-71.1097&quot; ...
#__ ..$ patent_firstnamed_assignee_state : chr [1:25] &quot;MA&quot; ...
#__ ..$ patent_firstnamed_inventor_city : chr [1:25] &quot;Lucca&quot; ...
#__ ..$ patent_firstnamed_inventor_country : chr [1:25] &quot;IT&quot; ...
#__ ..$ patent_firstnamed_inventor_id : chr [1:25] &quot;6416028-3&quot; ...
#__ ..$ patent_firstnamed_inventor_latitude : chr [1:25] &quot;43.8376&quot; ...
#__ ..$ patent_firstnamed_inventor_location_id: chr [1:25] &quot;43.8376211|10.&quot;..
#__ ..$ patent_firstnamed_inventor_longitude : chr [1:25] &quot;10.4951&quot; ...
#__ ..$ patent_firstnamed_inventor_state : chr [1:25] &quot;Tuscany&quot; ...
#__ ..$ patent_id : chr [1:25] &quot;7313829&quot; ...
#__ ..$ patent_kind : chr [1:25] &quot;B1&quot; ...
#__ ..$ patent_number : chr [1:25] &quot;7313829&quot; ...
#__ ..$ patent_num_cited_by_us_patents : chr [1:25] &quot;5&quot; ...
#__ ..$ patent_num_claims : chr [1:25] &quot;25&quot; ...
#__ ..$ patent_num_combined_citations : chr [1:25] &quot;35&quot; ...
#__ ..$ patent_num_foreign_citations : chr [1:25] &quot;0&quot; ...
#__ ..$ patent_num_us_application_citations : chr [1:25] &quot;0&quot; ...
#__ ..$ patent_num_us_patent_citations : chr [1:25] &quot;35&quot; ...
#__ ..$ patent_processing_time : chr [1:25] &quot;792&quot; ...
#__ ..$ patent_title : chr [1:25] &quot;Sealing device&quot;..
#__ ..$ patent_type : chr [1:25] &quot;utility&quot; ...
#__ ..$ patent_year : chr [1:25] &quot;2008&quot; ...
#__ ..$ inventors :List of 25
#__
#__ $query_results
#__ #### Distinct entity counts across all downloadable pages of output:
#__
#__ total_patent_count = 100,000
Example
Let's look at a quick example of pulling and analyzing patent data.
We'll look at patents from the last ten years that are classified below
the H04L63/00 CPC
code.
Patents in this area relate to &quot;network architectures or network
communication protocols for separating internal from external
traffic.&quot; 3 CPC codes offer a quick and dirty way to find patents of
interest, though getting a sense of their hierarchy can be tricky.
Download the data
library(patentsview)
# Write a query:
query