NYC Data Science Academy| Blog
Bootcamps
Lifetime Job Support Available Financing Available
Bootcamps
Data Science with Machine Learning Flagship ๐Ÿ† Data Analytics Bootcamp Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lesson
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories Testimonials Alumni Directory Alumni Exclusive Study Program
Courses
View Bundled Courses
Financing Available
Bootcamp Prep Popular ๐Ÿ”ฅ Data Science Mastery Data Science Launchpad with Python View AI Courses Generative AI for Everyone New ๐ŸŽ‰ Generative AI for Finance New ๐ŸŽ‰ Generative AI for Marketing New ๐ŸŽ‰
Bundle Up
Learn More and Save More
Combination of data science courses.
View Data Science Courses
Beginner
Introductory Python
Intermediate
Data Science Python: Data Analysis and Visualization Popular ๐Ÿ”ฅ Data Science R: Data Analysis and Visualization
Advanced
Data Science Python: Machine Learning Popular ๐Ÿ”ฅ Data Science R: Machine Learning Designing and Implementing Production MLOps New ๐ŸŽ‰ Natural Language Processing for Production (NLP) New ๐ŸŽ‰
Find Inspiration
Get Course Recommendation Must Try ๐Ÿ’Ž An Ultimate Guide to Become a Data Scientist
For Companies
For Companies
Corporate Offerings Hiring Partners Candidate Portfolio Hire Our Graduates
Students Work
Students Work
All Posts Capstone Data Visualization Machine Learning Python Projects R Projects
Tutorials
About
About
About Us Accreditation Contact Us Join Us FAQ Webinars Subscription An Ultimate Guide to
Become a Data Scientist
    Login
NYC Data Science Acedemy
Bootcamps
Courses
Students Work
About
Bootcamps
Bootcamps
Data Science with Machine Learning Flagship
Data Analytics Bootcamp
Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lessons
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook
Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories
Testimonials
Alumni Directory
Alumni Exclusive Study Program
Courses
Bundles
financing available
View All Bundles
Bootcamp Prep
Data Science Mastery
Data Science Launchpad with Python NEW!
View AI Courses
Generative AI for Everyone
Generative AI for Finance
Generative AI for Marketing
View Data Science Courses
View All Professional Development Courses
Beginner
Introductory Python
Intermediate
Python: Data Analysis and Visualization
R: Data Analysis and Visualization
Advanced
Python: Machine Learning
R: Machine Learning
Designing and Implementing Production MLOps
Natural Language Processing for Production (NLP)
For Companies
Corporate Offerings
Hiring Partners
Candidate Portfolio
Hire Our Graduates
Students Work
All Posts
Capstone
Data Visualization
Machine Learning
Python Projects
R Projects
About
Accreditation
About Us
Contact Us
Join Us
FAQ
Webinars
Subscription
An Ultimate Guide to Become a Data Scientist
Tutorials
Data Analytics
  • Learn Pandas
  • Learn NumPy
  • Learn SciPy
  • Learn Matplotlib
Machine Learning
  • Boosting
  • Random Forest
  • Linear Regression
  • Decision Tree
  • PCA
Interview by Companies
  • JPMC
  • Google
  • Facebook
Artificial Intelligence
  • Learn Generative AI
  • Learn ChatGPT-3.5
  • Learn ChatGPT-4
  • Learn Google Bard
Coding
  • Learn Python
  • Learn SQL
  • Learn MySQL
  • Learn NoSQL
  • Learn PySpark
  • Learn PyTorch
Interview Questions
  • Python Hard
  • R Easy
  • R Hard
  • SQL Easy
  • SQL Hard
  • Python Easy
Data Science Blog > Capstone > Using NLP to Explore Unconventional Targets

Using NLP to Explore Unconventional Targets

Zachary MacTaggart
Posted on Jan 16, 2024

Introduction and Data Issues

Introduction

