Kaggle competition: DonorsChoose.org Application Screening
<SOS> metric: AUC Kaggle data source: donorschoose.org-application-screening<load_from_csv>
nltk.download("punkt" )
wr = open('results.txt', "w", encoding='utf8')
 mybest = pd.read_csv('/kaggle/input/mybest/sub9523.csv')
 sub = pd.read_csv('/kaggle/input/jigsaw-multilingual-toxic-test-translated/jigsaw_miltilingual_test_translated.csv')
 sub1 = pd.read_csv('/kaggle/input/mysub42/sub9458.csv')
 sub['prd'] = sub1['toxic']
for p0 in numpy.arange(1.2, 1.3, 0.1):
for p1 in numpy.arange(0.6, 0.7, 0.1):
for p2 in numpy.arange(0.8, 0.9, 0.1):
for p3 in numpy.arange(0.6, 0.7, 0.1):
for p4 in numpy.arange(0.6, 0.7, 0.1):
for p5 in numpy.arange(0.6, 0.7, 0.1):
out = []
for _, row in sub.iterrows() :
item = [row['id'], row['prd'], row['lang']]
if(item[2]=='es'):
if(item[1]<0.7):
item[1] *= p0
elif(item[2]=='fr'):
if(item[1]<0.7):
item[1] *= p1
elif(item[2]=='ru'):
if(item[1]<0.7):
item[1] *= p2
elif(item[2]=='it'):
if(item[1]<0.7):
item[1] *= p3
elif(item[2]=='tr'):
if(item[1]<0.7):
item[1] *= p4
elif(item[2]=='pt'):
if(item[1]<0.7):
item[1] *= p5
out.append(item)
 of = pd.DataFrame(out, columns=['id', 'toxic', 'lang'])
 score1 = roc_auc_score(mybest.toxic.round().astype(int), of.toxic.values)
 score2 = roc_auc_score(of.toxic.round().astype(int), mybest.toxic.values)
 line = '%1.2f,%1.2f,%1.2f,%1.2f,%1.2f,%1.2f\t%2.4f\t%2.4f'%(p0, p1,p2,p3,p4,p5, 100*score1, 100*score2)
 print(line)
 wr.write(line+'
')
 wr.close()<load_from_csv>
def tokenize_sentences(sentences, words_dict):
tokenized_sentences = []
for sentence in tqdm.tqdm(sentences):
if hasattr(sentence, "decode"):
sentence = sentence.decode("utf-8")
 tokens = nltk.tokenize.word_tokenize(sentence)
 result = []
for word in tokens:
word = word.lower()
if word not in words_dict:
words_dict[word] = len(words_dict)
 word_index = words_dict[word]
result.append(word_index)
 tokenized_sentences.append(result)
 return tokenized_sentences, words_dict
wr = open('results.txt', "w", encoding='utf8')
 mybest = pd.read_csv('/kaggle/input/mybest/sub9523.csv')
 sub = pd.read_csv('/kaggle/input/jigsaw-multilingual-toxic-test-translated/jigsaw_miltilingual_test_translated.csv')
 sub1 = pd.read_csv('/kaggle/input/mysub42/sub9458.csv')
 sub['prd'] = sub1['toxic']
dic = {}
oft = open('/kaggle/input/profanity/Profanity.txt', "r", encoding='utf8')
 for l in oft:
ele = l.strip().lower().split(':')
 dic[ele[0]] = ele[1]
oft.close()
len, les, lit, ltr, lfr, lru, lpt = 1., 1., 1., 1., 1., 1., 1.
 enpros = dic['en'].split(',')
 for len in numpy.arange(1.3, 1.4, 0.1):
out = []
found = 0
for _, row in sub.iterrows() :
if(row['lang']=='es'):
lmd = les
elif(row['lang']=='it'):
lmd = lit
elif(row['lang']=='tr'):
lmd = ltr
elif(row['lang']=='fr'):
lmd = lfr
elif(row['lang']=='ru'):
lmd = lru
else:
lmd = lpt
item = [row['id'], row['prd']]
if(item[1]<0.5):
for w in enpros:
if(str(row['translated'] ).lower().find(w)>=0):
item[1] *= len
found += 1
break
ws = dic[row['lang']].split(',')
 for w in ws:
if(str(row['content'] ).lower().find(w)>=0):
item[1] *= lmd
break
out.append(item)
 of = pd.DataFrame(out, columns=['id', 'toxic'])
 score1 = roc_auc_score(mybest.toxic.round().astype(int), of.toxic.values)
 score2 = roc_auc_score(of.toxic.round().astype(int), mybest.toxic.values)
 l = '%1.2f:\t%2.4f\t%2.4f'%(len, 100*score1, 100*score2)
 print(found, l)
 wr.write(l+'
')
 wr.close()<define_variables>
def read_embedding_list(file_path):
embedding_word_dict = {}
embedding_list = []
f = open(file_path)
 for index, line in enumerate(f):
if index == 0:
continue
values = line.split()
word = values[0]
try:
coefs = np.asarray(values[1:], dtype='float32')
 except:
continue
embedding_list.append(coefs)
 embedding_word_dict[word] = len(embedding_word_dict)
 f.close()
embedding_list = np.array(embedding_list)
 return embedding_list, embedding_word_dict
LABELS = ["toxic"]
all_files = glob.glob(".. /input/jigsaw-data/*.csv" )<load_from_csv>
def clear_embedding_list(embedding_list, embedding_word_dict, words_dict):
cleared_embedding_list = []
cleared_embedding_word_dict = {}
for word in words_dict:
if word not in embedding_word_dict:
continue
word_id = embedding_word_dict[word]
row = embedding_list[word_id]
cleared_embedding_list.append(row)
 cleared_embedding_word_dict[word] = len(cleared_embedding_word_dict)
 return cleared_embedding_list, cleared_embedding_word_dict
outs = [pd.read_csv(f, index_col=0)for f in all_files]
concat_sub = pd.concat(outs, axis=1)
 cols = list(map(lambda x: "m" + str(x), range(len(concat_sub.columns))))
concat_sub.columns = cols
concat_sub.reset_index(inplace=True )<feature_engineering>
def convert_tokens_to_ids(tokenized_sentences, words_list, embedding_word_dict, sentences_length):
words_train = []
for sentence in tokenized_sentences:
current_words = []
for word_index in sentence:
word = words_list[word_index]
word_id = embedding_word_dict.get(word, len(embedding_word_dict)- 2)
 current_words.append(word_id)
 if len(current_words)>= sentences_length:
current_words = current_words[:sentences_length]
else:
current_words += [len(embedding_word_dict)- 1] *(sentences_length - len(current_words))
words_train.append(current_words)
 return words_train
warnings.filterwarnings("ignore")
 rank = np.tril(concat_sub.iloc[:,1:].corr().values,-1)
 m =(rank>0 ).sum()
m_gmean, s = 0, 0
for n in range(min(rank.shape[0],m)) :
mx = np.unravel_index(rank.argmin() , rank.shape)
 w =(m-n)/(m+n/10)
 m_gmean += w*(np.log(concat_sub.iloc[:,mx[0]+1])+np.log(concat_sub.iloc[:,mx[1]+1])) /2
s += w
rank[mx] = 1
m_gmean = np.exp(m_gmean/s ).clip(0.0,1.0 )<load_from_csv>
from keras.callbacks import Callback, EarlyStopping, ModelCheckpoint
from keras.engine import Layer
from keras.layers import Activation, Add, Bidirectional, Conv1D, Dense, Dropout, Embedding, Flatten
from keras.layers import concatenate, GRU, Input, K, LSTM, MaxPooling1D
from keras.layers import GlobalAveragePooling1D, GlobalMaxPooling1D, SpatialDropout1D
from keras.models import Model
from keras.optimizers import Adam
from keras.preprocessing import text, sequence
from sklearn.metrics import accuracy_score, roc_auc_score, log_loss
from sklearn.model_selection import train_test_split
from keras import initializers, regularizers, constraints, optimizers, layers, callbacks
predict_list = []
predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9139.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9158.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9189.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9234.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9240.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9242.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9257.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9312.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9322.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9332.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9336.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9338.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9346.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9358.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9361.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9368.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9377.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9383.csv")[LABELS].values)
 predict_list.append(pd.read_csv(".. /input/jigsaw-data/submission-.9397.csv")[LABELS].values)
 predict_list_2 = []
predict_list_2.append(pd.read_csv(".. /input/jigsaw-data/submission-.9414-1.csv")[LABELS].values)
 predict_list_2.append(pd.read_csv(".. /input/jigsaw-data/submission-.9416.csv")[LABELS].values)
 predict_list_2.append(pd.read_csv(".. /input/jigsaw-data/submission-.9422.csv")[LABELS].values)
 predict_list_2.append(pd.read_csv(".. /input/jigsaw-data/submission-.9427.csv")[LABELS].values)
 predict_list_2.append(pd.read_csv(".. /input/jigsaw-data/submission-.9487.csv")[LABELS].values)
 predict_list_2.append(pd.read_csv(".. /input/jigsaw-data/submission-.9522.csv")[LABELS].values )<feature_engineering>
gru_len = 128
Routings = 5
Num_capsule = 10
Dim_capsule = 16
dropout_p = 0.3
rate_drop_dense = 0.3
warnings.filterwarnings("ignore")
 print("Rank averaging on ", len(predict_list), " files")
 predictions = np.zeros_like(predict_list[0])
 for predict in predict_list:
for i in range(1):
predictions[:, i] = np.add(predictions[:, i], rankdata(predict[:, i])/predictions.shape[0])
 predictions = predictions /len(predict_list )<feature_engineering>
def squash(x, axis=-1):
s_squared_norm = K.sum(K.square(x), axis, keepdims=True)
 scale = K.sqrt(s_squared_norm + K.epsilon())
 return x / scale
warnings.filterwarnings("ignore")
 print("Rank averaging on ", len(predict_list_2), " files")
 predictions_2 = np.zeros_like(predict_list_2[0])
 for predict in predict_list_2:
for i in range(1):
predictions_2[:, i] = np.add(predictions_2[:, i], rankdata(predict[:, i])/predictions_2.shape[0])
 predictions_2 = predictions_2 /len(predict_list_2 )<save_to_csv>
class Capsule(Layer):
def __init__(self, num_capsule, dim_capsule, routings=3, kernel_size=(9, 1), share_weights=True,
activation='default', **kwargs):
super(Capsule, self ).__init__(**kwargs)
 self.num_capsule = num_capsule
self.dim_capsule = dim_capsule
self.routings = routings
self.kernel_size = kernel_size
self.share_weights = share_weights
if activation == 'default':
self.activation = squash
else:
self.activation = Activation(activation)
 def build(self, input_shape):
super(Capsule, self ).build(input_shape)
 input_dim_capsule = input_shape[-1]
if self.share_weights:
self.W = self.add_weight(name='capsule_kernel',
shape=(1, input_dim_capsule,
self.num_capsule * self.dim_capsule),
initializer='glorot_uniform',
trainable=True)
 else:
input_num_capsule = input_shape[-2]
self.W = self.add_weight(name='capsule_kernel',
shape=(input_num_capsule,
input_dim_capsule,
self.num_capsule * self.dim_capsule),
initializer='glorot_uniform',
trainable=True)
 def call(self, u_vecs):
if self.share_weights:
u_hat_vecs = K.conv1d(u_vecs, self.W)
 else:
u_hat_vecs = K.local_conv1d(u_vecs, self.W, [1], [1])
 batch_size = K.shape(u_vecs)[0]
input_num_capsule = K.shape(u_vecs)[1]
u_hat_vecs = K.reshape(u_hat_vecs,(batch_size, input_num_capsule,
self.num_capsule, self.dim_capsule))
u_hat_vecs = K.permute_dimensions(u_hat_vecs,(0, 2, 1, 3))
b = K.zeros_like(u_hat_vecs[:, :, :, 0])
 for i in range(self.routings):
b = K.permute_dimensions(b,(0, 2, 1))
c = K.softmax(b)
 c = K.permute_dimensions(c,(0, 2, 1))
b = K.permute_dimensions(b,(0, 2, 1))
outputs = self.activation(K.batch_dot(c, u_hat_vecs, [2, 2]))
if i < self.routings - 1:
b = K.batch_dot(outputs, u_hat_vecs, [2, 3])
 return outputs
def compute_output_shape(self, input_shape):
return(None, self.num_capsule, self.dim_capsule )
submission_1 = pd.read_csv('.. /input/jigsaw-multilingual-toxic-comment-classification/sample_submission.csv')
 submission_1[LABELS] = predictions
submission_2 = pd.read_csv('.. /input/jigsaw-multilingual-toxic-comment-classification/sample_submission.csv')
 submission_2[LABELS] = predictions_2
submission = pd.read_csv('.. /input/jigsaw-multilingual-toxic-comment-classification/sample_submission.csv')
 submission[LABELS] = submission_1[LABELS]*.35 + submission_2[LABELS]*.65
submission.to_csv('submission.csv', index=False )<load_from_csv>
def get_model(embedding_matrix, sequence_length, dropout_rate, recurrent_units, dense_size):
input1 = Input(shape=(sequence_length,))
embed_layer = Embedding(embedding_matrix.shape[0], embedding_matrix.shape[1],
weights=[embedding_matrix], trainable=False )(input1)
 embed_layer = SpatialDropout1D(rate_drop_dense )(embed_layer)
 x = Bidirectional(
 GRU(gru_len, activation='relu', dropout=dropout_p, recurrent_dropout=dropout_p, return_sequences=True))(
 embed_layer)
 capsule = Capsule(num_capsule=Num_capsule, dim_capsule=Dim_capsule, routings=Routings,
share_weights=True )(x)
 capsule = Flatten()(capsule)
 capsule = Dropout(dropout_p )(capsule)
 output = Dense(1, activation='sigmoid' )(capsule)
 model = Model(inputs=input1, outputs=output)
 model.compile(
 loss='binary_crossentropy',
optimizer='adam',
metrics=['accuracy'])
 return model
data = pd.read_csv(".. /input/train.csv", parse_dates=['timestamp'])
 prices = data['price_doc']
features_raw = data.drop(['price_doc','id'], axis =1 )<normalization>
def _train_model(model, batch_size, train_x, train_y, val_x, val_y):
num_labels = train_y.shape[1]
patience = 5
best_loss = -1
best_weights = None
best_epoch = 0
current_epoch = 0
while True:
model.fit(train_x, train_y, batch_size=batch_size, epochs=1)
 y_pred = model.predict(val_x, batch_size=batch_size)
 total_loss = 0
for j in range(num_labels):
loss = log_loss(val_y[:, j], y_pred[:, j])
 total_loss += loss
total_loss /= num_labels
print("Epoch {0} loss {1} best_loss {2}".format(current_epoch, total_loss, best_loss))
current_epoch += 1
if total_loss < best_loss or best_loss == -1:
best_loss = total_loss
best_weights = model.get_weights()
best_epoch = current_epoch
else:
if current_epoch - best_epoch == patience:
break
model.set_weights(best_weights)
 return model
features_raw.fillna(0, inplace =True)
 scaler = MinMaxScaler(( 0,1e6))
numerical = features_raw.select_dtypes(include=['float64','int64'] ).keys()
features_raw[numerical] = scaler.fit_transform(features_raw[numerical])
 print(features_raw.head(n = 1))<categorify>
def train_folds(X, y, X_test, fold_count, batch_size, get_model_func):
print("="*75)
 fold_size = len(X)// fold_count
models = []
result_path = "predictions"
if not os.path.exists(result_path):
os.mkdir(result_path)
 for fold_id in range(0, fold_count):
fold_start = fold_size * fold_id
fold_end = fold_start + fold_size
if fold_id == fold_size - 1:
fold_end = len(X)
 train_x = np.concatenate([X[:fold_start], X[fold_end:]])
 train_y = np.concatenate([y[:fold_start], y[fold_end:]])
 val_x = np.array(X[fold_start:fold_end])
 val_y = np.array(y[fold_start:fold_end])
 model = _train_model(get_model_func() , batch_size, train_x, train_y, val_x, val_y)
 train_predicts_path = os.path.join(result_path, "train_predicts{0}.npy".format(fold_id))
test_predicts_path = os.path.join(result_path, "test_predicts{0}.npy".format(fold_id))
train_predicts = model.predict(X, batch_size=512, verbose=1)
 test_predicts = model.predict(X_test, batch_size=512, verbose=1)
 np.save(train_predicts_path, train_predicts)
 np.save(test_predicts_path, test_predicts)
 return models
objects = features_raw.select_dtypes(include=['object'] ).keys()
lbl = LabelEncoder()
for col in objects:
lbl.fit(list(features_raw[col].values))
features_raw[col] = lbl.transform(list(features_raw[col].values))
features = features_raw
features = features.drop(features.filter(regex='_no', axis=1),axis=1)
 features.drop('timestamp',axis=1,inplace =True)
 encoded = list(features.columns)
 print("{} total features after one-hot encoding.".format(len(encoded)))
 print(encoded )<compute_test_metric>
train_file_path = ".. /input/donorschooseorg-preprocessed-data/train_small.csv"
test_file_path = ".. /input/donorschooseorg-preprocessed-data/test_small.csv"
embedding_path = ".. /input/donorschooseorg-preprocessed-data/embeddings_small.vec"
batch_size = 128
recurrent_units = 16
dropout_rate = 0.3
dense_size = 8
sentences_length = 10
fold_count = 2
minimum_price = np.min(prices)
 maximum_price = np.max(prices)
 mean_price = np.mean(prices)
 median_price = np.median(prices)
 std_price = np.std(prices)
 print("Statistics for russian housing dataset:
")
 print("Minimum price: Rub {:,.2f}".format(minimum_price))
print("Maximum price: Rub {:,.2f}".format(maximum_price))
print("Mean price: Rub {:,.2f}".format(mean_price))
print("Median price Rub {:,.2f}".format(median_price))
print("Standard deviation of prices: Rub {:,.2f}".format(std_price))
alfa_c =(std_price/99)*1.96
print("critical alfa score for sample size of 100: Rub {:,.2f}".format(alfa_c))<compute_test_metric>
UNKNOWN_WORD = "_UNK_"
END_WORD = "_END_"
NAN_WORD = "_NAN_"
CLASSES = ["project_is_approved"]
def performance_metric(y_true, y_predict):

 score = r2_score(y_true, y_predict)
 return score<split>
print("Loading data...")
 train_data = pd.read_csv(train_file_path)
 test_data = pd.read_csv(test_file_path)
 list_sentences_train = train_data["application_text"].fillna(NAN_WORD ).values
list_sentences_test = test_data["application_text"].fillna(NAN_WORD ).values
y_train = train_data[CLASSES].values
X_train, X_test, y_train, y_test = train_test_split(features,prices, test_size =0.2, random_state = 33)
 print("Training and testing split was successful." )<train_model>
print("Tokenizing sentences in train set...")
 tokenized_sentences_train, words_dict = tokenize_sentences(list_sentences_train, {})
 print("Tokenizing sentences in test set...")
 tokenized_sentences_test, words_dict = tokenize_sentences(list_sentences_test, words_dict )
def ModelLearning(X, y):

 cv = ShuffleSplit(n_splits = 10, test_size = 0.2, random_state = 0)
 train_sizes = np.rint(np.linspace(1, X.shape[0]*0.8 - 1, 9)).astype(int)
 fig = pl.figure(figsize=(10,7))
for k, depth in enumerate([1,3,6,10]):
regressor = DecisionTreeRegressor(max_depth = depth)
 sizes, train_scores, test_scores = curves(regressor, X, y, \
cv = cv, train_sizes = train_sizes, scoring = 'r2')
 train_std = np.std(train_scores, axis = 1)
 train_mean = np.mean(train_scores, axis = 1)
 test_std = np.std(test_scores, axis = 1)
 test_mean = np.mean(test_scores, axis = 1)
 ax = fig.add_subplot(2, 2, k+1)
 ax.plot(sizes, train_mean, 'o-', color = 'r', label = 'Training Score')
 ax.plot(sizes, test_mean, 'o-', color = 'g', label = 'Testing Score')
 ax.fill_between(sizes, train_mean - train_std, \
train_mean + train_std, alpha = 0.15, color = 'r')
 ax.fill_between(sizes, test_mean - test_std, \
test_mean + test_std, alpha = 0.15, color = 'g')
 ax.set_title('max_depth = %s'%(depth))
ax.set_xlabel('Number of Training Points')
 ax.set_ylabel('Score')
 ax.set_xlim([0, X.shape[0]*0.8])
 ax.set_ylim([-0.05, 1.05])
 ax.legend(bbox_to_anchor=(1.05, 2.05), loc='lower left', borderaxespad = 0.)
fig.suptitle('Decision Tree Regressor Learning Performances', fontsize = 16, y = 1.03)
 fig.tight_layout()
fig.show()<compute_test_metric>
words_dict[UNKNOWN_WORD] = len(words_dict)
 print("Loading embeddings...")
 embedding_list, embedding_word_dict = read_embedding_list(embedding_path)
 embedding_size = len(embedding_list[0] )
ModelLearning(features, prices )<compute_test_metric>
print("Preparing data...")
 embedding_list, embedding_word_dict = clear_embedding_list(embedding_list, embedding_word_dict, words_dict)
 embedding_word_dict[UNKNOWN_WORD] = len(embedding_word_dict)
 embedding_list.append([0.] * embedding_size)
 embedding_word_dict[END_WORD] = len(embedding_word_dict)
 embedding_list.append([-1.] * embedding_size)
 embedding_matrix = np.array(embedding_list)
 id_to_word = dict(( id, word)for word, id in words_dict.items())
 train_list_of_token_ids = convert_tokens_to_ids(
 tokenized_sentences_train,
id_to_word,
embedding_word_dict,
sentences_length)
 test_list_of_token_ids = convert_tokens_to_ids(
 tokenized_sentences_test,
id_to_word,
embedding_word_dict,
sentences_length)
 X_train = np.array(train_list_of_token_ids)
 X_test = np.array(test_list_of_token_ids )
ModelComplexity(X_train, y_train )<prepare_x_and_y>
get_model_func = lambda: get_model(
 embedding_matrix,
sentences_length,
dropout_rate,
recurrent_units,
dense_size )
xgb_params = {
'eta': 0.05,
'max_depth': 5,
'subsample': 0.7,
'colsample_bytree': 0.7,
'objective': 'reg:linear',
'eval_metric': 'rmse',
'silent': 1
}
dtrain = xgb.DMatrix(features, prices )<compute_train_metric>
del train_data, test_data, list_sentences_train, list_sentences_test
del tokenized_sentences_train, tokenized_sentences_test, words_dict
del embedding_list, embedding_word_dict
del train_list_of_token_ids, test_list_of_token_ids
gc.collect() ;
cv_output = xgb.cv(xgb_params, dtrain, num_boost_round=1000, early_stopping_rounds=20,
verbose_eval=50, show_stdv=False)
 cv_output[['train-rmse-mean', 'test-rmse-mean']].plot()<train_model>
print("Starting to train models...")
 models = train_folds(X_train, y_train, X_test, fold_count, batch_size, get_model_func )
<load_from_csv><EOS> 
LABELS = ["project_is_approved"]
base = ".. /input/donorschooseorg-application-screening-predictions/predictions/predictions/"
predict_list = []
for j in range(10):
predict_list.append(np.load(base + "predictions_001/test_predicts%d.npy"%j))
print("Rank averaging on ", len(predict_list), " files")
 predcitions = np.zeros_like(predict_list[0])
 for predict in predict_list:
predcitions = np.add(predcitions.flatten() , rankdata(predict)/predcitions.shape[0])
 predcitions /= len(predict_list)
 submission = pd.read_csv('.. /input/donorschoose-application-screening/sample_submission.csv')
 submission[LABELS] = predcitions
submission.to_csv('submission.csv', index=False )