{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Basic usage" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Go to:\n", " \n", " - [Notebook configuration](basic_usage.ipynb#Notebook-configuration)\n", " - [Getting started](basic_usage.ipynb#Getting-started)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Notebook configuration" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2021-10-01T09:13:28.523135Z", "start_time": "2021-10-01T09:13:26.427353Z" } }, "outputs": [], "source": [ "import sys\n", "\n", "# Optional dependencies\n", "import matplotlib as mpl\n", "import matplotlib.pyplot as plt\n", "\n", "import cnnclustering\n", "from cnnclustering import cluster" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Print Python and package version information:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2021-10-01T09:13:28.530534Z", "start_time": "2021-10-01T09:13:28.525553Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Python: 3.8.8 (default, Mar 11 2021, 08:58:19) [GCC 8.3.0]\n", "Packages:\n", " matplotlib: 3.3.4\n", " cnnclustering: 0.4.3\n" ] } ], "source": [ "# Version information\n", "print(\"Python: \", *sys.version.split(\"\\n\"))\n", "\n", "print(\"Packages:\")\n", "for package in [mpl, cnnclustering]:\n", " print(f\" {package.__name__}: {package.__version__}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We use [Matplotlib](https://matplotlib.org/) to create plots. The `matplotlibrc` file in the root directory of the `CommonNNClustering` repository is used to customize the appearance of the plots." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2021-10-01T09:13:28.540353Z", "start_time": "2021-10-01T09:13:28.532580Z" } }, "outputs": [], "source": [ "# Matplotlib configuration\n", "mpl.rc_file(\n", " \"../../matplotlibrc\",\n", " use_default_template=False\n", ")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2021-10-01T09:13:28.547540Z", "start_time": "2021-10-01T09:13:28.542440Z" } }, "outputs": [], "source": [ "# Axis property defaults for the plots\n", "ax_props = {\n", " \"aspect\": \"equal\"\n", "}\n", "\n", "# Property defaults for plotted lines\n", "dot_props = {\n", " \"marker\": \"o\",\n", " \"markeredgecolor\": \"k\"\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Getting started" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `cnnclustering.cluster` main module provides the `Clustering` class. An instance of this class is used to bundle input data (e.g. data points) with cluster results (cluster label assignments) alongside the clustering method (a fitter with a set of building blocks) and convenience functions for further analysis (not only in an Molecular Dynamics context). As a guiding principle, a `Clustering` object is always associated with one particular data set and allows varying cluster parameters." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", " | n_points | \n", "radius_cutoff | \n", "cnn_cutoff | \n", "member_cutoff | \n", "max_clusters | \n", "n_clusters | \n", "ratio_largest | \n", "ratio_noise | \n", "execution_time | \n", "
---|---|---|---|---|---|---|---|---|---|
0 | \n", "12 | \n", "2.0 | \n", "1 | \n", "<NA> | \n", "<NA> | \n", "2 | \n", "0.583333 | \n", "0.166667 | \n", "0.000038 | \n", "
1 | \n", "12 | \n", "1.5 | \n", "1 | \n", "<NA> | \n", "<NA> | \n", "2 | \n", "0.416667 | \n", "0.333333 | \n", "0.000029 | \n", "