This file contains 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 numpy as np | |
import pandas as pd | |
import bottleneck as bn | |
# Read And Count | |
trainDF = pd.read_csv('train.csv',sep=',',header=0) | |
lenTrain = len(trainDF) | |
valDF = pd.read_csv('submission.csv',sep=',',header=0) | |
lenVal = len(valDF) | |
trainFold = pd.read_csv('train_5fold_20181219.csv',sep=',',header=0) |
This file contains 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 numpy as np | |
import pandas as pd | |
import numpy.random as nr | |
# Read In | |
DF = pd.read_csv('train.csv',sep=',',header=0) | |
for i in xrange(28): | |
DF[str(i)] = DF['Target'].map(lambda x: int(str(i) in x.split(' '))) | |
value_counts = DF.ix[:,2:].apply(np.sum, axis=0) |
This file contains 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
# When processing Sequence Tagging problems, | |
# An accuracy func which is too strict is not convergence-friendly. | |
# This Func is the solution of a naive leetcode problem LCS (Largest Common Subsequence), | |
# Original All-Correct-Or-Nothing accuracy function takes 7x times long to achieve certain accuracy. | |
def LCS(p,l): | |
if len(p)==0: | |
return 0 | |
P = np.array(list(p)).reshape((1,len(p))) | |
L = np.array(list(l)).reshape((len(l),1)) |