-
Notifications
You must be signed in to change notification settings - Fork 5
Lior/dr #67
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
Open
liororama
wants to merge
3
commits into
master
Choose a base branch
from
lior/dr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Lior/dr #67
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| { | ||
| "version": 1, | ||
| "engineType": "Generic", | ||
| "language": "Python", | ||
| "userStandalone": false, | ||
| "name": "dataframe_stats", | ||
| "label": "DataFrame Statistics", | ||
| "description": "Generate statistics on the input dataframe.", | ||
| "program": "dataframe_stats.py", | ||
| "componentClass": "MCenterStatsComponentAdapter", | ||
| "modelBehavior": "Auxiliary", | ||
| "useMLOps": true, | ||
| "inputInfo": [ | ||
| { | ||
| "description": "In Pandas Dataframe", | ||
| "label": "dataframe", | ||
| "defaultComponent": "", | ||
| "type": "dataframe", | ||
| "group": "data" | ||
| } | ||
| ], | ||
| "outputInfo": [ | ||
| { | ||
| "description": "Out Pandas Dataframe", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out->Output |
||
| "label": "dataframe", | ||
| "defaultComponent": "", | ||
| "type": "dataframe", | ||
| "group": "data" | ||
| } | ||
| ], | ||
| "group": "FeatureEng", | ||
| "arguments": [ | ||
| { | ||
| "key": "dataframe_is", | ||
| "label": "Dataframe Is", | ||
| "description": "What is this dataframe represents", | ||
| "type": "string", | ||
| "uiType": "select", | ||
| "options": [ | ||
| { | ||
| "label": "Input Data", | ||
| "value": "input_data" | ||
| }, | ||
| { | ||
| "label": "Categorical Predictions Probabilities", | ||
| "value": "categorical_predictions_probabilities" | ||
| }, | ||
| { | ||
| "label": "Other", | ||
| "value": "other" | ||
| } | ||
| ], | ||
| "defaultValue": "input_data", | ||
| "optional": false | ||
| } | ||
| ] | ||
| } | ||
44 changes: 44 additions & 0 deletions
44
components/Python/Generic/dataframe_stats/dataframe_stats.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| from __future__ import print_function | ||
|
|
||
| from parallelm.components import ConnectableComponent | ||
| from parallelm.mlops import mlops as mlops | ||
| from parallelm.mlops.stats.bar_graph import BarGraph | ||
|
|
||
|
|
||
| class MCenterStatsComponentAdapter(ConnectableComponent): | ||
| def __init__(self, engine): | ||
| super(self.__class__, self).__init__(engine) | ||
|
|
||
| def _materialize(self, parent_data_objs, user_data): | ||
| mlops.init() | ||
|
|
||
| df = parent_data_objs[0] | ||
| dataframe_is = self._params.get("dataframe_is", "input_data") | ||
|
|
||
| if dataframe_is == "input_data": | ||
| self._handle_input_data(df) | ||
| elif dataframe_is == "categorical_predictions_probabilities": | ||
| self._handle_categorical_predictions(df) | ||
| elif dataframe_is == "other": | ||
| pass | ||
| else: | ||
| self._logger("Error: argument value is not supported: {}".format(dataframe_is)) | ||
|
|
||
| mlops.done() | ||
|
|
||
| return[df] | ||
|
|
||
| def _handle_input_data(self, df): | ||
| mlops.set_data_distribution_stat(df) | ||
|
|
||
| def _handle_categorical_predictions(self, df): | ||
|
|
||
| df_max_col = df.idxmax(axis=1) | ||
| series_value_count = df_max_col.value_counts(normalize=True) | ||
|
|
||
| col_values = [] | ||
| for col in df.columns: | ||
| col_values.append(series_value_count.at[col]) | ||
|
|
||
| bg = BarGraph().name("Categorical Prediction Distribution").cols(list(df.columns)).data(col_values) | ||
| mlops.set_stat(bg) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
38 changes: 38 additions & 0 deletions
38
components/Python/Generic/file_to_dataframe/component.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "version": 1, | ||
| "engineType": "Generic", | ||
| "language": "Python", | ||
| "userStandalone": false, | ||
| "name": "file_to_dataframe", | ||
| "label": "Source File to DataFrame", | ||
| "program": "file_to_dataframe.py", | ||
| "componentClass": "MCenterComponentAdapter", | ||
| "modelBehavior": "Auxiliary", | ||
| "useMLOps": true, | ||
| "inputInfo": [{ | ||
| "description": "File to read contents", | ||
| "label": "filename", | ||
| "defaultComponent": "", | ||
| "type": "str", | ||
| "group": "data" | ||
| }], | ||
| "outputInfo": [ | ||
| { | ||
| "description": "Pandas Dataframe", | ||
| "label": "dataframe", | ||
| "defaultComponent": "", | ||
| "type": "dataframe", | ||
| "group": "data" | ||
| } | ||
| ], | ||
| "group": "Connectors", | ||
| "arguments": [ | ||
| { | ||
| "key": "filename", | ||
| "label": "Dataset file to read", | ||
| "type": "str", | ||
| "description": "File to use for loading DataSet into DataFrame", | ||
| "optional": true | ||
| } | ||
| ] | ||
| } |
38 changes: 38 additions & 0 deletions
38
components/Python/Generic/file_to_dataframe/file_to_dataframe.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| from __future__ import print_function | ||
|
|
||
| import sys | ||
| import os | ||
| import pandas | ||
|
|
||
| from parallelm.components import ConnectableComponent | ||
|
|
||
|
|
||
| class MCenterComponentAdapter(ConnectableComponent): | ||
| """ | ||
| Adapter for read_file_to_df | ||
| """ | ||
|
|
||
| def __init__(self, engine): | ||
| super(self.__class__, self).__init__(engine) | ||
|
|
||
| def _materialize(self, parent_data_objs, user_data): | ||
| if len(parent_data_objs) is not 0: | ||
| file_path = str(parent_data_objs[0]) | ||
| else: | ||
| file_path = self._params.get('filename') | ||
|
|
||
| self._logger.info("file: {}".format(file_path)) | ||
| df = self.read_file_to_df(file_path) | ||
| return [df] | ||
|
|
||
| def read_file_to_df(self, filepath): | ||
| """ | ||
| Read file and return DataFrame | ||
| """ | ||
|
|
||
| if not os.path.exists(filepath): | ||
| self._logger.info("stderr- failed to find {}".format(filepath), file=sys.stderr) | ||
| raise Exception("file path does not exist: {}".format(filepath)) | ||
|
|
||
| df = pandas.read_csv(filepath) | ||
| return df |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "version": 1, | ||
| "engineType": "Generic", | ||
| "userStandalone": false, | ||
| "language": "Python", | ||
| "name": "string-sink", | ||
| "label": "Simple String Sink", | ||
| "program": "string_sink.py", | ||
| "componentClass": "StringSink", | ||
| "group": "Sinks", | ||
| "useMLOps": true, | ||
| "inputInfo": [ | ||
| { | ||
| "description": "String", | ||
| "label": "string", | ||
| "defaultComponent": "", | ||
| "type": "str", | ||
| "group": "data" | ||
| }], | ||
| "outputInfo": [], | ||
| "arguments": [ | ||
| { | ||
| "key": "expected-value", | ||
| "label": "Expected value to compare to", | ||
| "type": "str", | ||
| "description": "This is the value expected as input. If no value is provided no check is done", | ||
| "optional": true | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| from parallelm.components import ConnectableComponent | ||
|
|
||
|
|
||
| class StringSink(ConnectableComponent): | ||
|
|
||
| def __init__(self, engine): | ||
| super(self.__class__, self).__init__(engine) | ||
|
|
||
| def _materialize(self, parent_data_objs, user_data): | ||
| expected_str_value = self._params.get('expected-value', "") | ||
| actual_value = parent_data_objs[0] | ||
|
|
||
| if len(expected_str_value) > 0 and expected_str_value != actual_value: | ||
| raise Exception("Actual [{}] != Expected [{}]".format(actual_value, expected_str_value)) | ||
| return [] |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "version": 1, | ||
| "engineType": "Generic", | ||
| "userStandalone": false, | ||
| "language": "Python", | ||
| "name": "string-source", | ||
| "label": "Simple String Source", | ||
| "program": "string_source.py", | ||
| "componentClass": "StringSource", | ||
| "group": "Connectors", | ||
| "useMLOps": true, | ||
| "inputInfo": [], | ||
| "outputInfo": [ | ||
| { | ||
| "description": "String", | ||
| "label": "string", | ||
| "defaultComponent": "", | ||
| "type": "str", | ||
| "group": "data" | ||
| } | ||
| ], | ||
| "arguments": [ | ||
| { | ||
| "key": "value", | ||
| "type": "str", | ||
| "label": "String value", | ||
| "description": "String value to provide as output", | ||
| "optional": false | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from parallelm.components import ConnectableComponent | ||
|
|
||
|
|
||
| class StringSource(ConnectableComponent): | ||
|
|
||
| def __init__(self, engine): | ||
| super(self.__class__, self).__init__(engine) | ||
|
|
||
| def _materialize(self, parent_data_objs, user_data): | ||
| str_value = self._params.get('value', "default-string-value") | ||
| return [str_value] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In->Input