Browse Source

formatting: md formating and typo corrections

pull/20/head
lee 3 years ago
parent
commit
93073cb888
  1. 111
      one_md_per_day_format/projects/project2/project2.md
  2. 10
      one_md_per_day_format/projects/project2/project2_correction.md

111
one_md_per_day_format/projects/project2/project2.md

@ -1,102 +1,101 @@
# NLP-enriched News Intelligence platform
The goal of this project is to build an NLP-enriched News Intelligence platform. News analysis is a trending and important topic. The analysts get their information from the news and the amount of available information is limitless. Having a platfrom that helps to detect the relevant information is definitely valuable.
The goal of this project is to build an NLP-enriched News Intelligence platform. News analysis is a trending and important topic. The analysts get their information from the news and the amount of available information is limitless. Having a platform that helps to detect the relevant information is definitely valuable.
The platform connects to a news data source, detects the entities, detects the topic of the article, analyse the sentiment and ...
The platform connects to a news data source, detects the entities, detects the topic of the article, analyse the sentiment and ...
## Scrapper
## Scrapper
News data source:
News data source:
- Find a news website that is easy to scrap. I could have chosen the website but the news' websites change their scraping policy frequently.
- Find a news website that is easy to scrap. I could have chosen the website but the news' websites change their scraping policy frequently.
- Store it:
- File system per day:
- URL, date unique id
- headline
- body of the article
- SQL database (optional)
- Store it:
- File system per day:
- URL, date unique id
- headline
- body of the article
- SQL database (optional)
from the last week otherwise the volume may be to high
TODO Link: scrape in python
from the last week otherwise the volume may be to high
TODO Link: scrape in python
## NLP engine
## NLP engine
In production architectures, the NLP engine delivers a live output based on the news that are delivered in a live stream data by the scrapper. However, it required advanced Python skills that are not a pre-requisite for the AI branch.
To simplify this step the scrapper and the NLP engine are used independently in the project. The scrapper fetches the news and store them in the data structure (either a file system or a SQL database) and then, the NLP engine runs on the stored data.
In production architectures, the NLP engine delivers a live output based on the news that are delivered in a live stream data by the scrapper. However, it required advanced Python skills that are not a pre-requisite for the AI branch.
To simplify this step the scrapper and the NLP engine are used independently in the project. The scrapper fetches the news and store them in the data structure (either the file systeme or the SQL database) and then, the NLP engine runs on the stored data.
Here is how the NLP engine should process the news:
Here how the NLP engine should process the news:
### **1. Entities detection:**
### 1. Entities detection:
The goal is to detect all the entities in the document (headline and body). The type of entity we focus on is `ORG`. This corresponds to companies and organizations. This information should be stored.
The goal is to detect all the entities in the document (headline and body). The type of entity we focus on is `ORG`. This corresponds to companies and organisations. This information should be stored.
- Detect all companies using SpaCy NER on the body of the text.
- Detect all companies using SpaCy NER on the body of the text.
https://towardsdatascience.com/named-entity-recognition-with-nltk-and-spacy-8c4a7d88e7da
### 2. Topic detection:
### **2. Topic detection:**
The goal is to detect what the article is dealing with: Tech, Sport, Business, Entertainment or Politics. To do so, a labelled dataset is provided. From this dataset, build a classifier that learns to detect the right topic in the article. The trained model should be stored as `topic_classifier.pkl`.
The goal is to detect what the article is dealing with: Tech, Sport, Business, Entertainment or Politics. To do so, a labelled dataset is provided. From this dataset, build a classifier that learns to detect the right topic in the article. The trained model should be stored as `topic_classifier.pkl`.
Save the plot of learning curves (`learning_curves.png`) in `results` to prove that the model is trained correctly and not overfitted.
Save the plot of learning curves (`learning_curves.png`) in `results` to prove that the model is trained correctly and not overfitted.
- Learning constraints: **Score on test: > 95%**
- **Optional**: If you want to train a news' topic classifier based on a more challenging dataset, you can use the following which based on 200k news headlines. https://www.kaggle.com/rmisra/news-category-dataset.
- **Optional**: If you want to train a news' topic classifier based on a more challenging dataset, you can use the [kaggle](https://www.kaggle.com/rmisra/news-category-dataset) which is based on 200k news headlines.
### **3. Sentiment analysis:**
The goal is to detect the sentiment of the news articles. To do so, use a pre-trained sentiment model. I suggest to use: NLTK.
### 3. Sentiment analysis:
There are 3 reasons for which we use a pre-trained model:
The goal is to detect the sentiment of the news articles. To do so, use a pre-trained sentiment model. I suggest to use: NLTK.
There are 3 reasons for which we use a pre-trained model:
1. As a Data Scientist, you should learn to use a pre-trained model. There are so many models available and trained that sometimes you don't need to train one from scratch.
1. As a Data Scientist, you should learn to use a pre-trained model. There are so many models available and trained that sometimes you don't need to train one from scratch.
2. Labelled news data for sentiment analysis are very expensive. Companies as SESAMm provide this kind of services.
3. You already know how to train a sentiment analysis classifier ;-)
3. You already know how to train a sentiment analysis classifier ;-)
### **4. Scandal detection**
### 4. Scandal detection
The goal is to detect environmental disaster for the detected companies. Here is the methodology that should be used:
The goal is to detect environmental disaster for the detected companies. Here is the methodology that should be used:
- Define keywords that correspond to environmental disaster that may be caused by companies: pollution, deforestation etc ... Here is an example of disaster we want to detect: https://en.wikipedia.org/wiki/MV_Erika. Pay attention to not use ambigous words that make sense in the context of an environmental disaster but also in another context. This would lead to detect a false positive natural disaster.
- Define keywords that correspond to environmental disaster that may be caused by companies: pollution, deforestation etc ... Here is an example of disaster we want to detect: https://en.wikipedia.org/wiki/MV_Erika. Pay attention do not use ambiguous words that make sense in the context of an environmental disaster but also in another context. This would lead to detect a false positive natural disaster.
- Compute the embeddings of the keywords.
- Compute the embeddings of the keywords.
- Compute the distance between the embeddings of the keywords and all sentences that contain an entity.
- Compute the distance between the embeddings of the keywords and all sentences that contain an entity.
- Flag the top 10 articles.
### 5. Source analysis (optional)
### **5. Source analysis (optional)**
The goal is to show insights about the news' source you scrapped.
The goal is to show insights about the news' source you scrapped.
This requires to scrap data on at least 5 days (a week ideally). Save the plots in the `results` folder.
Here are examples of insights:
- Per day:
- Proportion of topics per day
- Number of articles
- Number of companies mentionned
- Sentiment per day
- Proportion of topics per day
- Number of articles
- Number of companies mentioned
- Sentiment per day
- Per companies:
- Per companies:
- Companies mentionned the most
- Sentiment per companies
- Companies mentioned the most
- Sentiment per companies
## Deliverables
## Deliverables
The structure of the project is:
The structure of the project is:
```
project
│ README.md
│ environment.yml
│ environment.yml
└───data
│ │ topic_classification_data.csv
@ -107,12 +106,11 @@ project
|
|───nlp_engine
```
```
1. Run the scrapper until it fetches at least 300 articles
1. Run the scrapper until it fetches at least 300 articles
```prompt
```
python scrapper_news.py
1. scrapping <URL>
@ -127,10 +125,9 @@ python scrapper_news.py
```
2. Run on this 300 articles the nlp engine.
2. Run on this 300 articles the NLP engine.
```prompt
```
python nlp_enriched_news.py
Enriching <URL>:
@ -160,4 +157,4 @@ Computing embeddings and distance ...
Environmental scandal detected for <entity>
```
I strongly suggest to create a data scructure (dictionary for example) to save all the intermediate result. Then, a boolean argument `cache` fetched the intermediate results when they are already computed.
I strongly suggest to create a data structure (dictionary for example) to save all the intermediate result. Then, a boolean argument `cache` fetched the intermediate results when they are already computed.

10
one_md_per_day_format/projects/project2/project2_correction.md

@ -1,6 +1,6 @@
# NLP-enriched News Intelligence platform
This is the correction of the project 1: **NLP-enriched News Intelligence platform**.
This is the correction of the project 2: **NLP-enriched News Intelligence platform**.
## Deliverables
@ -19,19 +19,21 @@ project
|───nlp_engine
```
```
## Validation
The project is validated if:
### Scrapper
- There are at least 300 news articles stored in the file system or the database.
- Run the scrapper and fetch 3 documents. The scrapper is not expected to fetch n documents, you can stop it manually.
### NLP engine
- Run the nlp_engine on the 3 documents you fetched.
- Run the nlp_engine on the 3 documents you fetched.
### Topic classfier
- The **accuracy** on the test set is bigger then **95%**.
- The **accuracy** on the test set is bigger then **95%**.

Loading…
Cancel
Save