Visualization tool for sklearn pipelines
Project description
A Python package that provides a convenient way to visualize Scikit-learn machine learning pipelines. It utilizes libraries such as NetworkX, Matplotlib, and Plotly to generate clear, interactive, and insightful visual representations of your ML pipelines
Installation
You can install Visualize Pipeline using pip:
pip install visualize-pipeline
Dependencies
Visualize Pipeline depends on the following Python libraries:
--NetworkX --Matplotlib --Plotly --Scikit-Learn
You can install these dependencies using pip:
pip install networkx matplotlib plotly scikit-learn
Usage
Basic Example
Here's a basic example of how to use Visualize Pipeline:
from visualize_pipeline import visualize_pipeline
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
# Create a simple pipeline
pipe = Pipeline([
('scale', StandardScaler()),
('clf', LogisticRegression())
])
# Visualize the pipeline
graph = visualize_pipeline(pipe)
# Save the graph to an HTML file
convert_graph_to_plot(graph, 'pipeline.html')
This will create an interactive HTML file pipeline.html with the visualization of your pipeline.
Example in Google Colab with a complex pipeline
pipe = Pipeline(steps=[
('scaler', StandardScaler()),
('classifier', LogisticRegression())])
preprocessor = ColumnTransformer(
transformers=[
('num', StandardScaler(), [0, 1]),
('cat', OneHotEncoder(), [2, 3])])
complex_pipeline = Pipeline(steps=[
('preprocessor', preprocessor),
('classifier', pipe)])
graph = visualize_pipeline(complex_pipeline)
# fig = convert_graph_to_plot(graph)
# Convert the graph to a plotly figure
fig = convert_graph_to_plot(graph, filename='pipeline.html')
from IPython.display import HTML
# Display the HTML file
display(HTML('pipeline.html'))
Visual Example
Scope
Visualize Pipeline currently supports Scikit-Learn's Pipeline, FeatureUnion, and ColumnTransformer classes. It can visualize pipelines with nested pipelines and feature unions/column transformers.
The package is meant for visualizing the structure of your pipelines and does not show the actual data flow or transformations in the pipeline.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pipeline_viz-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8eee41969a8b37b150c8118e3daf2aca626bf327b17bbb2ea123654999f9d044 |
|
MD5 | 06c1f87309155443c40c00236b5bfe6f |
|
BLAKE2b-256 | 65922069aee8a2eff5af53bf1ce0a364b441b739f5029bfa8eeae1bc9d90f5f6 |