Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

function transformer and feature union

# Import FunctionTransformer
from sklearn.preprocessing import FunctionTransformer

# Obtain the text data: get_text_data
get_text_data = FunctionTransformer(lambda x: x['text'], validate=False)

# Obtain the numeric data: get_numeric_data
get_numeric_data = FunctionTransformer(lambda x: x[['numeric', 'with_missing']], validate=False)

# Fit and transform the text data: just_text_data
just_text_data = get_text_data.fit_transform(sample_df)

# Fit and transform the numeric data: just_numeric_data
just_numeric_data = get_numeric_data.fit_transform(sample_df)

# Print head to check results
print('Text Data')
print(just_text_data.head())
print('
Numeric Data')
print(just_numeric_data.head())
Comment

PREVIOUS NEXT
Code Example
Python :: fastai read data from image folders 
Python :: fizzbuzz algorithm 
Python :: traint test split on column id 
Python :: how to break out of while loop when the user hit ctrl + d python 
Python :: Customizing multiple plots in the same figure 
Python :: django admin difference between superuser and staff 
Python :: website screenshot python compress image 
Python :: python typing namedtuple 
Python :: python data manipulation_16.06.2022 
Python :: real numbers python 
Python :: update value in xml python 
Python :: map column dataframe python 
Python :: Create list element using algebraic operation 
Python :: filetype: env "DB_PASSWORD" 
Python :: find mean of list python 
Python :: how to choose a random key from a dictionary in python 
Python :: como tornar uma string numa lista 
Python :: create canvas for signature flutter 
Python :: multi line cooment in python 
Python :: python selenium canvas fingerprinting 
Python :: why static kwyword not in python 
Python :: na.kalman in python 
Python :: visual studio code python indent shortcut 
Python :: monoamine oxidase inhibitor 
Python :: two labels on one axis python 
Python :: assign multiple vabies in one line 
Python :: how to sort a list randomly in python 
Python :: torch print floating precision 
Python :: how to make commas appear in integers in terminal python 
Python :: fill misssing values using sklrean 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =