GithubHelp home page GithubHelp logo

Refactor to a class about kmeans HOT 4 OPEN

mljs avatar mljs commented on May 30, 2024
Refactor to a class

from kmeans.

Comments (4)

maasencioh avatar maasencioh commented on May 30, 2024

why TypeScript? I think that the class is not a bad idea, do you see any advantage doing this?

from kmeans.

stropitek avatar stropitek commented on May 30, 2024

I think that's a very good idea. People will be familiar with the API. I think most people doing ML have worked with python and scikit before.

@maasencioh we've been experimenting with Typescript and it's awesome.

  • Auto-completion and documentation as you code, really useful for ML where you often see have complex types
  • Fix typos and type errors before even running the program
  • Thinking with types in mind helps you to design a better API IMHO
  • It's still just js at the end
  • We often have a build step anyway (for example to support es6 modules)
  • People have already expressed their desire to see MLJS in typescript

from kmeans.

jobo322 avatar jobo322 commented on May 30, 2024

Syntax is like Java, for reading the code maybe it's better, you need to write more code for the same result but personally I like the comments functionality for the argument types

from kmeans.

lpatiny avatar lpatiny commented on May 30, 2024

Migrating to a class would be great indeed but I would prefer to have something similar to pca, pls and other packages

const kMeans = new KMeans(dataset, options); (or new KMeans(dataset, numberClusters, options))

const newPoints = [[4.9, 3.2, 1.2, 0.4], [5.4, 3.3, 1.4, 0.9]];
console.log(kMeans.predict(newPoints)); // project new points into the PCA space

const model2 = kMeans.toJSON(); // to save the model

const kMeans2 = KMeans.load(model);
kMeans2.predict(newPoints);

from kmeans.

Related Issues (12)

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.