text_plain_output_1.png
from sklearn.feature_extraction.text import CountVectorizer

import itertools as it

import pandas as pd

import re

train = pd.read_json('../input/train.json')
train['listing_id'] = train['listing_id'].apply(str)

feature_total = []
train['features'].apply(lambda x: feature_total.append(x))
feature_total = list(it.chain.from_iterable(feature_total))
len(feature_total)

uniq_feature_total = set(feature_total)
len(uniq_feature_total)

vec = CountVectorizer(stop_words='english', max_features=200)
train['features_new'] = train['features'].apply(lambda y: ' '.join(['_'.join(x.split(' ')).lower() for x in y]))
tr_sparse = vec.fit_transform(train['features_new'])
feature_names = vec.get_feature_names()

feature_total = []
train['features'].apply(lambda x: feature_total.append(x))
feature_total = list(it.chain.from_iterable(feature_total))
uniq_feature_total = list(set(feature_total))

def re_search(key):
    """
    Present all features with specific re pattern
    """
    result = []
    my_reg = '' + key
    for item in uniq_feature_total:
        if re.compile(my_reg, re.IGNORECASE).search(item) != None:
            result.append(item)
    return result

re_search('doorman')