Coder Social home page Coder Social logo

Comments (12)

PrayagAshwini avatar PrayagAshwini commented on June 2, 2024

Hi
I am trying to use jaccard matrix as an attribute to clusterfck -- here is my code :

var clusters = clusterfck.hcluster(dataarray, clj_fuzzy.metrics.levenshtein, clusterfck.COMPLETE_LINKAGE);

however, it always returns single node for each array item

from clj-fuzzy.

Yomguithereal avatar Yomguithereal commented on June 2, 2024

Hello @PrayagAshwini. I am not very acquainted with how the clusterfck works so it is quite difficult to help you efficiently. However, your example uses the levenshtein function rather than the jaccard one.

from clj-fuzzy.

Yomguithereal avatar Yomguithereal commented on June 2, 2024

Could you elaborate a bit more on what you are trying to do @PrayagAshwini, please?

from clj-fuzzy.

PrayagAshwini avatar PrayagAshwini commented on June 2, 2024

thanks for quick response Yomguithereal .
Actually I tried both Jaccard & levenshtein, however none of them working. same output with any matrix attribute.
I am using clj-fuzzy - v0.3.1 js file .
let me know if you get any other pointers.

from clj-fuzzy.

Yomguithereal avatar Yomguithereal commented on June 2, 2024

Do you have a sample of the data you are trying to cluster somewhere so I can run tests on my side?

from clj-fuzzy.

PrayagAshwini avatar PrayagAshwini commented on June 2, 2024

here is sample data - ["economictimes.com","food.com","gaana.com","google.com","facebook.com","food.com","facebook.com","food.com"]

from clj-fuzzy.

Yomguithereal avatar Yomguithereal commented on June 2, 2024

After running some tests on my own, I am not sure this library is really suited to analyze strings. It seem that it will only process numbers.

from clj-fuzzy.

Yomguithereal avatar Yomguithereal commented on June 2, 2024

Moreover the library behaves quite strangely, sometimes it computes instantaneously but sometimes it just does not compute at all or very slowly. Besides the library is not maintained anymore.

from clj-fuzzy.

Yomguithereal avatar Yomguithereal commented on June 2, 2024

Why don't you use something like hierarchical-clustering:

var cluster = require('hierarchical-clustering'),
    metrics = require('clj-fuzzy').metrics;

var data = [
  'economictimes.com',
  'food.com',
  'gaana.com',
  'google.com',
  'facebook.com',
  'food.com',
  'facebook.com',
  'food.com'
];

// Single-linkage clustering
function linkage(distances) {
  return Math.min.apply(null, distances);
}

var levels = cluster({
  input: data,
  distance: metrics.jaccard,
  linkage: linkage,
  minClusters: 2, // only want two clusters
});

var clusters = levels[levels.length - 1].clusters;

clusters = clusters.map(function (cluster) {
  return cluster.map(function (index) {
    return data[index];
  });
});

console.log(clusters);

from clj-fuzzy.

PrayagAshwini avatar PrayagAshwini commented on June 2, 2024

thanks Yomguithereal. The above code is working.. however metrics parameter is not working..
here is data -
[ 'chatting.com', 'chrysler.com', 'economictimes.com', 'food.com', 'toopgaana.com', 'health.nih.gov', 'ibncnn.com', 'nytimes.com', 'khaanakhajana.com','kidshealth.org','makaan.com', 'photography.com', 'pinrest.com', 'test.com', 'thetimes.co.uk', 'topgames.com', 'topnonprofits.com' ]

And output is -
[["kidshealth.org"],["topnonprofits.com","topgames.com","toopgaana.com","test.com","food.com","pinrest.com","nytimes.com","makaan.com","ibncnn.com","chrysler.com","chatting.com","thetimes.co.uk","economictimes.com","khaanakhajana.com","photography.com","health.nih.gov"]]

whether I use "metrics.jaccard," or " metrics.levenshtein" ..

Any pointers??

I would like to receive output something like below --

[["kidshealth.org"], ["topnonprofits.com", "topgames.com", "toopgaana.com"], ["test.com"],["food.com"], ["pinrest.com"], ["thetimes.co.uk", "economictimes.com", "nytimes.com"],["makaan.com"] ,["ibncnn.com"], ["chrysler.com", "chatting.com"], ["khaanakhajana.com"], ["photography.com"], ["health.nih.gov"]]

from clj-fuzzy.

Yomguithereal avatar Yomguithereal commented on June 2, 2024

You can try to fiddle with the minClusters option to increase the number of possible clusters generated by the algorithm.

from clj-fuzzy.

PrayagAshwini avatar PrayagAshwini commented on June 2, 2024

I tried that.. however it just creates more clusters with single item, and remaining all in one..
If I provide manual distance formula, it clusters at least two values starting with "ch" and remaining items listed correctly as single item.

// Euclidean distance
function Edistance(a, b) {
var d = 0;
for (var i = 0; i < a.length; i++) {
d += Math.pow(a[i] - b[i], 2);
}
return Math.sqrt(d);
}

output
[["chrysler.com","chatting.com"],["economictimes.com"],["food.com"],["toopgaana.com"],["health.nih.gov"],["ibncnn.com"],["nytimes.com"],["khaanakhajana.com"],["kidshealth.org"],["makaan.com"],["photography.com"],["pinrest.com"],["test.com"],["thetimes.co.uk"],["topgames.com"],["topnonprofits.com"]]

from clj-fuzzy.

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.