Coder Social home page Coder Social logo

giacbrd / shallowlearn Goto Github PK

View Code? Open in Web Editor NEW
197.0 18.0 30.0 550 KB

An experiment about re-implementing supervised learning models based on shallow neural network approaches (e.g. fastText) with some additional exclusive features and nice API. Written in Python and fully compatible with Scikit-learn.

License: GNU Lesser General Public License v3.0

Python 99.13% C 0.29% Shell 0.58%
word2vec fasttext scikit-learn machine-learning neural-network gensim text-mining text-classification supervised-learning online-learning

shallowlearn's People

Contributors

giacbrd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shallowlearn's Issues

make hash function faster

Iterating over documents and hashing words is almost an order of magnitude slower.
What can we do:

  • the hash function used for hashing trick and also for matrices initialization should be written in Cython/C (but also the fastest hash functions seem slow)

normalize argument names

use both fastText and Gensim names in GensimFastText, raise a warning when two names for the same parameter are set, make it retro-compatible with current (wrong) names

predict more samples at once

In GensimFastText predicting more documents is a sequence of prediction calls. It would be preferable to implement as deeply as possible in the core (i.e. matrix computations in Cython) the computations of multiple inputs.

Wrong output

When I try to predict some sentence I get the prediction for each word.
Is this a bug?

pre-train internally

Given a training set, it is possible to train the word embeddings (unsupervised) first, and then doing the label learning. It is similar to pass a pre-trained model, but more transparent

Structured documents

Documents can be structured, made of different sections (title, body, tags (tags positions are not significant, but they dependent on the document body)), learned independently

Implementation:

  • the input data is a dict of the sections
  • in the learning algorithm: concatenate labels to words according to their section

somehow combine fastText with doc2vec

fastText supervised model does not take into account of the document and words representation, it just learns bag of words and labels.
embeddings are computed only on the relation word->label. it would be interesting to learn jointly the semantic relation label<->document<->word<->context.
for now it is only possible to pre-train word embeddings and then use them as initial vectors for the classification algorithm

ShallowLearn ImportError on Ubuntu

from shallowlearn.models import GensimFastText

Traceback (most recent call last):
File "", line 1, in
File "/home/usr/anaconda2/lib/python2.7/site-packages/shallowlearn/models.py", line 15, in
import fasttext
File "/home/usr/anaconda2/lib/python2.7/site-packages/fasttext/init.py", line 1, in
from .fasttext import skipgram
ImportError: /home/usr/anaconda2/lib/python2.7/site-packages/fasttext/fasttext.so: undefined symbol: _ZTVNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEE

Tried with both 0.8.2 & 0.8.3 version of fasttext
and 0.13.4 & 1.0.1 version of gensim

Installed ShallowLearn using both 'pip' and by running the 'setup.py'

learning with non-explicit negative label

This could open to scenarios like:

  • one-class classification (the training set is only made of positive examples)
  • multi-label classification: learn with multiple labels but, given a test sample, the predicted label may not be the one with the highest probability (it could be not associable to any label)

test time longer than training time in the performance graph

@giacbrd @tmylk While running this document classification script, the performance graph generated shows training time to be lesser than test time.

But if we look closely, the training time is actually longer than test time for all the classifier. Here is the log

I think this is not the right way to convert the result into a range of (0,1) on the same axis

training_time = np.array(training_time) / np.max(training_time)
test_time = np.array(test_time) / np.max(test_time)

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.