-
Notifications
You must be signed in to change notification settings - Fork 105
Open
Labels
Description
add functionality required for this test load_collection & collect
| # TODO: add functionality required for this test load_collection & collect |
# limitations under the License.
#
import pytest
from pywy.dataquanta import WayangContext
from pywy.platforms.java import JavaPlugin
from pywy.platforms.spark import SparkPlugin
# TODO: add functionality required for this test load_collection & collect
@pytest.mark.skip(reason="no way of currently testing this, since we are missing implementations for load_collection & collect")
def test_train_and_predict():
ctx = WayangContext().register({JavaPlugin, SparkPlugin})
features = ctx.load_collection([[0.0, 1.0], [1.0, 0.0], [1.0, 1.0], [0.0, 0.0]])
labels = ctx.load_collection([1.0, 1.0, 0.0, 0.0])
model = features.train_linear_svc(labels, max_iter=10, reg_param=0.1)
predictions = model.predict(features)
result = predictions.collect()
print("Predictions:", result)
assert len(result) is 4, f"Expected len(result) to be 4, but got: {len(result)}"
for pred in result:
assert pred in [0.0, 1.0], f"Expected prediction to be in [0.0, 0.1], but got: {pred}"6bd117a221c0fa18b566075684463e7058390aca