Jump to content

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


sasori

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

Link to comment
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.

Link to comment
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

Link to comment
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. 

Link to comment
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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

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.