Extracting information from file content and file pathways presents a challenging task. While Natural Language Processing (NLP) techniques can be beneficial in dealing with these tasks, file pathways are not the conventional target for NLP. Consequently, the data must undergo cleaning and processing steps tailored for NLP applications.

This information extraction process contributes to the precision of search and retrieval functions, facilitates information extraction, and helps to discover similar content related to the target or source.

Problems with the Data

The data presents inconsistent and complex patterns, making the use of Regular Expressions difficult. File paths lack a standardized format or structure, adding to the complexity. Additionally, there are numerous instances of uncommon and domain-specific terminology, posing recognition difficulties for most NLP models. This project aims to address these challenges and find effective ways to detect and extract important information from complex structures.

Data Processing

Getting the Data Prepared for NLP

The first stage of this project involved preparing the data for use in NLP packages. The package I used for this project is called spaCy, a conventional NLP package. Since my data was not in the conventional format it needed to be processed first beforehand. Traditional NLP operates on sentences and bodies of text, so I modified the file paths to resemble sentences more closely. I removed any characters in the file paths that natural language would typically have such as the "/" between file sections. I also added periods in between these sections along with a space so the package would treat them as separate units. These adjustments significantly improved spaCy's ability to recognize and extract information from this data.

Extracting Information

File Path Extraction

After the file paths were processed, the important information could be extracted, after it was broken down into tokens by spaCy.

These tokens allowed for search functions to be created to allow for specific token search across all files. I created a search function to return all file pathways that included a specific token along with a searchable list of all the tokens from the paths.

Term Frequency-Inverse Document Frequency (TF-IDF)

The important information was identified using Term Frequency-Inverse Document Frequency (TF-IDF). TF-IDF scoring is a statistic that represents term-importance in a document relative to a collection of documents or corpus. The formula for this scoring is shown below:

The TF portion represents the number of times term t appears in document d over the total number of terms in document d. The IDF portion represents the total number of documents in the corpus D divided by the number of documents containing the original term t. These two portions are then solved and multiplied together to get the TF-IDF score for each term.

This scoring was then used to give a rank to all the terms within the file paths. Each file path was equal to one document d and the entire directory would be the corpus D. Once the top terms were identified, they were used for Named Entity Recognition (NER) and Non-Negative Matrix Factorization (NMF) later on.

Named Entity Recognition (NER)

NER was used through the spaCy package to help identify and classify information into named entities such as people, dates, and so on. Specific tokens of interest were labeled with general NER along with custom NER for domain-specific terminology and uncommon terms from the TF-IDF scoring.

Some custom NER labels used in the file paths:

  • Directory Folder
  • Instrument Folders
  • Data Folders
  • Data, Reports, and other Analysis Files
  • Image, Temporary, and other File Types

Search functions were created to search for specific entities and return all files with the target entity.

File Content Extraction

The files provided had limited content information due to encryption or other permissions that prevented  the data from being viewed. I created test files to use in their place. The file content was processed and tokenized using similar methods as the file pathways.

For the processing step, the file content had new line spacing and commas if in csv format that needed to be changed to periods to be more sentence-like. The content was created into a searchable list, and search functions to find a specific token were created. These functions would return the content and identify where the content was from based on the target token.

Term Frequency-Inverse Document Frequency (TF-IDF)

TF-IDF scoring was used on the file content just like the file pathways. The content of each file was one document d, and the entire collection of file content would be the corpus D. Some stop words were added to ensure only important words were taken and not numerical values like results values (limited file content caused result values to be important thus created a need for stop words).

Named Entity Recognition (NER)

NER was used for the file content the same way as the file paths. Specific tokens were labeled, and custom NER was created for domain-specific and uncommon terminology that the base spaCy package did not recognize.

Some custom NER labels used in the file content:

  • Test Names
  • Test Type
  • Instrument (Machine) Used
  • Data Values and Measurements
  • Tech Name

Non-Negative Matrix Factorization (NMF)

File Pathway Matrix

