Skip to content

Commit

Permalink
final commit pre-tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
Giovanni Petri committed Jan 25, 2019
1 parent c83f279 commit 8201adb
Show file tree
Hide file tree
Showing 10 changed files with 2,208 additions and 2 deletions.
91 changes: 91 additions & 0 deletions notebooks/01_kMapper_basics.ipynb
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
}
Loading

0 comments on commit 8201adb

Please sign in to comment.