@@ -2040,25 +2040,25 @@ def test_predict_contrib_int64():
20402040 assert preds .shape [1 ] == X_test .shape [1 ] + 1
20412041
20422042
2043- # @pytest.mark.skipif(psutil.virtual_memory().available / 1024 / 1024 / 1024 < 3, reason="not enough RAM")
2044- # def test_int32_max_sparse_contribs(rng):
2045- # params = {"objective": "binary"}
2046- # train_features = rng.uniform(size=(100, 1000))
2047- # train_targets = [0] * 50 + [1] * 50
2048- # lgb_train = lgb.Dataset(train_features, train_targets)
2049- # gbm = lgb.train(params, lgb_train, num_boost_round=2)
2050- # csr_input_shape = (3000000, 1000)
2051- # test_features = csr_matrix(csr_input_shape)
2052- # for i in range(0, csr_input_shape[0], csr_input_shape[0] // 6):
2053- # for j in range(0, 1000, 100):
2054- # test_features[i, j] = random.random()
2055- # y_pred_csr = gbm.predict(test_features, pred_contrib=True)
2056- # # Note there is an extra column added to the output for the expected value
2057- # csr_output_shape = (csr_input_shape[0], csr_input_shape[1] + 1)
2058- # assert y_pred_csr.shape == csr_output_shape
2059- # y_pred_csc = gbm.predict(test_features.tocsc(), pred_contrib=True)
2060- # # Note output CSC shape should be same as CSR output shape
2061- # assert y_pred_csc.shape == csr_output_shape
2043+ @pytest .mark .skipif (psutil .virtual_memory ().available / 1024 / 1024 / 1024 < 3 , reason = "not enough RAM" )
2044+ def test_int32_max_sparse_contribs (rng ):
2045+ params = {"objective" : "binary" }
2046+ train_features = rng .uniform (size = (100 , 1000 ))
2047+ train_targets = [0 ] * 50 + [1 ] * 50
2048+ lgb_train = lgb .Dataset (train_features , train_targets )
2049+ gbm = lgb .train (params , lgb_train , num_boost_round = 2 )
2050+ csr_input_shape = (3000000 , 1000 )
2051+ test_features = csr_matrix (csr_input_shape )
2052+ for i in range (0 , csr_input_shape [0 ], csr_input_shape [0 ] // 6 ):
2053+ for j in range (0 , 1000 , 100 ):
2054+ test_features [i , j ] = random .random ()
2055+ y_pred_csr = gbm .predict (test_features , pred_contrib = True )
2056+ # Note there is an extra column added to the output for the expected value
2057+ csr_output_shape = (csr_input_shape [0 ], csr_input_shape [1 ] + 1 )
2058+ assert y_pred_csr .shape == csr_output_shape
2059+ y_pred_csc = gbm .predict (test_features .tocsc (), pred_contrib = True )
2060+ # Note output CSC shape should be same as CSR output shape
2061+ assert y_pred_csc .shape == csr_output_shape
20622062
20632063
20642064def test_sliced_data (rng ):
0 commit comments