forked from anazalea/pySankey
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates example section in the Readme (#48)
* removes jupyter artifacts * adds extended description of the fruits example and clarifies use for larger datasets * updates status badge and gives ci workflow the name build to match with travis * moved plot creation script to .github as it has nothing to do with the package and is only used for the repo * simplifies data aggregation in the preprocessing example * removes old png file from package folder (the ones still used can be found in the .github/ folder Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
- Loading branch information
1 parent
c1bc4fb
commit 14a58b1
Showing
10 changed files
with
123 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import matplotlib.pyplot as plt | ||
import pandas as pd | ||
from pysankey import sankey | ||
|
||
df = pd.read_csv("../pysankey/fruits.txt", sep=" ", names=["true", "predicted"]) | ||
|
||
colorDict = { | ||
"apple": "#f71b1b", | ||
"blueberry": "#1b7ef7", | ||
"banana": "#f3f71b", | ||
"lime": "#12e23f", | ||
"orange": "#f78c1b", | ||
"kiwi": "#9BD937", | ||
} | ||
|
||
labels = list(colorDict.keys()) | ||
leftLabels = [label for label in labels if label in df["true"].values] | ||
rightLabels = [label for label in labels if label in df["predicted"].values] | ||
|
||
ax = sankey( | ||
left=df["true"], | ||
right=df["predicted"], | ||
leftLabels=leftLabels, | ||
rightLabels=rightLabels, | ||
colorDict=colorDict, | ||
aspect=20, | ||
fontsize=12, | ||
) | ||
|
||
plt.savefig("img/fruits.png") | ||
plt.close() | ||
|
||
|
||
# This calculates how often the different combinations of "true" and | ||
# "predicted" co-occure | ||
df = df.groupby(["true", "predicted"]).size().reset_index() | ||
weights = df[0].astype(float) | ||
|
||
|
||
ax = sankey( | ||
left=df["true"], | ||
right=df["predicted"], | ||
rightWeight=weights, | ||
leftWeight=weights, | ||
leftLabels=leftLabels, | ||
rightLabels=rightLabels, | ||
colorDict=colorDict, | ||
aspect=20, | ||
fontsize=12, | ||
) | ||
|
||
|
||
plt.savefig("img/fruits_weighted.png") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Jupyter | ||
.ipynb_checkpoints/ | ||
|
||
#Eclipse/pydev | ||
.project | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.