Transformers should implement fit() and transform()
up vote
0
down vote
favorite
I'm not seeing why this block of Pipeline code from sklearn won't work...cna anyone else figure out why I'm getting the error:
TypeError: All intermediate steps should be transformers and implement fit and transform.
pipeline = Pipeline([
('features', FeatureUnion([
('plots', Pipeline([
('selector', movies_encoded['Plot']),
('count_vector', CountVectorizer(tokenizer=nltk.word_tokenize)),
('tfidf', TfidfTransformer())
])),
('genres', Pipeline([
('selector', movies_encoded['Rating_Encoded']),
('labeler', LabelEncoder())
]))
])),
('neural_network', MLPClassifier(alpha=0.01, hidden_layer_sizes=(100, 100, ), early_stopping=False, verbose=True))
])
All of the estimators DO have either transform() or fit_transform() methods. Argh. Thanks!
scikit-learn
add a comment |
up vote
0
down vote
favorite
I'm not seeing why this block of Pipeline code from sklearn won't work...cna anyone else figure out why I'm getting the error:
TypeError: All intermediate steps should be transformers and implement fit and transform.
pipeline = Pipeline([
('features', FeatureUnion([
('plots', Pipeline([
('selector', movies_encoded['Plot']),
('count_vector', CountVectorizer(tokenizer=nltk.word_tokenize)),
('tfidf', TfidfTransformer())
])),
('genres', Pipeline([
('selector', movies_encoded['Rating_Encoded']),
('labeler', LabelEncoder())
]))
])),
('neural_network', MLPClassifier(alpha=0.01, hidden_layer_sizes=(100, 100, ), early_stopping=False, verbose=True))
])
All of the estimators DO have either transform() or fit_transform() methods. Argh. Thanks!
scikit-learn
do you put a pipeline inside a pipeline ? can you add some data and the full code ?
– seralouk
Nov 18 at 21:13
Thanks! The data would come from the 4 variables for train_test_split(), and bellow the code block above I'd call pipeline.fit(X_train, y_train). But oddly, it's not working, as it's saying the fit() and transform() aren't applicable on my estimators, which they clearly are.
– user2302078
Nov 18 at 22:56
The error is inmovies_encoded
. You cannot simply put data columns inside thePipeline
. You will need to pass the data only infit()
. Check this example on how to select a single column from data: scikit-learn.org/stable/auto_examples/preprocessing/…
– Vivek Kumar
Nov 19 at 6:58
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm not seeing why this block of Pipeline code from sklearn won't work...cna anyone else figure out why I'm getting the error:
TypeError: All intermediate steps should be transformers and implement fit and transform.
pipeline = Pipeline([
('features', FeatureUnion([
('plots', Pipeline([
('selector', movies_encoded['Plot']),
('count_vector', CountVectorizer(tokenizer=nltk.word_tokenize)),
('tfidf', TfidfTransformer())
])),
('genres', Pipeline([
('selector', movies_encoded['Rating_Encoded']),
('labeler', LabelEncoder())
]))
])),
('neural_network', MLPClassifier(alpha=0.01, hidden_layer_sizes=(100, 100, ), early_stopping=False, verbose=True))
])
All of the estimators DO have either transform() or fit_transform() methods. Argh. Thanks!
scikit-learn
I'm not seeing why this block of Pipeline code from sklearn won't work...cna anyone else figure out why I'm getting the error:
TypeError: All intermediate steps should be transformers and implement fit and transform.
pipeline = Pipeline([
('features', FeatureUnion([
('plots', Pipeline([
('selector', movies_encoded['Plot']),
('count_vector', CountVectorizer(tokenizer=nltk.word_tokenize)),
('tfidf', TfidfTransformer())
])),
('genres', Pipeline([
('selector', movies_encoded['Rating_Encoded']),
('labeler', LabelEncoder())
]))
])),
('neural_network', MLPClassifier(alpha=0.01, hidden_layer_sizes=(100, 100, ), early_stopping=False, verbose=True))
])
All of the estimators DO have either transform() or fit_transform() methods. Argh. Thanks!
scikit-learn
scikit-learn
asked Nov 18 at 2:36
user2302078
68110
68110
do you put a pipeline inside a pipeline ? can you add some data and the full code ?
– seralouk
Nov 18 at 21:13
Thanks! The data would come from the 4 variables for train_test_split(), and bellow the code block above I'd call pipeline.fit(X_train, y_train). But oddly, it's not working, as it's saying the fit() and transform() aren't applicable on my estimators, which they clearly are.
– user2302078
Nov 18 at 22:56
The error is inmovies_encoded
. You cannot simply put data columns inside thePipeline
. You will need to pass the data only infit()
. Check this example on how to select a single column from data: scikit-learn.org/stable/auto_examples/preprocessing/…
– Vivek Kumar
Nov 19 at 6:58
add a comment |
do you put a pipeline inside a pipeline ? can you add some data and the full code ?
– seralouk
Nov 18 at 21:13
Thanks! The data would come from the 4 variables for train_test_split(), and bellow the code block above I'd call pipeline.fit(X_train, y_train). But oddly, it's not working, as it's saying the fit() and transform() aren't applicable on my estimators, which they clearly are.
– user2302078
Nov 18 at 22:56
The error is inmovies_encoded
. You cannot simply put data columns inside thePipeline
. You will need to pass the data only infit()
. Check this example on how to select a single column from data: scikit-learn.org/stable/auto_examples/preprocessing/…
– Vivek Kumar
Nov 19 at 6:58
do you put a pipeline inside a pipeline ? can you add some data and the full code ?
– seralouk
Nov 18 at 21:13
do you put a pipeline inside a pipeline ? can you add some data and the full code ?
– seralouk
Nov 18 at 21:13
Thanks! The data would come from the 4 variables for train_test_split(), and bellow the code block above I'd call pipeline.fit(X_train, y_train). But oddly, it's not working, as it's saying the fit() and transform() aren't applicable on my estimators, which they clearly are.
– user2302078
Nov 18 at 22:56
Thanks! The data would come from the 4 variables for train_test_split(), and bellow the code block above I'd call pipeline.fit(X_train, y_train). But oddly, it's not working, as it's saying the fit() and transform() aren't applicable on my estimators, which they clearly are.
– user2302078
Nov 18 at 22:56
The error is in
movies_encoded
. You cannot simply put data columns inside the Pipeline
. You will need to pass the data only in fit()
. Check this example on how to select a single column from data: scikit-learn.org/stable/auto_examples/preprocessing/…– Vivek Kumar
Nov 19 at 6:58
The error is in
movies_encoded
. You cannot simply put data columns inside the Pipeline
. You will need to pass the data only in fit()
. Check this example on how to select a single column from data: scikit-learn.org/stable/auto_examples/preprocessing/…– Vivek Kumar
Nov 19 at 6:58
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357398%2ftransformers-should-implement-fit-and-transform%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
do you put a pipeline inside a pipeline ? can you add some data and the full code ?
– seralouk
Nov 18 at 21:13
Thanks! The data would come from the 4 variables for train_test_split(), and bellow the code block above I'd call pipeline.fit(X_train, y_train). But oddly, it's not working, as it's saying the fit() and transform() aren't applicable on my estimators, which they clearly are.
– user2302078
Nov 18 at 22:56
The error is in
movies_encoded
. You cannot simply put data columns inside thePipeline
. You will need to pass the data only infit()
. Check this example on how to select a single column from data: scikit-learn.org/stable/auto_examples/preprocessing/…– Vivek Kumar
Nov 19 at 6:58