semvec/pypi-packages huggingface dataset:
finch-clust 0.2.2
FINCH - First Integer Neighbor Clustering Hierarchy: A parameter-free fast clustering algorithm.
Requires Python: >=3.8

# First Integer Neighbor Clustering Hierarchy (FINCH) Algorithm
![alt text](https://raw.githubusercontent.com/ssarfraz/FINCH-Clustering/master/data/toy_data_vis.jpg)

FINCH is a parameter-free fast and scalable clustering algorithm. it stands out for its speed and clustering quality.
 The algorithm is described in our paper **Efficient Parameter-free Clustering Using First Neighbor Relations** published in CVPR 2019 . [Read Paper](http://openaccess.thecvf.com/content_CVPR_2019/papers/Sarfraz_Efficient_Parameter-Free_Clustering_Using_First_Neighbor_Relations_CVPR_2019_paper.pdf).


## Installation
The project is available in PyPI. To install run:

`pip install finch-clust`  

**Optional**.  Install [PyNNDescent](https://github.com/lmcinnes/pynndescent) to get first neighbours for large data

To install finch with pynndescent run:

`pip install "finch-clust[ann]"`  


## Usage:

typically you would run: 
``` 
from finch import FINCH
c, num_clust, req_c = FINCH(data)

```
You can set options e.g., required number of cluster or distance etc,

```
c, num_clust, req_c = FINCH(data, initial_rank=None, req_clust=None, distance='cosine', verbose=True)
```

For more details on meaning of input arguments check README in [finch directory](finch/README.md). 

**Matlab usage**

A minimal correponding Matlab implementation is provided in the [matlab directory](https://github.com/ssarfraz/FINCH-Clustering/tree/master/matlab/README.md).

## Demos

The following demo notebooks are available to see the usage in clustering a dataset.

1. [Basic usage on 2D toy data](https://github.com/ssarfraz/FINCH-Clustering/blob/master/notebooks/Basic_usage.ipynb)
2. [Clustering STL-10 dataset with FINCH](https://github.com/ssarfraz/FINCH-Clustering/blob/master/notebooks/Clustering_with_FINCH.ipynb)


## Relevant tools built on FINCH
- [h-nne](https://github.com/koulakis/h-nne): See also our [h-nne](https://github.com/koulakis/h-nne) method which uses FINCH for fast dimenionality reduction  and visualization applications.

- [TW-FINCH](https://github.com/ssarfraz/FINCH-Clustering/tree/master/TW-FINCH): Also see our [TW-FINCH](https://github.com/ssarfraz/FINCH-Clustering/tree/master/TW-FINCH) variant which is useful for video segmentation.
## Citation 
```
@inproceedings{finch,
    author    = {M. Saquib Sarfraz and Vivek Sharma and Rainer Stiefelhagen}, 
    title     = {Efficient Parameter-free Clustering Using First Neighbor Relations}, 
    booktitle = {Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
    pages = {8934--8943}
    year  = {2019}
}

```
narsche 0.1.3
Computing schematicity of autobiographical narratives
Requires Python: >=3.9


# Measuring narrative schematicity

[![codecov](https://codecov.io/github/kinleyid/narsche/graph/badge.svg?token=EHCYVTZWCE)](https://codecov.io/github/kinleyid/narsche)

Methods from the paper "Computational Tools for Quantifying Schemas in Autobiographical Narratives".

## Installation

```
pip install narsche
```

`narsche` depends on `networkx` (for network models), `SpaCy` (for tokenization), and `wordfreq` for automated topic identification. Additionally, one of `SpaCy`'s models must be downloaded for `SpaCy`-based tokenization:

```
python -m spacy download en_core_web_sm
```

## Usage

### Loading and saving models

A text file of word vectors can be read using the `read_vectors()` function:

```python
vec_mod = narsche.read_vectors('/path/to/vectors.txt')
```

This produces a vector model. Initializing a network model requires first loading a `networkx.Graph` object:

```python
import networkx as nx

graph = nx.load('/path/to/graph')
net_mod = narsche.NetworkModel(graph)
```

Models can be saved using the `save()` method and loaded using the `load()` class method:

```python
net_mod.save('network.mod')
net_mod = narsche.NetworkModel.load('network.mod')

vec_mod.save('vector.mod')
vec_mod = narsche.VectorModel.load('vector.mod')
```

These are just wrappers around `pickle.[load/dump]`. Any extension can be used.

### Tokenizing narratives

Before schematicity can be computed, narratives must be tokenized, i.e., converted to a list of tokens. For this, there is a `Tokenizer()` class that relies on `SpaCy`:

```python
txt = 'I sat on the sofa in my living room with a lamp' # Example text
tokenizer = narsche.Tokenizer('en_core_web_sm') # Initialize tokenizer
words = tokenizer.tokenize(txt) # Tokenize words
words = vec_mod.keep_known(words) # Use only those words that are in the model
```

### Computing schematicity

Given a model and a set of tokens (and possibly a topic word), schematicity can be computed using the `schematicity()` function:

```python
topic = narsche.identify_topic(words) # Identify the topic
# Compute schematicity
narsche.schematicity(
	words=words,
	model=mod,
	method='on-topic-ppn', # or topic-relatedness, pairwise-relatedness, or component-size
	topic=topic)
```

See the documentation of the `schematicity()` function for kewords required by other methods.