“Etikettencodierung” Code-Antworten

Etikettencodierung

from sklearn.preprocessing import LabelEncoder

le = LabelEncoder()
companydata.ShelveLoc = le.fit_transform(companydata.ShelveLoc)
Condemned Cowfish

Etikettencodierung in Python

##We apply Label Encoding on black Friday dataset on the target column which is Species. It contains three species Iris-setosa, Iris-versicolor, Iris-virginica. 

# Import libraries
import numpy as np
import pandas as pd
 
# Importing dataset
df = pd.read_csv('../../data/blackFriday.csv')

#Cheking out the unique values in your dataset
df['Age'].unique()

# Import label encoder
from sklearn import preprocessing
 
# label_encoder object knows how to understand word labels.
label_encoder = preprocessing.LabelEncoder()
 
# Encode labels in column 'Age'.
df['Age']= label_encoder.fit_transform(df['Age'])
 
df['Age'].unique()
DON-PECH

So verwenden Sie die Etikettencodierung in Python


obj_df["body_style"] = obj_df["body_style"].astype('category')
obj_df.dtypes

obj_df["body_style_cat"] = obj_df["body_style"].cat.codes
obj_df.head()
Drab Dove

Ähnliche Antworten wie “Etikettencodierung”

Fragen ähnlich wie “Etikettencodierung”

Weitere verwandte Antworten zu “Etikettencodierung” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen