{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"collapsed":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport cv2\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\ntrain = pd.read_csv(\"../input/train.csv\")\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true,"collapsed":true},"cell_type":"code","source":"print(\"train has {} rows and {} columns\".format(train.shape[0],train.shape[1]))\nprint(\"FEATURES:\")\nprint(train.columns)","execution_count":8,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f1816378a237c7426f16a2a3a861605e30714f8a","collapsed":true},"cell_type":"code","source":"def item_loc(id_,feat=None):  #the function helps on selective feature searching\n    if id_==int(id_) and feat==None:\n        nil_feat = train.iloc[id_,:]\n    else:\n        nil_feat = train.iloc[id_,:][int(feat)]\n    return nil_feat","execution_count":28,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a91155b9147cb9f6b0ffdbd119c3b8626b1fdb8e","collapsed":true},"cell_type":"code","source":"from zipfile import ZipFile\nimage_dir = ZipFile(\"../input/train_jpg.zip\")\nfilenames = image_dir.namelist()[1:200]","execution_count":63,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"432927edb217c5dce551b31ee3c88b01815bc728","collapsed":true},"cell_type":"code","source":"def get_blurrness(file): #extracting blurness\n    exfile = image_dir.read(file)\n    arr = np.frombuffer(exfile, np.uint8)\n    if arr.size > 0:   # exclude dirs and blanks\n        imz = cv2.imdecode(arr, flags=cv2.COLOR_BGR2GRAY)\n        fm = cv2.Laplacian(imz, cv2.CV_64F).var()\n    else: \n        fm = -1\n    return fm\nblurrness = []\nfiles = filenames[60:75]\nfor i in range(0, len(files)):\n    print(i)\n    blurrness.append(get_blurrness(files[i]))\n    ","execution_count":67,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8c93403be813738374f5862265fc77827684334e","collapsed":true},"cell_type":"code","source":"blurrness","execution_count":66,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5cdb2f44d7882b04817499e67331ceb4f1aafb7e","collapsed":true},"cell_type":"code","source":"x = 60 #\nfor i,p in zip(range(len(blurrness)),range(x,x+len(blurrness))):\n    print(blurrness[i],item_loc(p,17))","execution_count":79,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"ad03a0a5d0a8964b77190e3e87fcd06be51308d2"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.5","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}