593b94c120
pytest / Unit Tests (push) Has been cancelled
pytest / Integration (integration_tests_a) (push) Has been cancelled
pytest / Integration (integration_tests_b) (push) Has been cancelled
pytest / Integration (integration_tests_c) (push) Has been cancelled
pytest / Integration (integration_tests_d) (push) Has been cancelled
pytest / Integration (integration_tests_e) (push) Has been cancelled
pytest / Integration (integration_tests_f) (push) Has been cancelled
pytest / Integration (integration_tests_g) (push) Has been cancelled
pytest / Integration (integration_tests_h) (push) Has been cancelled
pytest / Integration (integration_tests_i) (push) Has been cancelled
pytest / Integration (integration_tests_j) (push) Has been cancelled
pytest / Distributed (distributed_a) (push) Has been cancelled
pytest / Distributed (distributed_b) (push) Has been cancelled
pytest / Distributed (distributed_c) (push) Has been cancelled
pytest / Distributed (distributed_d) (push) Has been cancelled
pytest / Distributed (distributed_e) (push) Has been cancelled
pytest / Distributed (distributed_f) (push) Has been cancelled
pytest / Minimal Install (push) Has been cancelled
pytest / Event File (push) Has been cancelled
pytest (slow) / py-slow (push) Has been cancelled
Publish JSON Schema / publish-schema (push) Has been cancelled
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
import logging
|
|
|
|
import pandas as pd
|
|
|
|
from ludwig.api import LudwigModel
|
|
from ludwig.datasets import amazon_employee_access_challenge
|
|
|
|
df = amazon_employee_access_challenge.load()
|
|
|
|
model = LudwigModel(config="config.yaml", logging_level=logging.INFO)
|
|
|
|
training_statistics, preprocessed_data, output_directory = model.train(
|
|
df,
|
|
skip_save_processed_input=True,
|
|
skip_save_log=True,
|
|
skip_save_progress=True,
|
|
skip_save_training_description=True,
|
|
skip_save_training_statistics=True,
|
|
)
|
|
|
|
# Predict on unlabeled test
|
|
config = model.config
|
|
config["preprocessing"] = {}
|
|
model.config = config
|
|
unlabeled_test = df[df.split == 2].reset_index(drop=True)
|
|
preds, _ = model.predict(unlabeled_test)
|
|
|
|
# Save predictions to csv
|
|
action = preds.ACTION_probabilities_True
|
|
submission = pd.merge(unlabeled_test.reset_index(drop=True).id.astype(int), action, left_index=True, right_index=True)
|
|
submission.rename(columns={"ACTION_probabilities_True": "Action", "id": "Id"}, inplace=True)
|
|
submission.to_csv("submission.csv", index=False)
|