This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def full_path(folder_path): | |
| full_path = [] | |
| for dirpath, subdirs, files in os.walk(folder_path): | |
| for f in files: | |
| full_path.append(os.path.join(dirpath, f)) | |
| return full_path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| data_root = '/home/pt/Dropbox/mxnet/example/yelp/' | |
| def load_info(): | |
| full_path = [] | |
| for path, dir, files in os.walk(data_root+'/train_photos'): | |
| for f in files: | |
| #path_to_image.append(f) | |
| #dir.append(f) | |
| name = os.path.join(dir, f) | |
| full_path.append(name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bid_img = defaultdict(list) | |
| for line in train_photo_to_biz_ids: | |
| pid, bid2 = [v.strip() for v in line.split(',')] | |
| bid2 = bid2.strip("\r\n") | |
| bid_img[bid2].append(pid) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| unzip -c train.zip Train.csv | less |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo "alias aliasname='command'" >> ~/.bash_aliases && source ~/.bash_aliases |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def convert_label_to_array(str_label): | |
| str_label = str_label[1:-1] | |
| str_label = str_label.split(',') | |
| return [int(x) for x in str_label if len(x)>0] | |
| def convert_feature_to_vector(str_feature): | |
| str_feature = str_feature[1:-1] | |
| str_feature = str_feature.split(',') | |
| return [float(x) for x in str_feature] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #List unique values in a DataFrame column | |
| pd.unique(df.column_name.ravel()) | |
| #Convert Series datatype to numeric, getting rid of any non-numeric values | |
| df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True) | |
| #Grab DataFrame rows where column has certain values | |
| valuelist = ['value1', 'value2', 'value3'] | |
| df = df[df.column.isin(value_list)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def mf(y_true, y_pred): | |
| tp = 0 | |
| fp = 0 | |
| fn = 0 | |
| for i in range(y_true.shape[0]): | |
| for j in range(y_true.shape[1]): | |
| if y_true[i, j] == y_pred[i, j]: | |
| if y_true[i,j] == 1: | |
| tp += 1 | |
| elif y_true[i, j] != y_pred[i, j]: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def mf(y_true, y_pred): | |
| tp = 0.0 | |
| fp = 0.0 | |
| fn = 0.0 | |
| for i in range(y_true.shape[0]): | |
| for j in range(y_true.shape[1]): | |
| if y_true[i, j] == y_pred[i, j] & y_true[i,j] == 1: | |
| tp += 1 | |
| elif y_true[i, j] != y_pred[i, j]: | |
| if y_pred[i,j] == 1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from_dir = from_dir if from_dir.endswith('/') else from_dir + '/' |