words_embed_tsr = self._word_embed(words_tsr.view(-1)).view(N, W, Ew) # Apply dropout to word rep (N x W x Ew) words_rep_tsr = self._word_dropout(words_embed_tsr) # Apply bidirectional LSTM to word rep sequence (N x W x 2h) (words_hidden_rep_tsr, _) = self._word_lstm(words_rep_tsr) words_hidden_rep_tsr = words_hidden_rep_tsr.contiguous() # Apply linear + softmax operation for sentence rep for all sentences (N x W x t) word_probs_tsr = F.softmax(self._word_lin( words_hidden_rep_tsr.view(N * W, self._h * 2)), dim=1).view(N, W, t) return word_probs_tsr if __name__ == '__main__': test_model_class(model_file_path=__file__, model_class='PyBiLstm', task=TaskType.POS_TAGGING, dependencies={ModelDependency.PYTORCH: '0.4.1'}, train_dataset_uri='data/ptb_for_pos_tagging_train.zip', test_dataset_uri='data/ptb_for_pos_tagging_test.zip', queries=[['Ms.', 'Haag', 'plays', 'Elianti', '18', '.'], [ 'The', 'luxury', 'auto', 'maker', 'last', 'year', 'sold', '1,214', 'cars', 'in', 'the', 'U.S.' ]])
if __name__ == '__main__': # model = SkLasso() # model._reg = Lasso(0.1) # model.train('data/home_rentals_train.zip') # print(model.evaluate('data/home_rentals_test.zip')) # queries = [[3358, 2, 1, 743, 10, 3230, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], # [3359, 1, 1, 533, 10, 1903, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], # [3360, 3, 2, 1186, 62, 4437, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0] # ] # print(model.predict(queries)) test_model_class(model_file_path=__file__, model_class='SkBeyesianRidge', task=TaskType.TABLE_REGRESSION, dependencies={}, train_dataset_uri='data/home_rentals_train.zip', test_dataset_uri='data/home_rentals_test.zip', queries=[[ 3358, 2, 1, 743, 10, 3230, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ], [ 3359, 1, 1, 533, 10, 1903, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 3360, 3, 2, 1186, 62, 4437, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]])
test_model_class( model_file_path=__file__, model_class='TfFeedForward', task=TaskType.IMAGE_CLASSIFICATION, dependencies={ModelDependency.TENSORFLOW: '1.12.0'}, train_dataset_uri= 'data/fashion_mnist_for_image_classification_train.zip', test_dataset_uri='data/fashion_mnist_for_image_classification_test.zip', queries=[[[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0, 0, 7, 0, 37, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 27, 84, 11, 0, 0, 0, 0, 0, 0, 119, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 88, 143, 110, 0, 0, 0, 0, 22, 93, 106, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 53, 129, 120, 147, 175, 157, 166, 135, 154, 168, 140, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 11, 137, 130, 128, 160, 176, 159, 167, 178, 149, 151, 144, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 1, 0, 2, 1, 0, 3, 0, 0, 115, 114, 106, 137, 168, 153, 156, 165, 167, 143, 157, 158, 11, 0 ], [ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 3, 0, 0, 89, 139, 90, 94, 153, 149, 131, 151, 169, 172, 143, 159, 169, 48, 0 ], [ 0, 0, 0, 0, 0, 0, 2, 4, 1, 0, 0, 0, 98, 136, 110, 109, 110, 162, 135, 144, 149, 159, 167, 144, 158, 169, 119, 0 ], [ 0, 0, 2, 2, 1, 2, 0, 0, 0, 0, 26, 108, 117, 99, 111, 117, 136, 156, 134, 154, 154, 156, 160, 141, 147, 156, 178, 0 ], [ 3, 0, 0, 0, 0, 0, 0, 21, 53, 92, 117, 111, 103, 115, 129, 134, 143, 154, 165, 170, 154, 151, 154, 143, 138, 150, 165, 43 ], [ 0, 0, 23, 54, 65, 76, 85, 118, 128, 123, 111, 113, 118, 127, 125, 139, 133, 136, 160, 140, 155, 161, 144, 155, 172, 161, 189, 62 ], [ 0, 68, 94, 90, 111, 114, 111, 114, 115, 127, 135, 136, 143, 126, 127, 151, 154, 143, 148, 125, 162, 162, 144, 138, 153, 162, 196, 58 ], [ 70, 169, 129, 104, 98, 100, 94, 97, 98, 102, 108, 106, 119, 120, 129, 149, 156, 167, 190, 190, 196, 198, 198, 187, 197, 189, 184, 36 ], [ 16, 126, 171, 188, 188, 184, 171, 153, 135, 120, 126, 127, 146, 185, 195, 209, 208, 255, 209, 177, 245, 252, 251, 251, 247, 220, 206, 49 ], [ 0, 0, 0, 12, 67, 106, 164, 185, 199, 210, 211, 210, 208, 190, 150, 82, 8, 0, 0, 0, 178, 208, 188, 175, 162, 158, 151, 11 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]]])
test_model_class(model_file_path=__file__, model_class='XgbReg', task=TaskType.TABULAR_REGRESSION, dependencies={ModelDependency.XGBOOST: '0.90'}, queries=[{ 'CRIM': { 370: 6.53876 }, 'ZN': { 370: 0.0 }, 'INDUS': { 370: 18.1 }, 'CHAS': { 370: 1.0 }, 'NOX': { 370: 0.631 }, 'RM': { 370: 7.016 }, 'AGE': { 370: 97.5 }, 'DIS': { 370: 1.2024 }, 'RAD': { 370: 24.0 }, 'TAX': { 370: 666.0 }, 'PTRATIO': { 370: 20.2 }, 'B': { 370: 392.05 } }], train_dataset_uri=os.path.join(root, 'data/boston_train.csv'), test_dataset_uri=os.path.join(root, 'data/boston_test.csv'))
objective='multi:softmax', num_class=num_class) return clf if __name__ == '__main__': test_model_class(model_file_path=__file__, model_class='XgbClf', task=TaskType.TABULAR_CLASSIFICATION, dependencies={ModelDependency.XGBOOST: '0.90'}, train_dataset_uri=os.path.join(root, 'data/titanic_train.csv'), test_dataset_uri=os.path.join(root, 'data/titanic_test.csv'), queries=[{ 'Pclass': { 499: 3 }, 'Age': { 499: 24.0 }, 'Sex_female': { 499: 0 }, 'Sex_male': { 499: 1 } }], features=['Pclass', 'Sex', 'Age'], target='Survived')