Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scikit-learn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ian Johnson
scikit-learn
Commits
5c7f3fb9
Commit
5c7f3fb9
authored
14 years ago
by
Mathieu Blondel
Browse files
Options
Downloads
Patches
Plain Diff
Added fit_transform() to pipeline.
parent
88a52a1b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scikits/learn/pipeline.py
+18
-4
18 additions, 4 deletions
scikits/learn/pipeline.py
with
18 additions
and
4 deletions
scikits/learn/pipeline.py
+
18
−
4
View file @
5c7f3fb9
...
...
@@ -33,16 +33,21 @@ class Pipeline(BaseEstimator):
fit:
Fit all the transforms one after the other and transform the
data, then fit the transformed data using the final estimator
fit_transform:
Fit all the transforms one after the other and transform the
data, then use fit_transform on transformed data using the final
estimator. Valid only if the final estimator implements
fit_transform.
predict:
Applie
d
transforms to the data, and the predict method of the
Applie
s
transforms to the data, and the predict method of the
final estimator. Valid only if the final estimator implements
predict.
transform:
Applie
d
transforms to the data, and the transform method of the
Applie
s
transforms to the data, and the transform method of the
final estimator. Valid only if the final estimator implements
transform.
score:
Applie
d
transforms to the data, and the score method of the
Applie
s
transforms to the data, and the score method of the
final estimator. Valid only if the final estimator implements
score.
...
...
@@ -120,7 +125,8 @@ class Pipeline(BaseEstimator):
# Estimator interface
#---------------------------------------------------------------------------
def
fit
(
self
,
X
,
y
=
None
,
**
params
):
def
_pre_transform
(
self
,
X
,
y
=
None
,
**
params
):
self
.
_set_params
(
**
params
)
Xt
=
X
for
name
,
transform
in
self
.
steps
[:
-
1
]:
...
...
@@ -128,9 +134,17 @@ class Pipeline(BaseEstimator):
Xt
=
transform
.
fit_transform
(
Xt
,
y
)
else
:
Xt
=
transform
.
fit
(
Xt
,
y
).
transform
(
Xt
)
return
Xt
def
fit
(
self
,
X
,
y
=
None
,
**
params
):
Xt
=
self
.
_pre_transform
(
X
,
y
,
**
params
)
self
.
steps
[
-
1
][
-
1
].
fit
(
Xt
,
y
)
return
self
def
fit_transform
(
self
,
X
,
y
=
None
,
**
params
):
Xt
=
self
.
_pre_transform
(
X
,
y
,
**
params
)
return
self
.
steps
[
-
1
][
-
1
].
fit_transform
(
Xt
,
y
)
def
predict
(
self
,
X
):
Xt
=
X
for
name
,
transform
in
self
.
steps
[:
-
1
]:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment