Menu

Combining Text Features

Combining Text Features

Instead of analyzing each feature separately, we combine the selected text columns into a single feature. This gives the recommendation model more information when comparing news articles.

Code

news['content'] = (
news['headline'] + " " +
news['short_description'] + " " +
news['category']
)

Explanation

The new content column contains the combined textual information from the headline, short description, and category.

This combined text will be converted into numerical features in the next step.

Output

A new feature named content is successfully added to the dataset.