Code Monkey home page Code Monkey logo

ljwolf / spenc Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 2.0 361 KB

Spatially-Encouraged Spectral Clustering, a method of discovering clusters/deriving labels for spatially-referenced data with attribute/labels attached.

Home Page: https://osf.io/jh483/

License: BSD 3-Clause "New" or "Revised" License

Jupyter Notebook 86.51% Python 13.49%
clustering cluster geography spatial-analysis spatial python3 python unsupervised-learning spatial-data-science geographic-data-science

spenc's People

Contributors

knaaptime avatar ljwolf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

spenc's Issues

typo in sklearn import 'calinski_harabaz_score'

In [1]: import sklearn

In [2]: sklearn.__version__
Out[2]: '0.23.1'

In [3]: sklearn.__file__
Out[3]: '/Users/knaaptime/anaconda3/envs/toss/lib/python3.8/site-packages/sklearn/__init__.py'

In [4]: import spenc
/Users/knaaptime/anaconda3/envs/toss/lib/python3.8/site-packages/sklearn/utils/deprecation.py:143: FutureWarning: The sklearn.cluster.spectral module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.cluster. Anything that cannot be imported from sklearn.cluster is now part of the private API.
  warnings.warn(message, FutureWarning)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-b10ad84211d1> in <module>
----> 1 import spenc

~/anaconda3/envs/toss/lib/python3.8/site-packages/spenc/__init__.py in <module>
----> 1 from .abstracts import SPENC

~/anaconda3/envs/toss/lib/python3.8/site-packages/spenc/abstracts.py in <module>
     15 from warnings import warn as Warn
     16
---> 17 class SPENC(clust.SpectralClustering):
     18     def __init__(self, n_clusters=8, eigen_solver=None, random_state=None,
     19                  n_init=10, gamma=1., affinity='rbf', n_neighbors=10,

~/anaconda3/envs/toss/lib/python3.8/site-packages/spenc/abstracts.py in SPENC()
    455
    456     def score(self, X, W, labels=None, delta=.5,
--> 457               attribute_score=skm.calinski_harabaz_score,
    458               spatial_score=boundary_fraction,
    459               attribute_kw = dict(),

AttributeError: module 'sklearn.metrics' has no attribute 'calinski_harabaz_score'

I guess scikit caught this typo and corrected it in version 0.23 without warning? It's a breaking change for spenc that causes import failure (can be solved by downgrading to sklearn 0.22

the fix is to change attribute_score=skm.calinski_harabaz_score to attribute_score=skm.calinski_harabasz_score (with the sz)

handle cannot-link constraints

Usually, you should be able to pass an affinity matrix with -1 to indicate that a connection cannot be made, and two observations cannot be put in the same cluster.

But, because of the way sklearn.manifold.spectral_embedding works, it computes a normalized laplacian, so any negative weights become nan.

add license file

i'd like to get as much of our stack as possible available directly through conda. The only requirement is that all deps for each package must also be available on conda... so i need spenc on conda-forge before we can get geosnap there. Assuming you're cool with that, conda-forge wants a license.txt in the repo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.