{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Import needed libraries" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import mapper\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Step 1: Input data
\n", " Load the circle data set, circle = \$x^2 + y^2 = 1\$" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "data = mapper.shapes.circle(samples=1000)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Run the following without modification, just preprocessing some variables" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Preprocessing\n", "point_labels = None\n", "mask = None\n", "Gauss_density = mapper.filters.Gauss_density\n", "kNN_distance = mapper.filters.kNN_distance\n", "crop = mapper.crop\n", "# Custom preprocessing code\n", "\n", "# End custom preprocessing code\n", "data, point_labels = mapper.mask_data(data, mask, point_labels)\n" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Step 2: Choose metric
\n", "Below we are choosing to use the Euclidean metric" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "intrinsic_metric = False\n", "if intrinsic_metric:\n", " is_vector_data = data.ndim != 1\n", " if is_vector_data:\n", " metric = Euclidean # here we choose Euclidean metric\n", " if metric != 'Euclidean':\n", " raise ValueError('Not implemented')\n", " data = mapper.metric.intrinsic_metric(data, k=1, eps=1.0)\n", "is_vector_data = data.ndim != 1\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Step 3: Choose Filter function