4
$\begingroup$

I was thinking of training a neural network that would be able to classify twitter users according to their followers. For example, I would like to know if a user is "gamer" or not by the people they follow (not the number, but the list of the people they follow). I'd have a dataset of people who are gamers or not based on the accounts they're following and train them.

The problem that I find is that the number of followers of each person will vary ... One person could follow thousands of users while another could only follow hundreds, so since the list of followers of each person won't be the same lenght, how could I determine my feature there?

This would be an example of my dataset:

enter image description here

Features would be every people an account is following, and the label would say if it's a gamer or not.

As I said, the problem I can see is that the number of labels won't be the same...

$\endgroup$
1
  • $\begingroup$ I think bayesian models are best here ... $\endgroup$ – david david Jun 12 '20 at 14:29
4
$\begingroup$

This is a very interesting problem that can be approached in a lot of different ways!
Even though you are asking for a neural network, I will apply my own experience with Bayesian networks as I think they are more than suitable for this task (they might be even the best choice).
You could start of with a small seed of highly popular users which you can label as gamers/not gamers. Afterwards, using some threshold (which should vary in proportion to the number of users which have been labelled P(θ = X | labelledUsers = 100)), you should decide whether a particular user is a gamer or not (I would start off with people that follow a lot of "twitterers" to maximize the chances of following one of your "seed".
To help you find the previously mentioned probability, you can also help yourself with a test set to validate the probability. I hope this was helpful even though it doesn't use a neural network. BTW, you could also model P(θ = X | labelledUsers = 100) with a beta distribution. Using this technique, the algorithm would choose how much to weigh each feature using a PDF and you could just feed it as many features as you like without bothering about how relevant they are. As an extra, I wholeheartedly encourage you to buy/download John Kruschke's book on Doing Bayesian Data Analysis (A tutorial with R and BUGS), it will give you an excellent insight into data analysis for solving problems like this one.

In case you still want to use ANNs, I would recommend learning the parameters (the weights) for the neural network in a special environment (which you have to manually label) and using features such as the number of people following, ratio: gamers/all, you can try to create a computer vision algorithm for the images he posts (gaming vs non gaming). The list is infinite! Still, you should be careful not to include too many random (meaningless) features otherwise it might cause underfitting!

If you would also like details on which programming language would be best for this, I would recommend R or Matlab (my personal choice even though R comes with more premade functions) for developing the algorithm and Fortran or C for a final exportable version (if you wished to do so).

$\endgroup$
3
$\begingroup$

I guess your question is: you want to use a neural network to predict whether a user is a "gamer" or not, and you want to find some features from his/her followers. Well here are some possible features you may want to use.

  1. If you find the number of their followers is varying, why not just use this "follower number" as a feature.
  2. Based on the first point: because some gamers are very active in their game community and like to discuss their common interests, you can check the absolute number of the "gamers number" in their followers. Even based on the percentage of the (gamers/followers), you can even give weights to these users.
  3. Another thing I found from my project is that: you may find some interesting features from the user pages. For example, the number of tweets or pictures they post, the contents of their tweets (you can do some simple sentiment analyses or more complex NLP to extract features from it). Then you can find more useful features to feed your model.

Hope these can help you.

$\endgroup$
2
  • $\begingroup$ I'm pretty new to this so sorry to ask, I can't see why the number of their followers could be a feature. A guy could have 100 followers and most of them based on things like... I don't know, let's say fashion, while other one could have 100 followers as well but they interest could be based in the gamer industry. As human I can classify a person as a gamer or not, looking over their twitter and I'm pretty sure that the followers of many of those accounts have patterns in common so I thought maybe keeping a list of users' followers could be a good way to start $\endgroup$ – Sharki Jun 4 '20 at 2:03
  • 1
    $\begingroup$ From my understanding, I think this is the "magic" part of deep learning. I mean, compared with traditional machine learning methods, which require you to put many efforts into feature engineering, deep learning can find out/extract the features from your inputs through the layers. For example, the content of tweets, it's easy for you to figure out the difference between "gamer post" and the normal one. And if you input these contents (after reasonable embeddings) to deep learning model, you can have confidence that your model can achieve the same thing as you. $\endgroup$ – Nick Chen Jun 4 '20 at 5:57
2
$\begingroup$

If I correctly understand your question, your main problem here is the length of your features which are varying. So I think you need to use Long short-term memory (LSTM ) model or Gated Recurrent Units (GRU). These types of models are based on Recurrent neural networks(RNN)s architecture which are used widely in deep learning models specially when you need some memory in your model or where your models input sequence length are varying. Here is a good article about Sequence Classification with LSTM.

$\endgroup$
5
  • $\begingroup$ Yey, I read it, don't worry! :) I'll read about LSTM latter so I can update, or tell you something! Thanks $\endgroup$ – Sharki Jun 6 '20 at 1:50
  • $\begingroup$ Hello again, sorry to bother you, I was wondering if I could save the whole list into only one feature? like np.array([['Ibai, g2sports, EA3', 1],['foo, foo, foo', 0]]) and then do word embedding for every X[:, 0] and this would work? I mean, this would be correct or make sense? ` $\endgroup$ – Sharki Jun 6 '20 at 4:03
  • $\begingroup$ Hi. Never mind, I'm glad to help. Based on your explanation about different size of features for each data, I don't think it would make sense specially if you want to use LSTM. $\endgroup$ – pouyan Jun 6 '20 at 16:58
  • $\begingroup$ I'm not sure if we're thinking in the same problem, when I'm talking about different size of features I meant that if someone is following 2 people, and other one is following 3, then I'll have as max 3 features, not the lenght of each username of each follower itself. That's why I'm so lost, because I'm not sure how to treat my features, since the first row could have 4, the next row could have 6 and so on... (it will depend of how many friends the account has) I apologize again for my poor English and for not being able to explain myself correctly, it has to be stressful, sorry. $\endgroup$ – Sharki Jun 6 '20 at 17:29
  • 1
    $\begingroup$ For now I'm a little busy, but i will try to update my answer very soon, in the way that it become more clear for you. Until then I recommend you to read more about LSTM. Most of the samples in the net are based on the words but it doesn't mean that LSTM works just for words. While reading the examples (like one that I posted in my answer), You can imagine each of your followers data acts like a word in those examples( I hope this consideration will help you to understand how to use LSTM in your problem until I update my answer ) $\endgroup$ – pouyan Jun 6 '20 at 18:07
2
$\begingroup$

I would start by giving each Twitter user a unique ID - this will become the index of your dataset. Then for each unique ID (twitter user), do feature engineering and brainstorm different features that you think would be useful. I would highly recommend reading 'Hands On Machine Learning with Scikit-Learn and Tensorflow' if you don't have much experience with machine learning and neural networks for an implementation based approach. I'd also recommend researching and reading papers about Twitter user trends and the different category of users if you haven't already. Knowing the subject matter of what you are trying to model is very important.

Keep in mind, that you don't need to be very selective with the features you add. As long as you can come up with a reasonable suspicion, go ahead and add the data. Keep in mind, this will add to the amount of time you spend cleaning the data.

Some features I can think of:

  1. Parse their tweets and use a 'bag of words' model to assign a tone, negative or positive. Some category of users may have more positive or negative tone. For example, political tweets on Twitter.
  2. Twitter API may disclose what country the user is from, or even the city they are from. Some cities have a bigger population of certain people. For example, there are more farmers in Idaho than in NYC.
  3. Number of retweets and likes per unique ID.
  4. Number of tweets per user (as another commenter mentioned)

Another thought: a problem like this is ripe for a network analysis and graph based network model. Here is an example.

$\endgroup$
1
$\begingroup$

Your problem is that you are taking each followed user as an input feature and that the number of followed users can vary so you don't have a fixed length vector for your NN.

Two possible approaches (that I can think of):

  1. you want to extract on single "value" from each followed user (such as their own label) and in that case you could have an input vectors that aggregate these in counters: each dimension of the vector is one of your label and the value is just the number of followed users that have that label. Of course you need a fixed number of labels...

eg: the target account X has 3 followers:

  • MisterA being tagged a 'gamer', an 'influencer' and a 'youngster'
  • MissB being tagged a 'gamer', a 'leader' and a 'youngster'
  • MisterC being tagged a 'gamer' and 'political activist'

Feature vector for the target account should aggregate these values, for instance:

X = {'gamer': 3; 'influencer': 1; 'youngster': 2; 'leader': 1; 'political activist': 1}

You might want to normalize so all values are in [0,1].

  1. you extract several features from each followed users, in that case your inputs will be the aggregation of these features over all followed accounts. Here the form of the vector will depends on the features you have already in your data (tags, location, number of messages, numbers of followers...).

In both cases, you need to flip your view on the inputs and move from each followed user as a dimension to something else.

$\endgroup$
2
  • $\begingroup$ Hello @gdupont since I'm pretty new in this, I can't understand most of the things, besides my native language is not English, so everything becomes a bit more complicated. Could you propose an example in itself, or maybe just a more detailed answer for someone so dumb like me? Thanks and sorry! $\endgroup$ – Sharki Jun 8 '20 at 14:53
  • $\begingroup$ No worry English isn't my mother tongue either. I tried to add more details but it depends on the data you collect. Maybe you can provide extract in your question and then I could adapt the example. $\endgroup$ – gdupont Jun 9 '20 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy