I'm new to Machine learning or Ai but I have been a developer for almost 10 years.

I have a news aggregator application that grabs and save articles from news websites, And I have developed an algorithm of my own that categorizes the news based on it's titles.

The way it works is when I grab a new title I split the words of the title and save it in a table called "tags" and I have "categories" table, and then manually I'm going to link some of the tags (those are can be recognized or non stop words) to categories.

then on categories page using SQL I'm classifying the titles. It's all working good and since I'm using and it even works for "America" and "American" words and I only linked the "America" word to the categories and "American" word is not linked to any categories but still knows it belongs to the same category that "America" belongs.

And I read the PHP-ML library that's an AI library for PHP. That's how it uses the same thing as I do as far as I understand it:

// Data for training classifier
$samples = [[1, 3], [1, 4], [2, 4], [3, 1], [4, 1], [4, 2]];  // Training samples
$labels = ['a', 'a', 'a', 'b', 'b', 'b'];

// Initialize the classifier
$classifier = new SVC(Kernel::LINEAR, $cost = 1000);
// Train the classifier
$classifier->train($samples, $labels);

$classifier->predict([3, 2]); // return 'b'
$classifier->predict([[3, 2], [1, 5]]); // return ['b', 'a']

So it's kinda the same as my algorithm, but the only thing that I don't understand is how this library understand the new words.

so on my own algorithm if there's a new word let's say "Spain" I have to go to the table and link it to the "World" field on categories table.

But if this library is machine learning I think it's supposed to know where "Spain belongs to without my touch. on my database

I Have around twenty thousand words and I have linked almost two thousand of the words to the categories table. so if I use this library can I use it with same data that I have and without my touch anymore or how does this library tell if new word belongs to where? where does it save it? or does it even save it? or if he could predict a new word do I have to make it change the tag to link the categories? or it's kinda the same as my own and I have to teach it every word?

  • 2
    I think this is off topic here. It is also rather broad (answers to the many questions depend on the learning machine, the choice of which depends on the problem), and has nothing to do with PHP. It may be useful to know that the ability to recognise unseen patterns is called 'generalisation'. I say pattern because [3, 2] is not a word: it is a point in a 2D continuous space (or at least, that is how the SVM interprets it); words are not inherently like this. – VisualMelon Apr 28 '19 at 13:15
  • It can be useful to view SVM not as an example of learning, but simply as a statistical technique (like regression analysis) to find a classification boundary between two sets of high-dimensional data points. That boundary can later be used to predict the classification of new data points. The model won't understand new words, it will just assign them to one side of the boundary, based on the new word's coordinate in the feature space. – amon Apr 28 '19 at 13:22
  • Take a look at CPG Gray and 3 Brown 1 Blue both are excelent high level explanations and visualisations of neural nets which are a form of categorisation search. Other forms of learning do exist, though they are less suitable for the task you have outlined. – Kain0_0 Apr 28 '19 at 14:14

There are many different types of machine learning.

The one in your example is basically trying to draw straight lines between the a and b labelled points.

enter image description here

The lines are equivalent to your word mapping and are saved in memory as part of the classifier after you have called the train function.

To apply machine learning to your article tagging problem you would have to have a training set if articles with tag you were happy with along with a number of stats from the article itself. say a list of all the words in the article with the count of the number of times they occur.

A Machine Learning algorithm will then try to find a pattern between the word counts and the tag.

If it can find a pattern that works then you can feed it word counts from other articles and ask it to predict what the tag should be.

Obviously if there are completely new words in those articles they wont fit into the pattern and will be ignored.

  • So it's basically don't learn by itself based on the data? It's same as mine I have to teach it every word where belongs to? – user2682025 Apr 29 '19 at 11:38
  • the 'learning' can only be done with a set of data you already know the answers for, and that set has to be similar to data you want to predict the answer for – Ewan Apr 29 '19 at 11:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.