How to Combine Textual and Numerical Features for Machine Learning in Python

#artificialintelligence 

When you have a training dataframe which contains both number fields and text and apply a simple model from scikit-lean or some equivalent, one of the easiest way is to use sklearn.pipeline.FeatureUnion in Pipeline. The following example assumes X_train to be a pandas DataFrame, which consists of many number fields with a text field at the last column. Then you can create a FunctionTransformer to separate the number columns and the text column. The functions passed to this FunctionTransformer can be anything, so modify this according to your input data. Here it simply return the last column as textual feature and the rest as numerical features.

Duplicate Docs Excel Report

Title
None found

Similar Docs  Excel Report  more

TitleSimilaritySource
None found