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 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 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)