def testDmatrix(self): x = self.X cond = x[:, 0] < 1 x = x[cond] y = self.y[cond] # reset shape to mock the case that tileable's shape is doomed, # but chunks do not y._shape = self.y.shape dmatrix = MarsDMatrix(x, y) dmatrix.execute()
def testLocalPredictDataFrame(self): dtrain = MarsDMatrix(self.X_df, self.y_series) booster = train({}, dtrain, num_boost_round=2) self.assertIsInstance(booster, Booster) prediction = predict(booster, self.X_df) self.assertIsInstance(prediction.to_pandas(), pd.Series)
def test_local_predict_dataframe(setup): dtrain = MarsDMatrix(X_df, y_series) booster = train({}, dtrain, num_boost_round=2) assert isinstance(booster, Booster) prediction = predict(booster, X_df) assert isinstance(prediction.to_pandas(), pd.Series)
def testLocalPredictTensor(self): dtrain = MarsDMatrix(self.X, self.y) booster = train({}, dtrain, num_boost_round=2) self.assertIsInstance(booster, Booster) prediction = predict(booster, self.X) self.assertIsInstance(prediction.to_numpy(), np.ndarray) prediction = predict(booster, dtrain) self.assertIsInstance(prediction.fetch(), np.ndarray) with self.assertRaises(TypeError): predict(None, self.X)
def test_local_predict_tensor(setup): dtrain = MarsDMatrix(X, y) booster = train({}, dtrain, num_boost_round=2) assert isinstance(booster, Booster) prediction = predict(booster, X) assert isinstance(prediction.to_numpy(), np.ndarray) prediction = predict(booster, X_sparse) assert isinstance(prediction.to_numpy(), np.ndarray) prediction = predict(booster, dtrain) assert isinstance(prediction.fetch(), np.ndarray) with pytest.raises(TypeError): predict(None, X)
def testLocalTrainDataFrame(self): dtrain = MarsDMatrix(self.X_df, self.y_series) booster = train({}, dtrain, num_boost_round=2) self.assertIsInstance(booster, Booster)
def testLocalTrainSparseTensor(self): dtrain = MarsDMatrix(self.X_sparse, self.y) booster = train({}, dtrain, num_boost_round=2) self.assertIsInstance(booster, Booster)
def test_local_train_dataframe(setup): dtrain = MarsDMatrix(X_df, y_series) booster = train({}, dtrain, num_boost_round=2) assert isinstance(booster, Booster)
def test_local_train_sparse_tensor(setup): dtrain = MarsDMatrix(X_sparse, y) booster = train({}, dtrain, num_boost_round=2) assert isinstance(booster, Booster)
def testLocalTrainTensor(self): new_session().as_default() dtrain = MarsDMatrix(self.X, self.y) booster = train({}, dtrain, num_boost_round=2) self.assertIsInstance(booster, Booster)