Catboost: TypeError: cannot use a string pattern on a bytes-like object

Created on 2 Jul 2019  路  4Comments  路  Source: catboost/catboost

Problem: TypeError: cannot use a string pattern on a bytes-like object
catboost version: 0.15.2
Operating System: Ubuntu 19.04
CPU: Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz

I got over the issue AttributeError: 'str' object has no attribute 'decode' which already has this fix.

I've applied the changes and got a new error:

~/.local/lib/python3.7/site-packages/graphviz/lang.py in quote(identifier, html, valid_id, dot_keywords)
     48     '"<>"'
     49     """
---> 50     if html(identifier) and not isinstance(identifier, NoHtml):
     51         pass
     52     elif not valid_id(identifier) or identifier.lower() in dot_keywords:

TypeError: cannot use a string pattern on a bytes-like object

The code I am running is same as in Visualization of CatBoost decision trees tutorial

Most helpful comment

We'll look into this

All 4 comments

We'll look into this

I also meet this quesition

@annaveronika this occurs when trying to add the leaf nodes, specifically

node_label = leaf_values[node_num] # core.py line 2480

leaf_values[node_num] is byte not str

A fix is to revert the change https://github.com/catboost/catboost/commit/2e9b80146d93d8112119e961015b860346a84477 for the leaf_values (I'm not sure if this is general) i.e.

            if split_num >= 0:
                node_label = splits[split_num].replace('bin=', 'value>', 1)
                color = 'black'
                shape = 'ellipse'
            else:
                node_label = leaf_values[node_num].decode('utf-8')
                color = 'red'
                shape = 'rect'

This is fixed in catboost 0.16.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gushinyakov picture gushinyakov  路  4Comments

taurandat picture taurandat  路  4Comments

old-fashion-donut picture old-fashion-donut  路  4Comments

DBusAI picture DBusAI  路  3Comments

idavydov picture idavydov  路  3Comments