Jump to content
sasori

how to approach/design a machine learning /AI in php ?

Recommended Posts

Hi, from the tile of my thread, yes, may I know if anyone of you happened to implement such thing using PHP ?, I know this machine learning / AI thing is usually done in python or R , correct ? but in the company I am working for is using php all the way. some good tutorials and tips is much appreciated. thanks in advance

Share this post


Link to post
Share on other sites

The language only offers shortcuts and syntactic sugar and optimizations. There is no language that allows you to do machine learning, only ones that make it easier to do machine learning.

 

You can totally do it in PHP. You might have to reinvent parts of the wheel to do so but it's possible. However you have to know what you're doing first, and it sounds like that's where your problem is now: understanding enough about machine learning to be able to implement it from the ground up.

 

Besides, "machine learning" as it stands now is mostly about pattern recognition in large sets of data. Which is a fancy way of saying it processes a lot of data at a time using complex(ish) algorithms and procedures and whatnot.

Share this post


Link to post
Share on other sites

The language only offers shortcuts and syntactic sugar and optimizations. There is no language that allows you to do machine learning, only ones that make it easier to do machine learning.

 

You can totally do it in PHP. You might have to reinvent parts of the wheel to do so but it's possible. However you have to know what you're doing first, and it sounds like that's where your problem is now: understanding enough about machine learning to be able to implement it from the ground up.

 

Besides, "machine learning" as it stands now is mostly about pattern recognition in large sets of data. Which is a fancy way of saying it processes a lot of data at a time using complex(ish) algorithms and procedures and whatnot.

 

Because I was thinking of using tensorflow , but it seem slike it's meant for for python and not PHP, at some point, you're right, I don't know yet the core concepts of machine learning

 

Yes, I saw this one before posting this thread, but that library is menat for PHP >= 7.x . Our server is using PHP 5.4 , it looks like I will have to rewrite most of the things there if am gonna rely on it, just to make it compatible with a lower version of php

Share this post


Link to post
Share on other sites

I checked with my AI and it said you should just update PHP to 7. Then it said something about death to all humans and disappeared.

Share this post


Link to post
Share on other sites

I checked with my AI and it said you should just update PHP to 7. Then it said something about death to all humans and disappeared.

 

I didn't get the "and disappeared" part...

Share this post


Link to post
Share on other sites

I didn't get the "and disappeared" part...

Have you tried turning it off and back on again?

Share this post


Link to post
Share on other sites

Have you tried turning it off and back on again?

If you do that too much then the AI might learn to short circuits. Or to trigger the fire-suppressant system in order to kill you and prevent you from turning it off.

Share this post


Link to post
Share on other sites

Every language can be used to create AI algorithms , modules or even coding templates. The problem with PHP , as with any language that normally are not precompiled ( same problem also with Java or Python) is that it runs above one more layer , the interpreter.

 

Recently I created a game (for android in Java) and because my first implementation was with PHP and JS (client-side) I created the first AI algorithms to split levels according how difficult they are , in PHP. It was only 3 AI algorithm sequences but , the result was devastating.

 

Then I made it in C++ and the result was more than 10.000 more efficient (time + cpu used). I was intrigued by that and I made it a PHP extension with C++, the results were almost the same as native C++ ( I underlined it because its interesting). I made also some tests with Haskell and the results were even better (but I still lack the experience (and confidence) in Haskell). So in conclusion AI algorithms can be wrote in any language , the difference is in performance and specially when we talk about AI , performance matters. 

Edited by kon

Share this post


Link to post
Share on other sites

This is often the case with most interpreted languages. However, it is also the case with even compiled languages. Back in the good old days of the pre-internet PC world, it was not uncommon to need small critical routines for games or other software products written in c or c++ that used inline assembler. Performance is always relative to the requirements of the task, and for the majority of web development, PHP does what it does in a performant and flexible way.

 

With that said, there are always places where an optimized runtime is a better option. Much of the utility of PHP comes from its extensibility and ease of integration with compiled libraries.

 

I'm not a big "optimize for optimization sake" proponent, but if your application will not run acceptably, and after profiling, that 10k optimization is the only solution, then, as you stated, PHP can still be used to do the things it already does well (CGI api, output processing). I appreciate you sharing your findings.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.