简体   繁体   中英

Where does class Transformers come from?

All show the use of this import

from sklearn.pipeline import Pipeline, FeatureUnion
from Transformers import TextTransformer

When I run it

ModuleNotFoundError Traceback (most recent call last) <ipython-input-6-1f277e1659bb> in <module>() 1 from sklearn.pipeline import Pipeline, FeatureUnion ----> 2 from Transformers import TextTransformer ModuleNotFoundError: No module named 'Transformers

Googling only led me to the links I've already posted.
Where does Transformers come from?


import sklearn
import sys
print(sklearn.__version__)
print(sys.version)

0.18.1
3.6.0 |Anaconda 4.3.1 (x86_64)| (default, Dec 23 2016, 13:19:00) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]

What about

pip install transformers

The error message ModuleNotFoundError: No module named 'Transformers is because transformers is not installed most likely.

从您提供的第二个链接来看,它似乎是一个名为Transformers.py的用户定义文件,其中包含类TextTransformer

Yes, I am pretty sure it is some custom file containing transformers, which are very likely inheriting from TransformerMixin ( http://scikit-learn.org/stable/modules/generated/sklearn.base.TransformerMixin.html ).

This allows, as shown in the linked questions, to include custom data transformations in a pipeline. For an intro I recommend this great blog post, where also custom transformers are shown: http://zacstewart.com/2014/08/05/pipelines-of-featureunions-of-pipelines.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM