Code Monkey home page Code Monkey logo

rubixml / sentiment Goto Github PK

View Code? Open in Web Editor NEW
102.0 7.0 13.0 34.78 MB

An example project using a feed-forward neural network for text sentiment classification trained with 25,000 movie reviews from the IMDB website.

Home Page: https://rubixml.com

License: MIT License

PHP 100.00%
sentiment-analysis sentiment-classification neural-network natural-language-processing machine-learning text-classification deep-learning tf-idf tutorial example-project

sentiment's Introduction

Rubix ML

PHP from Packagist Latest Stable Version Downloads from Packagist Code Checks GitHub

A high-level machine learning and deep learning library for the PHP language.

  • Developer-friendly API is delightful to use
  • 40+ supervised and unsupervised learning algorithms
  • Support for ETL, preprocessing, and cross-validation
  • Open source and free to use commercially

Installation

Install Rubix ML into your project using Composer:

$ composer require rubix/ml

Requirements

  • PHP 7.4 or above

Recommended

Optional

Documentation

Read the latest docs here.

What is Rubix ML?

Rubix ML is a free open-source machine learning (ML) library that allows you to build programs that learn from your data using the PHP language. We provide tools for the entire machine learning life cycle from ETL to training, cross-validation, and production with over 40 supervised and unsupervised learning algorithms. In addition, we provide tutorials and other educational content to help you get started using ML in your projects.

Getting Started

If you are new to machine learning, we recommend taking a look at the What is Machine Learning? section to get started. If you are already familiar with basic ML concepts, you can browse the basic introduction for a brief look at a typical Rubix ML project. From there, you can browse the official tutorials below which range from beginner to advanced skill level.

Tutorials & Example Projects

Check out these example projects using the Rubix ML library. Many come with instructions and a pre-cleaned dataset.

Interact With The Community

Contributing

See CONTRIBUTING.md for guidelines.

License

The code is licensed MIT and the documentation is licensed CC BY-NC 4.0.

sentiment's People

Contributors

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

sentiment's Issues

hebrew support

hello,
thanks for the great work, can i train on hebrew language and the get predictions based on that training for hebrew texts?
cheers

Error trying to train, WordCountVectorizer missing parameter $maxDocumentFrequency

I am getting this error, when I am trying to train using your train.php (https://github.com/RubixML/Sentiment/blob/master/train.php) example:
Fatal error: Uncaught TypeError: Argument 3 passed to Rubix\ML\Transformers\WordCountVectorizer::__construct() must be of the type int, object given....

In your example on Line 44 you have:
new WordCountVectorizer(10000, 3, new NGram(1, 2)),

But the constuctor for WordCountVectorizer expects this:
public function __construct(
int $maxVocabulary = PHP_INT_MAX,
int $minDocumentFrequency = 1,
int $maxDocumentFrequency = PHP_INT_MAX,
?Tokenizer $tokenizer = null
)
What would be your recommended parameters for WordCountVectorizer for your example to work best?

How to optimize memory (RAM) usage

I'm running a sentiment type training environment with about 400,000 samples. The text is short, at most 255 characters each, but most are much less.

I'm running 32G on Linux running without a GUI and few other processes running. PHP is set to memory_limit -1.

Linux routinely kills my PHP process due to lack of memory. Following this guide I've set my overcommit_memory value to 2 which allows the script to run a little longer but it eventually runs out of memory and stops.

I've ordered 32G of more RAM hoping this will help with my problem, but, are there any other techniques I could use to reduce memory usage? Or, is there a way to see/calculate how much memory is needed before even attempting to run the script?

Neural network crash when using AdaMax optimizer with Tensor extension

The program work find before installing tensor extension, but after I install the extension I get this error.
Can someone help? What do I miss ?

zephir_call_class_method_aparams: *return_value must be IS_NULL or IS_UNDEF
#0 0x7f4afdead288 [/usr/lib/php/20190902/tensor.so(zephir_print_backtrace+0x38) [0x7f4afdead288]]
#1 0x7f4afdeb7215 [/usr/lib/php/20190902/tensor.so(zephir_call_class_method_aparams+0x285) [0x7f4afdeb7215]]
#2 0x7f4afdeb1469 [/usr/lib/php/20190902/tensor.so(zephir_array_fetch+0x2c9) [0x7f4afdeb1469]]
#3 0x7f4afdf4f165 [/usr/lib/php/20190902/tensor.so(zim_Tensor_Matrix_maximum+0xe15) [0x7f4afdf4f165]]
#4 0x55bf0acf5af5 [php(execute_ex+0x8635) [0x55bf0acf5af5]]
#5 0x55bf0acf714b [php(zend_execute+0x12b) [0x55bf0acf714b]]
#6 0x55bf0ac6e1ec [php(zend_execute_scripts+0xcc) [0x55bf0ac6e1ec]]
#7 0x55bf0ac0ded0 [php(php_execute_script+0x2d0) [0x55bf0ac0ded0]]
#8 0x55bf0acf9282 [php(+0x331282) [0x55bf0acf9282]]
#9 0x55bf0aad5938 [php(+0x10d938) [0x55bf0aad5938]]
#10 0x7f4b00f4b0b3 [/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f4b00f4b0b3]]
#11 0x55bf0aad5ade [php(_start+0x2e) [0x55bf0aad5ade]]

Aborted (core dumped)

Estimator

I am seeing the estimator file system is with the .model formate how to make .model file? I want to rank the data where the doc's says
$scores = $estimator->rank($dataset);

var_dump($scores);
but $estimator should be given how?

How long should training take?

First of all, this looks like an amazing project! I have a been trying to lear ML for a specific problem I need to solve and reading your code is helping a lot.

Anyway, I have followed the instructions to train the model for the sentiment analysis and seems to take hours. Does that sound right to you? How long would you expect it to take?

Why am I getting poor prediction results?

harry@ubuntu-server:~/sentiment$ php74 predict.php
Enter some text to analyze:
rubixml is great
The sentiment is: negative

harry@ubuntu-server:~/sentiment$ php74 predict.php
Enter some text to analyze:
Rubix ML is really great
The sentiment is: positive

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.