forked from lordgrilo/AML-days-TDA-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Giovanni Petri
committed
Jan 25, 2019
1 parent
c83f279
commit 8201adb
Showing
10 changed files
with
2,208 additions
and
2 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,91 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# kMapper basics" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import kmapper as km\n", | ||
"from kmapper import jupyter # Creates custom CSS full-size Jupyter screen" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Import the class\n", | ||
"import kmapper as km\n", | ||
"\n", | ||
"# Some sample data\n", | ||
"from sklearn import datasets\n", | ||
"data, labels = datasets.make_circles(n_samples=5000, noise=0.03, factor=0.3)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import matplotlib.pyplot as plt\n", | ||
"plt.scatter(data[:,0], data[:,1])\n", | ||
"plt.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Initialize\n", | ||
"mapper = km.KeplerMapper(verbose=1)\n", | ||
"\n", | ||
"# Fit to and transform the data\n", | ||
"projected_data = mapper.fit_transform(data, projection=[0,1]) # X-Y axis\n", | ||
"\n", | ||
"# Create dictionary called 'graph' with nodes, edges and meta-information\n", | ||
"graph = mapper.map(projected_data, data, nr_cubes=10)\n", | ||
"\n", | ||
"# Visualize it\n", | ||
"html = mapper.visualize(graph, path_html=\"make_circles_keplermapper_output.html\",\n", | ||
" title=\"make_circles(n_samples=5000, noise=0.03, factor=0.3)\")\n", | ||
"\n", | ||
"# Inline display\n", | ||
"# jupyter.display(path_html=\"http://mlwave.github.io/tda/word2vec-gender-bias.html\")\n", | ||
"jupyter.display(path_html=\"make_circles_keplermapper_output.html\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.