
Machine Learning and Deep Learning using the PHP Language (Examples & Tutorials) - andrewdalpino
https://github.com/RubixML
======
suff
NOPE. Never do this ever. Never in production and never in pre-production.
Never do this.

Warning: Here be dragons.

Never create anything people rely on that runs machine learning in PHP.

~~~
andrewdalpino
Haha yeah that's a common reaction from people that haven't seen it with their
own eyes yet

I don't blame you

Let me know if you have any questions

~~~
suff
I mean, it's not that it won't work, but why would you use a language that is
a CPU hog, for a heavy duty task that needs a GPU? It's 2 orders of magnitude
slower than it needs to be, and nobody else has ever trained or done tutorials
for PHP ML, so why? Just why??

Respect for building fundamentals, but in terms of utility, it needs a proper
warning label IMHO.

~~~
andrewdalpino
This is a good convo to have

Two things you mentioned that are incorrect though

The first is the presumption that you need a GPU to do machine learning - the
reality is that the average business doesn't need nor has the data to benefit
from such large models

The second is that PHP is slow - but when you do comparisons with Python, PHP
is actually faster

[https://benchmarksgame-
team.pages.debian.net/benchmarksgame/...](https://benchmarksgame-
team.pages.debian.net/benchmarksgame/faster/php.html)

The reason why Python, for example, is faster in some machine learning
applications is because it's probably getting help from a library such as
numPY or Tensorflow

Although these tools are missing currently in the PHP ecosystem, I'm confident
that we'll have them eventually

For example, here is an attempt to bring numPY-like functionality as a PHP
extension

[https://github.com/phpsci/phpsci-
ext/tree/1.0-dev](https://github.com/phpsci/phpsci-ext/tree/1.0-dev)

We've also had some progress being made accessing Tensorflow from PHP using an
FFI (foreign function interface)

[https://github.com/dstogov/php-tensorflow](https://github.com/dstogov/php-
tensorflow)

So this is where the convo should begin in my opinion

~~~
suff
If you're going to do it at all, I agree, integration with GPU enabled
libraries is a must. Even so, I could use DLLImport in VBA, and get access to
Tensorflow from an Excel macro. I would say the same thing: you can get a dog
to walk on two legs, but that's not what it was meant to do. 'Can' and
'should' are world's apart.

~~~
andrewdalpino
What languages do you program in?

I've used PHP for a while now. PHP is a language that favors practicality.
It's a language that is depended on throughout the world and doesn't
(purposely) change as fast to accommodate new trends

Having that said

\- The value of machine learning has become very clear over the past decade or
so

\- 80% of websites on the web are powered by PHP

[https://haydenjames.io/80-percent-web-powered-by-
php/](https://haydenjames.io/80-percent-web-powered-by-php/)

I undoubtedly anticipate a steady rise in effort from the PHP community
directed at practical applications of ML - Rubix ML being one of the first
libraries to make these tools accessible to the PHP engineer

~~~
suff
I write in all kinds of languages.

Just because Wordpress generates it, doesn't make it a best practice. Do you
think Wordpress websites are the best? It's definitely not the most popular
language:

[https://github.com/emmanuel-keller/github-language-
statistic...](https://github.com/emmanuel-keller/github-language-statistics)

[https://www.tiobe.com/tiobe-index](https://www.tiobe.com/tiobe-index)

[https://redmonk.com/sogrady/2019/03/20/language-
rankings-1-1...](https://redmonk.com/sogrady/2019/03/20/language-
rankings-1-19)

PHP is falling because it has major issues. It has poor idioms and is slow. It
is trending down, not up.

------
dual_basis
But... why?

Maybe we need a tech version of /r/diwhy to put this and all the "I rewrote my
toaster's firmware in Rust!" content.

~~~
andrewdalpino
Yeah that's a fair question

Machine learning is one of the most important technologies of the next coming
decades and I don't want PHP developers to get left behind

At first I wanted to learn ML and so I started writing the algorithms one by
one and putting them up on Github, it started to become very useful to me, and
so I decided to share it

Thanks for the question

------
andrewdalpino
Hi HN, OP here

Feel free to ask me any questions about the library

It's been a very interesting project so far

Andrew

