<div dir="ltr">I made a rendering of the result online <a href="https://sensimark.com/">https://sensimark.com/</a><br></div><br><div class="gmail_quote"><div dir="ltr">Le dim. 3 juin 2018 à 23:22, Sebastian Raschka <<a href="mailto:mail@sebastianraschka.com">mail@sebastianraschka.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">sorry, I had a copy & paste error, I meant "LogisticRegression(..., multi_class='multinomial')" and not "LogisticRegression(..., multi_class='ovr')" <br>
<br>
> On Jun 3, 2018, at 5:19 PM, Sebastian Raschka <<a href="mailto:mail@sebastianraschka.com" target="_blank">mail@sebastianraschka.com</a>> wrote:<br>
> <br>
> Hi,<br>
> <br>
>> I quickly read about multinomal regression, is it something do you recommend I use? Maybe you think about something else? <br>
> <br>
> Multinomial regression (or Softmax Regression) should give you results somewhat similar to a linear SVC (or logistic regression with OvO or OvR). The theoretical difference is that Softmax regression assumes that the classes are mutually exclusive, which is probably not the case in your setting since e.g., an article could be both "Art" and "Science" to some extend or so. Here a quick summary of softmax regression if useful: <a href="https://sebastianraschka.com/faq/docs/softmax_regression.html" rel="noreferrer" target="_blank">https://sebastianraschka.com/faq/docs/softmax_regression.html</a>. In scikit-learn, you can use it via LogisticRegression(..., multi_class='ovr').<br>
> <br>
> Howeever, spontaneously, I would say that Latent Dirichlet Allocation could be a better choice in your case. I.e., fit the model on the corpus for a specified number of topics (e.g., 10, but depends on your dataset, I would experiment a bit here), look at the top words in each topic and then assign a topic label to each topic. Then, for a given article, you can assign e.g., the top X labeled topics.<br>
> <br>
> Best,<br>
> Sebastian<br>
> <br>
> <br>
> <br>
> <br>
>> On Jun 3, 2018, at 5:03 PM, Amirouche Boubekki <<a href="mailto:amirouche.boubekki@gmail.com" target="_blank">amirouche.boubekki@gmail.com</a>> wrote:<br>
>> <br>
>> Héllo,<br>
>> <br>
>> I started a natural language processing project a few weeks ago called wikimark (the code is all in wikimark.py)<br>
>> <br>
>> Given a text it wants to return a dictionary scoring the input against vital articles categories, e.g.:<br>
>> <br>
>> out = wikimark("""Peter Hintjens wrote about the relation between technology and culture. Without using a scientifical tone of state-of-the-art review of the anthroposcene antropology, he gives a fair amount of food for thought. According to Hintjens, technology is doomed to become cheap. As matter of fact, intelligence tools will become more and more accessible which will trigger a revolution to rebalance forces in society.""") <br>
>> <br>
>> for category, score in out: <br>
>>    print('{} ~ {}'.format(category, score))<br>
>> <br>
>> The above program would output something like that:<br>
>> <br>
>> Art ~ 0.1 <br>
>> Science ~ 0.5 <br>
>> Society ~ 0.4<br>
>> <br>
>> Except not everything went as planned. Mind the fact that in the above example the total is equal to 1, but I could not achieve that at all.<br>
>> <br>
>> I am using gensim to compute vectors of paragraphs (doc2vev) and then submit those vectors to svm.SVR in a one-vs-all strategy ie. a document is scored 1 if it's in that subcategory and zero otherwise. At prediction time, it goes though the same doc2vec pipeline. The computer will score each paragraph against the SVR models of wikipedia vital article subcategories and get a value between 0 and 1 for each paragraph. I compute the sum and group by subcategory and then I have a score per category for the input document<br>
>> <br>
>> It somewhat works. I made a web ui online you can find it at <a href="https://sensimark.com" rel="noreferrer" target="_blank">https://sensimark.com</a> where you can test it. You can directly access the<br>
>> full api e.g. <a href="https://sensimark.com/api/v0?url=http://www.multivax.com/last_question.html&all=1" rel="noreferrer" target="_blank">https://sensimark.com/api/v0?url=http://www.multivax.com/last_question.html&all=1</a><br>
>> <br>
>> The output JSON document is a list of category dictionary where the prediction key is associated with the average of the "prediction" of the subcategories. If you replace &all=1 by &top=5 you might get something else as top categories e.g. <a href="https://sensimark.com/api/v0?url=http://www.multivax.com/last_question.html&top=10" rel="noreferrer" target="_blank">https://sensimark.com/api/v0?url=http://www.multivax.com/last_question.html&top=10</a><br>
>> <br>
>> or <br>
>> <br>
>> <a href="https://sensimark.com/api/v0?url=http://www.multivax.com/last_question.html&top=5" rel="noreferrer" target="_blank">https://sensimark.com/api/v0?url=http://www.multivax.com/last_question.html&top=5</a><br>
>> <br>
>> I wrote "prediction" with double quotes because the value you see, is the result of some formula. Since, the predictions I get are rather small between 0 and 0.015 I apply the following formula:<br>
>> value = math.exp(prediction)<br>
>> magic = ((value * 100) - 110) * 100<br>
>> <br>
>> In order to have values to spread between -200 and 200. Maybe this is the symptom that my model doesn't work at all. <br>
>> <br>
>> Still, the top 10 results are almost always near each other (try with BBC articles on <a href="https://sensimark.com" rel="noreferrer" target="_blank">https://sensimark.com</a> . It is only when a regression model is disqualified with a score of 0 that the results are simple to understand. Sadly, I don't have an example at hand to support that claim. You have to believe me.<br>
>> <br>
>> I just figured looking at the machine learning map that my problem might be classification problem, except I don't really want to know what is the class of new documents, I want to how what are the different subjects that are dealt in the document based on a hiearchical corpus;<br>
>> I don't want to guess a hiearchy! I want to now how the document content spread over the different categories or subcategories.<br>
>> <br>
>> I quickly read about multinomal regression, is it something do you recommend I use? Maybe you think about something else? <br>
>> <br>
>> Also, it seems I should benchmark / evaluate my model against LDA.<br>
>> <br>
>> I am rather noob in terms of datascience and my math skills are not so fresh. I more likely looking for ideas on what algorithm, fine tuning and some practice of datascience I must follow that doesn't involve writing my own algorithm.<br>
>> <br>
>> Thanks in advance!<br>
>> _______________________________________________<br>
>> scikit-learn mailing list<br>
>> <a href="mailto:scikit-learn@python.org" target="_blank">scikit-learn@python.org</a><br>
>> <a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scikit-learn</a><br>
> <br>
<br>
_______________________________________________<br>
scikit-learn mailing list<br>
<a href="mailto:scikit-learn@python.org" target="_blank">scikit-learn@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scikit-learn</a><br>
</blockquote></div>