NMF was used for topic modeling as a way to identify the topics within the data and later use that for different grouping methods. The initial NMF matrix was created by making a matrix of file paths as rows by important words as columns. The important words used were the top scoring ones from the previous TF-IDF scoring metric. Limiting the columns to only the important words helps keep the dimensions reasonable. The resulting matrix for the file paths was a matrix with dimensions of 2843 x 18. This original matrix will be referred to as matrix V.

The matrix V then gets decomposed into two separate matrices of W and H. When W and H are multiplied back together, they equal the original matrix (with some rounding). With this W matrix we can gather information about the topic of each file path and later calculate the similarity to other file paths within the matrix.

The general form of NMF with an example is shown below, where V is the original matrix that gets decomposed into W and H:

Below is a more accurate form of how NMF is used this in this project, where V is a matrix of documents (file paths or file content) by important terms (from TF-IDF scoring). To find the topic matrix we need to decompose it to find W, which can be used for document similarity and clustering.

File Content Matrix

The same process was done for the file content for NMF. The original matrix V was comprised of file content as rows by important words as columns. Again, using the most important words as the columns based on previous TF-IDF scoring. The resulting matrix was a 5x5 matrix (very small due to limited data and using mostly test files). Matrix V gets decomposed into W and H, and we then use the W (file content topic matrix) for further topic and similarity analysis.

Document Similarity

Documents within the corpus (file paths or file content) were evaluated for similarity using Cosine Similarity to compare the vectors of their respective W matrices. Cosine Similarity calculates the cosine angle between vectors, providing insight into how similar or dissimilar each document is in terms of topics. A Cosine Similarity of 1 indicates perfect similarity, with the vectors pointing in the same direction. A Cosine Similarity of 0 indicates the vectors are perpendicular to each other, indicating no similarity. This scoring was used to compare similarity between all documents in file content and file paths.

Clustering Documents

K-means clustering was used on the vectors within the W matrix to organize the file paths and file content into similar clusters. The vectors in the W matrix were then assigned to the cluster whose K center was closest, determined by Euclidean distance. The algorithm updates the clusters based on the mean of vectors assigned to each cluster until it converges. The end result is the file paths and file content grouped into numbered clusters based on the original K value.

Retrieval Augmented Generation (RAG)

ChatGPT-3.5 Turbo API and RAG

OpenAI's ChatGPT API was also tested to see how it would perform taking information from this project and being able to answer questions and help extract information. The model was fed information from the project such as important terms, file paths, and file content into the first prompt of the chat model to provide information for RAG, where chat models can learn from information it has yet to be trained on. The โ€˜systemโ€™ content was also changed so the model knows that it is working in a specific setting.

It proved very effective at answering basic questions and extracting the relevant information from file content and file paths based on the RAG information fed to it in the first prompt. While this is an effective method, it might not be wise to feed real or sensitive data into a public chat model instead of a custom or bespoke model. API calls can also become expensive, so you need to be sure that they will provide significant business value to offset the costs.

Conclusions and Future Work

Applications and Conclusions

This project could help standardize data within its domain, establishing uniform file naming conventions that could be easily processed by NLP and other extraction methods. These conventions may draw inspiration from the Named Entity Recognition (NER) utilized in the project or adopt a similar approach.

Furthermore, the project has the capability to enhance the management and organization of large directories of files and their content. Documents could be organized based on document similarity or by clustering into similar groups. The similarity scoring mechanism could also be leveraged to recommend related documents from external sources, contributing to the development of a comprehensive knowledge base in the domain.

These extraction methods represent an important first step in automating results analysis by identifying targets containing important information for further review and later release.

Future Work

Future work could involve making all the token and entity search functions user-friendly (as using it through code is not intuitive), with the development of a UI.

Additionally, I would like to continue this work by training a custom model on domain-specific words for custom word vectorization. This approach would allow for searching for similar words based on their vector positions in vector space, allowing users to input words and find similar words based on the closest or most similar vectors.

Gathering and annotating real-world data to be able to train a custom NER model for more precise identification and extraction would also prove a useful addition to this project.

About Author

Zachary MacTaggart

