Giter Site home page Giter Site logo

liulhdarks / darks-learning Goto Github PK

View Code? Open in Web Editor NEW
19.0 5.0 8.0 1.2 MB

Darks learning is the machine learning algorithm library. It contains Word2vec,DBN, RBM, MLP, LSA, PLSA, SDA, Maxent, regression, etc.

License: Apache License 2.0

Java 97.98% HTML 2.02%

darks-learning's Introduction

Darks Learning

Darks learning is the machine learning algorithm library. It contains Word2vec,DBN, RBM, MLP, LSA, PLSA, SDA, Maxent, regression, etc.

Load Corpus

The corpus type are divided into Corpus, Documents and ModelSet.

Corpus

It can be used for Word2vec,LSA,pLSA,etc. which are used to documents and words related to non classification algorithm.

CorpusLoader loader = new CorpusLoader();
loader.addFilter(...);
loader.addStopwords(...);
Corpus corpus = loader.loadFromFile(new File(...));

Documents

It can be used for Maxent, bayes, etc. which are used to documents and words related to classification algorithm.

File input = new File(...);
File labels = new File(...);
Documents docs = Documents.loadFromFile(input, labels, "UTF-8");
File corpusFile = new File(...); 
//The corpusFile both contains labels and features, which's labels and features of each line must be separated by Tab(\t).
Documents docs = Documents.loadFromFile(corpusFile, "UTF-8");

ModelSet

It can be used for regression, MLP, DBN, RBM, SDA, SOFTMAX, etc. which are used to classification based on double matrix.

ModelSet modelSet = ModelLoader.loadFromFile(...);
ModelSet modelSet = ModelLoader.loadFromStream(...);

Naive Bayes

Navie bayes contains the BINAMIAL and BERNOULLI modes.

  • BINAMIAL is fine-grained to words by default.
  • BERNOULLI is coarse-grained to documents.

Example

How to train

Documents docs = Documents.loadFromFile(corpusFile, "UTF-8");
NaiveBayes bayes = new NaiveBayes();
bayes.config.setLogLikelihood(true)
			.setModelType(NaiveBayes.BINAMIAL);
bayes.train(docs);

How to classify

String sentence = ...; //Sentence string must be separated by spaces.
String classify = bayes.predict(sentence);
String classify = bayes.predict(new String[]{...});

Maxent

Maxent only supports GIS algorithm.

Example

How to train

Documents docs = Documents.loadFromFile(corpusFile, "UTF-8");
Maxent maxent = new GISMaxent();
MaxentModel model = maxent.train(docs, 1000); //Train model with 1000 iterations.
model.saveModel(...);

How to load

GISModel model = GISModel.readModel(...);
GISMaxent maxent = new GISMaxent(model);
...

How to classify

String[] terms = ...;
int labelIndex = maxent.predict(terms);
String classify = maxent.getLabel(labelIndex);

LSA (Latent Semantic Analysis)

Example

How to train

CorpusLoader loader = new CorpusLoader(Corpus.TYPE_TF_IDF);
File file = ...;
Corpus corpus = loader.loadFromFile(file, "UTF-8");
LatentSemanticAnalysis lsa = new LatentSemanticAnalysis();
lsa.train(corpus);
lsa.saveModel(...);
lsa.loadModel(...);

How to predict

String result = lsa.predict(new String[]{...});
int index = lsa.predictIndex(new String[]{...});

darks-learning's People

Contributors

liulhdarks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

darks-learning's Issues

Missing test data files

Please provide the 'corpus' directory so users can run the tests.

Tests in error:
  testDynamicalCluster(darks.learning.test.cluster.TextClusterTest): Cannot find corpus corpus\train_data.txt
  testPLSA(darks.learning.test.lsa.PlsaTest): Cannot find corpus corpus\corpus_ali_small.txt
  testMatrixSubAdd(darks.learning.test.math.MathTest): For input string: "9223372036854775807"
  testMaxentGIS(darks.learning.test.maxent.MaxentTest)
  testTrain(darks.learning.test.word2vec.Word2VecTest): Cannot find corpus corpus\text8_limit.txt

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.