Giter Site home page Giter Site logo

Comments (1)

nicodv avatar nicodv commented on August 30, 2024

There is such a large variety of potential distance functions to use for numerical clustering that I prefer to leave it to the users to provide them. kmodes specializes more in categorical distance functions.

But of course, feel free to submit a PR to add the function. :)

As for the pickling error, I'm not able to reproduce it:

>>> import numpy as np
>>> from kmodes.kprototypes import KPrototypes

>>> def L1(a, b):
...    return np.sum(np.abs(a-b), axis=1)

>>> model = KPrototypes(n_clusters=20, gamma=1, num_dissim=L1, init='Cao')
>>> model

KPrototypes(gamma=1, n_clusters=20, num_dissim=<function L1 at 0x7fa526505090>)

>>> import pickle
>>> pickle.dumps(model)

b'\x80\x04\x95\xe8\x00\x00\x00\x00\x00\x00\x00\x8c\x12kmodes.kprototypes\x94\x8c\x0bKPrototypes\x94\x93\x94)\x81\x94}\x94(\x8c\nn_clusters\x94K\x14\x8c\x08max_iter\x94Kd\x8c\ncat_dissim\x94\x8c\x12kmodes.util.dissim\x94\x8c\x0fmatching_dissim\x94\x93\x94\x8c\x04init\x94\x8c\x03Cao\x94\x8c\x06n_init\x94K\n\x8c\x07verbose\x94K\x00\x8c\x0crandom_state\x94N\x8c\x06n_jobs\x94K\x01\x8c\nnum_dissim\x94\x8c\x08__main__\x94\x8c\x02L1\x94\x93\x94\x8c\x05gamma\x94K\x01ub.'

I suspect the problem lies with where you define your function. Have a look at this: https://www.pythonanywhere.com/forums/topic/27818/

A step-by-step reproducible example would help here.

from kmodes.

Related Issues (20)

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.