Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This Version update will provide a fit_predict method #40

Merged
merged 9 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ repos:
- id: requirements-txt-fixer
- id: detect-aws-credentials
args: [--allow-missing-credentials]
- id: check-merge-conflict
- id: check-added-large-files
- id: check-case-conflict
- repo: https://github.com/psf/black
# workaround for black
# see: https://github.com/psf/black/issues/2493#issuecomment-1081987650
Expand All @@ -34,7 +37,7 @@ repos:
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.1
rev: v1.7.1
hooks:
- id: mypy
exclude: ^testing/resources/
Expand All @@ -44,7 +47,7 @@ repos:
- id: python-bandit-vulnerability-check
args: [--skip, "B101", --recursive, denseclus]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.5
rev: v0.1.6
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -64,7 +67,7 @@ repos:
hooks:
- id: pyupgrade
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
rev: 1.7.1
hooks:
- id: nbqa-pyupgrade
args: ["--py37-plus"]
Expand Down
35 changes: 31 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,42 @@ All preprocessing and extraction are done under the hood, just call fit and then
from denseclus import DenseClus
from denseclus.utils import make_dataframe

df = make_dataframe()

clf = DenseClus()
df = make_dataframe()
clf = DenseClus(df)
clf.fit(df)

print(clf.score())
scores = clf.score()
print(scores[0:10])
```


## Usage

### Prediction

DenseClus uses a `predict` method whhne `umap_combine_method` is set to `ensemble`.
Results are return in 2d array with the first part being the labels and the second part the probabilities.

```python
from denseclus import DenseClus
from denseclus.utils import make_dataframe

RANDOM_STATE = 10

df = make_dataframe(random_state=RANDOM_STATE)
train = df.sample(frac=0.8, random_state=RANDOM_STATE)
test = df.drop(train.index)
clf = DenseClus(random_state=RANDOM_STATE, umap_combine_method='ensemble')
clf.fit(train)

predictions = clf.predict(test)
print(predictions) # labels, probabilities
```


### On Combination Method

For a slower but more **stable** results select `intersection_union_mapper` to combine embedding layers via a third UMAP, which will provide equal weight to both numerics and categoriel columns. By default, you are setting the random seed which eliminates the ability for UMAP to run in parallel but will help circumevent some of [the randomness](https://umap-learn.readthedocs.io/en/latest/reproducibility.html) of the algorithm.

```python
Expand All @@ -51,10 +77,11 @@ clf = DenseClus(
)
```


### Advanced Usage

For advanced users, it's possible to select more fine-grained control of the underlying algorithms by passing
dictionaries into `DenseClus` class.
dictionaries into `DenseClus` class for either UMAP or HDBSCAN.

For example:
```python
Expand Down
Loading
Loading