{ "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": 2, "metadata": { "ExecuteTime": { "end_time": "2022-10-17T12:45:06.214273Z", "start_time": "2022-10-17T12:45:03.676498Z" } }, "outputs": [], "source": [ "import sys\n", "\n", "# Optional dependencies\n", "import matplotlib as mpl\n", "import matplotlib.pyplot as plt\n", "\n", "import commonnn\n", "from commonnn import cluster" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2022-10-17T12:45:06.222621Z", "start_time": "2022-10-17T12:45:06.217513Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Python: 3.9.0 | packaged by conda-forge | (default, Nov 26 2020, 07:57:39) [GCC 9.3.0]\n", "Packages:\n", " matplotlib: 3.9.4\n", " commonnn: 0.0.3\n" ] } ], "source": [ "# Version information\n", "print(\"Python: \", *sys.version.split(\"\\n\"))\n", "\n", "print(\"Packages:\")\n", "for package in [mpl, commonnn]:\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": 5, "metadata": { "ExecuteTime": { "end_time": "2022-10-17T12:45:06.240695Z", "start_time": "2022-10-17T12:45:06.236437Z" } }, "outputs": [], "source": [ "# Matplotlib configuration\n", "mpl.rc_file(\"../../matplotlibrc\", use_default_template=False)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2022-10-17T12:45:06.247485Z", "start_time": "2022-10-17T12:45:06.243108Z" } }, "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 `commonnn.cluster` main module provides a `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 a Molecular Dynamics context). As a guiding principle, a `Clustering` object is always associated with one particular data set (possibly hierarchically decomposed) and allows varying cluster parameters." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", " | n_points | \n", "radius_cutoff | \n", "similarity_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.000019 | \n", "
1 | \n", "12 | \n", "1.5 | \n", "1 | \n", "<NA> | \n", "<NA> | \n", "2 | \n", "0.416667 | \n", "0.333333 | \n", "0.000015 | \n", "