-1
$\begingroup$

The context of the question: I have a pandas dataframe where one column has text values and others have categorical values. I trained a word2vec model with tensorflow with some sample data. And I convert my text column into the vector representation. But I want to feed these data to Catboost for regression task. But I can't feed those data to catboost because of catboost only accept the Categorical variable.

I found a tutorial on Catboost Github page for this. But this example is for the classification task. It finds cosine and other types of relationship between two vector representation of text. But in my case, I have only one text field. So how can calculate cosine or other types relationship?

So my question is how to extract categorical features from the vector representation of text data?

$\endgroup$
1
  • $\begingroup$ Could you describe what the text column looked like? It might be an idea to just convert it using bag-of-words in binary form $\endgroup$ – S van Balen Feb 26 '18 at 19:49
0
$\begingroup$

You could try a clustering algorithm on the vector representation of your text data to see what clusters exist. Then once you have discovered the unique clusters, assign a cluster identity (for example, a single digit value indicating cluster identity (1, 2, 3, 4 etc)). Then you can use Keras's to_categorical function to convert the cluster identity to categorical values.

$\endgroup$
0
$\begingroup$

But I can't feed those data to catboost because of catboost only accept the Categorical variable.

That's not true. Actually CatBoost uses continuous variables by default, and to use categorical ones you'd need to tell your estimators which features are categorical with cat_features parameter.

If you still want to use this column as categorical, then there are two options: as you didn't specify whether this column contains words or some longer text, you could either one-hot encode words (in the first case) or use tf-idf features on text (in the latter). In the second case you'd have to note though that GBMs don't work well when there are thousands of features (which is common for tf-idf or Bag of Words models).

$\endgroup$

Your Answer

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

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