exports Module
General export functions.
Functions
dot_export_pipeline
Exports a pipeline in DOT language. Relies on method <xref:nimbusml.pipeline.Pipeline.get_fit_info>.
The function shows intermediate columns between operators. Blue columns are left unchanged, yellow columns are either created or replaced.
import pandas
from nimbusml.linear_model import FastLinearRegressor
from nimbusml.feature_extraction.categorical import OneHotVectorizer
from nimbusml.preprocessing.normalization import MeanVarianceScaler
from nimbusml.preprocessing.schema import ColumnDropper
from nimbusml import Pipeline
from nimbusml.utils.exports import dot_export_pipeline
df = pandas.DataFrame(dict(education=['A', 'B', 'A', 'B', 'A'],
workclass=['X', 'X', 'Y', 'Y', 'Y'],
yy=[1.1, 2.2, 1.24, 3.4, 3.4]))
X = df.drop('yy', axis=1)
y = df['yy']
exp = Pipeline([
MeanVarianceScaler() << {'new_y': 'yy'},
OneHotVectorizer() << ['workclass', 'education'],
ColumnDropper() << 'yy',
FastLinearRegressor() << {'Feature': ['workclass',
'education'],
Role.Label: 'new_y'}
])
dot = dot_export_pipeline(exp, X, y)
print(doc)
img_export_pipeline uses this function to render the graph as an image.
dot_export_pipeline(pipeline, X, y=None, **params)
Parameters
Name | Description |
---|---|
pipeline
|
|
X
|
|
y
|
Default value: None
|
img_export_pipeline
Produces an image which represents the data and the pipelines steps. It converts the export returned by function dot_export_pipeline and returns a graph built by module graphviz.
import pandas
from nimbusml.linear_model import FastLinearRegressor
from nimbusml.feature_extraction.categorical import OneHotVectorizer
from nimbusml.preprocessing.normalization import MeanVarianceScaler
from nimbusml.preprocessing.schema import ColumnDropper
from nimbusml import Pipeline
from nimbusml.utils.exports import img_export_pipeline
df = pandas.DataFrame(dict(education=['A', 'B', 'A', 'B', 'A'],
workclass=['X', 'X', 'Y', 'Y', 'Y'],
yy=[1.1, 2.2, 1.24, 3.4, 3.4]))
X = df.drop('yy', axis=1)
y = df['yy']
exp = Pipeline([
MeanVarianceScaler() << {'new_y': 'yy'},
OneHotVectorizer() << ['workclass', 'education'],
ColumnDropper() << 'yy',
FastLinearRegressor() << {'Feature': ['workclass',
'education'],
Role.Label: 'new_y'}
])
img_export_pipeline(exp, X, y).render("mypipeline.png")
img_export_pipeline(pipeline, X, y=None, **params)
Parameters
Name | Description |
---|---|
pipeline
|
|
X
|
|
y
|
Default value: None
|