Experienced medical laboratory scientist with a passion for data analytics in healthcare. Looking to transition into my first data science role, driven by an interest in machine learning techniques and the desire to bolster my analytical tools and...
View all posts by Zachary MacTaggart >

Related Articles

Capstone
Catching Fraud in the Healthcare System
Capstone
The Convenience Factor: How Grocery Stores Impact Property Values
Capstone
Acquisition Due Dilligence Automation for Smaller Firms
Machine Learning
Pandemic Effects on the Ames Housing Market and Lifestyle
Machine Learning
The Ames Data Set: Sales Price Tackled With Diverse Models

Leave a Comment

No comments found.

View Posts by Categories

All Posts 2399 posts
AI 7 posts
AI Agent 2 posts
AI-based hotel recommendation 1 posts
AIForGood 1 posts
Alumni 60 posts
Animated Maps 1 posts
APIs 41 posts
Artificial Intelligence 2 posts
Artificial Intelligence 2 posts
AWS 13 posts
Banking 1 posts
Big Data 50 posts
Branch Analysis 1 posts
Capstone 206 posts
Career Education 7 posts
CLIP 1 posts
Community 72 posts
Congestion Zone 1 posts
Content Recommendation 1 posts
Cosine SImilarity 1 posts
Data Analysis 5 posts
Data Engineering 1 posts
Data Engineering 3 posts
Data Science 7 posts
Data Science News and Sharing 73 posts
Data Visualization 324 posts
Events 5 posts
Featured 37 posts
Function calling 1 posts
FutureTech 1 posts
Generative AI 5 posts
Hadoop 13 posts
Image Classification 1 posts
Innovation 2 posts
Kmeans Cluster 1 posts
LLM 6 posts
Machine Learning 364 posts
Marketing 1 posts
Meetup 144 posts
MLOPs 1 posts
Model Deployment 1 posts
Nagamas69 1 posts
NLP 1 posts
OpenAI 5 posts
OpenNYC Data 1 posts
pySpark 1 posts
Python 16 posts
Python 458 posts
Python data analysis 4 posts
Python Shiny 2 posts
R 404 posts
R Data Analysis 1 posts
R Shiny 560 posts
R Visualization 445 posts
RAG 1 posts
RoBERTa 1 posts
semantic rearch 2 posts
Spark 17 posts
SQL 1 posts
Streamlit 2 posts
Student Works 1687 posts
Tableau 12 posts
TensorFlow 3 posts
Traffic 1 posts
User Preference Modeling 1 posts
Vector database 2 posts
Web Scraping 483 posts
wukong138 1 posts

Our Recent Popular Posts

AI 4 AI: ChatGPT Unifies My Blog Posts
by Vinod Chugani
Dec 18, 2022
Meet Your Machine Learning Mentors: Kyle Gallatin
by Vivian Zhang
Nov 4, 2020
NICU Admissions and CCHD: Predicting Based on Data Analysis
by Paul Lee, Aron Berke, Bee Kim, Bettina Meier and Ira Villar
Jan 7, 2020

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day ChatGPT citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay football gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income industry Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI

NYC Data Science Academy

NYC Data Science Academy teaches data science, trains companies and their employees to better profit from data, excels at big data project consulting, and connects trained Data Scientists to our industry.

NYC Data Science Academy is licensed by New York State Education Department.

Get detailed curriculum information about our
amazing bootcamp!

Please enter a valid email address
Sign up completed. Thank you!

Offerings

  • HOME
  • DATA SCIENCE BOOTCAMP
  • ONLINE DATA SCIENCE BOOTCAMP
  • Professional Development Courses
  • CORPORATE OFFERINGS
  • HIRING PARTNERS
  • About

  • About Us
  • Alumni
  • Blog
  • FAQ
  • Contact Us
  • Refund Policy
  • Join Us
  • SOCIAL MEDIA

    ยฉ 2025 NYC Data Science Academy
    All rights reserved. | Site Map
    Privacy Policy | Terms of Service
    Bootcamp Application