Пример #1
0
    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()
Пример #2
0
    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)
Пример #3
0
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)
Пример #4
0
    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)
Пример #5
0
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)
Пример #6
0
 def testLocalTrainDataFrame(self):
     dtrain = MarsDMatrix(self.X_df, self.y_series)
     booster = train({}, dtrain, num_boost_round=2)
     self.assertIsInstance(booster, Booster)
Пример #7
0
 def testLocalTrainSparseTensor(self):
     dtrain = MarsDMatrix(self.X_sparse, self.y)
     booster = train({}, dtrain, num_boost_round=2)
     self.assertIsInstance(booster, Booster)
Пример #8
0
def test_local_train_dataframe(setup):
    dtrain = MarsDMatrix(X_df, y_series)
    booster = train({}, dtrain, num_boost_round=2)
    assert isinstance(booster, Booster)
Пример #9
0
def test_local_train_sparse_tensor(setup):
    dtrain = MarsDMatrix(X_sparse, y)
    booster = train({}, dtrain, num_boost_round=2)
    assert isinstance(booster, Booster)
Пример #10
0
 def testLocalTrainTensor(self):
     new_session().as_default()
     dtrain = MarsDMatrix(self.X, self.y)
     booster = train({}, dtrain, num_boost_round=2)
     self.assertIsInstance(booster, Booster)