A Data Application to Foretell the Next Silicon Valley?
Can we predict what the next hub of tech entrepreneurship will be? Could we pinpoint where the next real estate boom will be and invest there? We can now.
Join the DZone community and get the full member experience.Join For Free
can we predict what the next hub of tech entrepreneurship will be? could we pinpoint where the next real estate boom will be and invest there? thanks to advances in machine learning and easier access to public data through open data initiatives, we can now explore these types of questions.
i took an approach originally developed to group countries for a global health policy initiative and brought it closer to home. using data from the us census and fbi, i developed an interactive data application for grouping us cities based business and technology, crime, demographics, health and more.
the screenshot below shows one such result looking at tech hubs. the color is the cluster assignment, the size of the city is the percentage of college degrees, and the opacity is access to healthcare. i placed more emphasis on business, technology and education metrics to guide the analysis. the results show that the san jose/palo alto area has more in common with its west coast brethren, denver and austin, while the san francisco metro area has more in common with big cities along the east coast and in the midwest. it also shows a strong cluster of midwestern tech hubs including columbus, indianapolis, oklahoma city, and salt lake city.
you can explore the data yourself. the application lets you adjust the relative weight of factors, e.g. demographics, health, and education, to see what city clusters manifest.
you can also toggle between a map and a network visualization to view the clusters.
if you find any interesting results, i’d love to hear about it. if you end up striking it rich after buying real estate in the next silicon valley, kickbacks are welcome.
here’s how i got the data, wrangled it, and analyzed it to enable some visual exploration in a data application.
how the wild west (of data) was won
while open data initiatives have led to increased transparency, they have in no way made things easy. data on government sites are in a variety of formats and states of completeness/quality and can be quite difficult to locate. after days of hunting around websites and exploring data, i settled in on a handful of files that had trend data for us metropolitan areas in some text-based format, like a csv or excel file.
the sources include:
- us census business patterns for establishment and payroll data by industry and city
- us census databooks for selected extracts from the 2010 census, including metrics on demographics, health, education, labor and immigration
- fbi uniform crime reporting (ucr) data for violent and non-violent crime
downloading the data was just the start. from there, i needed to massage the data extensively, mapping codes to names, handling variations in city names, and transforming three different formats into a single standardized json object for use in later python and rest components.
for those interested, the original and formatted data files are available in github .
dealing with raw time series data is tricky. small fluctuations in the shape or height of the curve, or even just a shift of a few units of time, can throw comparison algorithms into a tailspin. in fact, my first data analysis job was as an organic chemist intern comparing resin weight distribution graphs that looked like time series. if only i had the tools then that we have at our collective disposal now!
people have devised many sophisticated techniques to handle these situations, and one of the most popular is the fourier wavelet transform. algorithms like these are used for everything from audio analysis (think spotify or pandora) to healthcare monitors and financial markets.
the goal of all these techniques is to convert a raw piece of data like a time series into features: a more abstract representation of its characteristics like height and shape. for this analysis, i chose the symbolic aggregation approximation (sax) algorithm from keogh and lin at uc riverside. sax shares many of the benefits of fourier and other approaches but is more compact, representing features as strings. this is also useful because bioinformatics is ripe with machine learning algorithms for analyzing strings like dna and proteins.
i used a python module for sax by nathan hoffman and adapted it to include the average value of a time series and accommodations for missing values.
one of these things is not like the other
once i converted the cities' time series data to a series of strings, i could now more easily compare two cities metric-by-metric. but i still needed a way to calculate similarity. for that, i leaned on my biochemistry background and used the levenshtein distance, a formula that calculates the distance between two strings accounting for additions, substitutions and deletions. this approach is commonly used for comparing strings of dna, rna or protein sequences. it is forgiving to subtle shifts in the strings, which works well for both genetic mutations and, in our case, minor differences between time series trajectories.
his fingerprints were all over it
doing this similarity calculation for every metric and every time we compare two cities is both time consuming and yields poorer results. we humans excel at classifying things by creating higher-order features from more detailed raw data, and the same is true for computers.
now that i had time series features and a way to compare them, i created fingerprints for each city. i assigned a class for each city and metric using a clustering algorithm, then i combined them into a single feature vector. the result was a compact, 60-digit numeric vector for each city that could be quickly compared with another city's feature vector.
cluster's last stand
now that we have feature vectors per city, i was able to cluster the cities using standard clustering algorithms. we explored both kmeans and kmedoids for their simplicity, but other more sophisticated clustering algorithms would work just fine.
this is an incredibly exciting time. we increasingly have access to rich, complex data sets and the data analysis and visualization tools to make sense of it. imagine what else we can learn and apply to improve the lives of so many.
you can check out a webinar i conducted on the topic for a bit more detail about the algorithmic techniques. i created the xap (what we call data applications created with the exaptive studio), with the help of mark wissler and derek grape on the exaptive team.
Published at DZone with permission of Matt Coatney, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.