Einführung in NLP-Feature-Engineering

Feature Engineering für NLP in Python

Rounak Banik

Data Scientist

Numerische Daten

Iris-Datensatz

Kelchlänge Kelchbreite Blütenblattlänge Blütenblattbreite Klasse
6.3 2.9 5.6 1.8 Iris-virginica
4.9 3.0 1.4 0.2 Iris-setosa
5.6 2.9 3.6 1.3 Iris-versicolor
6.0 2.7 5.1 1.6 Iris-versicolor
7.2 3.6 6.1 2.5 Iris-virginica
Feature Engineering für NLP in Python

One-Hot-Encoding

Geschlecht
weiblich
männlich
weiblich
männlich
weiblich
...
Feature Engineering für NLP in Python

One-Hot-Encoding

Geschlecht One-Hot-Encoding
weiblich
männlich
weiblich
männlich
weiblich
... ...
Feature Engineering für NLP in Python

One-Hot-Encoding

Geschlecht One-Hot-Encoding sex_female sex_male
weiblich 1 0
männlich 0 1
weiblich 1 0
männlich 0 1
weiblich 1 0
... ... ... ...
Feature Engineering für NLP in Python

One-Hot-Encoding mit pandas

# Import the pandas library
import pandas as pd

# Perform one-hot encoding on the 'sex' feature of df df = pd.get_dummies(df, columns=['sex'])
Feature Engineering für NLP in Python

Textdaten

Datensatz Filmrezensionen

Rezension Klasse
This movie is for dog lovers. A very poignant... positive
The movie is forgettable. The plot lacked... negative
A truly amazing movie about dogs. A gripping... positive
Feature Engineering für NLP in Python

Textvorverarbeitung

  • In Kleinbuchstaben umwandeln
    • Beispiel: Reduction zu reduction
  • Auf Grundform bringen
    • Beispiel: reduction zu reduce
Feature Engineering für NLP in Python

Vektorisierung

Rezension Klasse
This movie is for dog lovers. A very poignant... positive
The movie is forgettable. The plot lacked... negative
A truly amazing movie about dogs. A gripping... positive
Feature Engineering für NLP in Python

Vektorisierung

0 1 2 ... n Klasse
0.03 0.71 0.00 ... 0.22 positive
0.45 0.00 0.03 ... 0.19 negative
0.14 0.18 0.00 ... 0.45 positive
Feature Engineering für NLP in Python

Einfache Features

  • Anzahl der Wörter
  • Anzahl der Zeichen
  • Durchschnittliche Wortlänge
  • Tweets

Tweet von Silverado Records

Feature Engineering für NLP in Python

POS-Tagging

Wort POS
I Pronomen
have Verb
a Artikel
dog Substantiv
Feature Engineering für NLP in Python

Named Entity Recognition

  • Bezieht sich das Substantiv auf Person, Organisation oder Land?

Eine Person, eine Landesflagge und das TED-Logo

Substantiv NER
Brian Person
DataCamp Organisation
Feature Engineering für NLP in Python

Behandelte Konzepte

  • Textvorverarbeitung
  • Einfache Features
  • Wort-Features
  • Vektorisierung
Feature Engineering für NLP in Python

Lass uns üben!

Feature Engineering für NLP in Python

Preparing Video For Download...