Kaggle competition: Generative Dog Images
<SOS> metric: PostProcessorKernel Kaggle data source: generative-dog-images<categorify>
def get_features(path):
try:
st = []
img = Image.open(path)
 im_stats_ = ImageStat.Stat(img)
 st += im_stats_.sum
st += im_stats_.mean
st += im_stats_.rms
st += im_stats_.var
st += im_stats_.stddev
except:
print(path)
 return [path, st]
def normalize_img(paths):
imf_d = {}
p = Pool(cpu_count())
 ret = p.map(get_features, paths)
 for i in range(len(ret)) :
imf_d[ret[i][0]] = ret[i][1]
ret = []
fdata = [imf_d[f] for f in paths]
return pd.DataFrame(fdata)
 dog_bytes = pd.DataFrame(glob.glob('.. /input/all-dogs/all-dogs/**'), columns=['Path'])
 dog_bytes = pd.concat(( dog_bytes, normalize_img(dog_bytes.Path.values)) , axis=1)
 dog_bytes.head()
train, test = train_test_apply_func(train, test, convert_OHE2LE )<categorify>
dog_bytes['Group'] = cluster.KMeans(n_clusters=100, random_state=3, n_jobs=-1 ).fit_predict(dog_bytes[list(range(15)) ])
 dog_bytes['Group'].value_counts() [:5]