Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add primitives to use Ballet together with MLBlocks #86

Merged
merged 4 commits into from Jun 6, 2021

Conversation

micahjsmith
Copy link
Contributor

  • the ballet.engineer_features primitive applies a given project's feature engineering pipeline
  • the ballet.encode_target primitive applies a given project's target encoder
  • two sample pipelines are included that put these two steps together with either RF classifier or regressor
  • a ballet.decode_target primitive may be necessary in the future but is not implemented here: (1) the target encoder is not necessarily reversible (2) the primitive needs to be able to restore its state from the context similar to class decoder

Example usage (for predict-census-income):

import mlblocks
from ballet import b
from sklearn.metrics import classification_report

X_df, y_df = b.api.load_data()
X_df_te, y_df_te = b.api.load_data(input_dir='data/val')

encoder = b.api.encoder
y = encoder.fit_transform(y_df)
y_te = encoder.transform(y_df_te)

pipeline_info = mlblocks.load_pipeline('ballet_rf_classifier')
pipeline = mlblocks.MLPipeline(pipeline_info)

pipeline.fit(X_df, y_df)

y_pred = pipeline.predict(X_df)
report = classification_report(y, y_pred, output_dict=True)

y_pred_te = pipeline.predict(X_df_te)
report_te = classification_report(y_te, y_pred_te, output_dict=True)

@micahjsmith micahjsmith merged commit b8991e8 into master Jun 6, 2021
@micahjsmith micahjsmith deleted the engineer-features-primitive branch June 6, 2021 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant