Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/python/nimbusml.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@
<Compile Include="nimbusml\ensemble\sub_model_selector\__init__.py" />
<Compile Include="nimbusml\ensemble\sub_model_selector\diversity_measure\classifierdisagreement.py" />
<Compile Include="nimbusml\ensemble\sub_model_selector\diversity_measure\regressordisagreement.py" />
<Compile Include="nimbusml\ensemble\sub_model_selector\diversity_measure\__init__.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="nimbusml\ensemble\sub_model_selector\diversity_measure\__init__.py" />
<Compile Include="nimbusml\ensemble\subset_selector\allinstanceselector.py" />
<Compile Include="nimbusml\ensemble\subset_selector\bootstrapselector.py" />
<Compile Include="nimbusml\ensemble\subset_selector\randompartitionselector.py" />
Expand Down
56 changes: 42 additions & 14 deletions src/python/nimbusml/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from scipy.sparse import csr_matrix
from sklearn.utils.validation import check_X_y, check_array
from sklearn.utils.multiclass import unique_labels
from zipfile import ZipFile

from .internal.core.base_pipeline_item import BasePipelineItem
from .internal.entrypoints.data_customtextloader import \
Expand All @@ -40,6 +41,8 @@
from .internal.entrypoints.models_summarizer import models_summarizer
from .internal.entrypoints.transforms_datasetscorer import \
transforms_datasetscorer
from .internal.entrypoints.transforms_datasettransformscorer import \
transforms_datasettransformscorer
from .internal.entrypoints.transforms_featurecombiner import \
transforms_featurecombiner
from .internal.entrypoints.transforms_featurecontributioncalculationtransformer import \
Expand Down Expand Up @@ -1816,22 +1819,43 @@ def _predict(self, X, y=None,
isinstance(X, DataFrame) and isinstance(y, (str, tuple))):
y = y_temp

model_zip = ZipFile(self.model)

@ganik ganik Aug 15, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you unpacking zip file? #ByDesign

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its actually doesnt unpack the content, just reads the list of directories/entries,so it should not be intensive operation


In reply to: 314144315 [](ancestors = 314144315)

@pieths pieths Aug 21, 2019

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a with statement so that model_zip is closed after the next line executes? Or, should model_zip be closed after it is used? #Resolved

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, made a change


In reply to: 316409298 [](ancestors = 316409298)

is_transformer_chain = any('TransformerChain' in item
for item in model_zip.namelist())

all_nodes = []
inputs = dict([('data', ''), ('predictor_model', self.model)])
if isinstance(X, FileDataStream):
importtext_node = data_customtextloader(
input_file="$file",
if is_transformer_chain:
inputs = dict([('data', ''), ('transform_model', self.model)])
if isinstance(X, FileDataStream):
importtext_node = data_customtextloader(
input_file="$file",
data="$data",
custom_schema=schema.to_string(
add_sep=True))
all_nodes = [importtext_node]
inputs = dict([('file', ''), ('transform_model', self.model)])

score_node = transforms_datasettransformscorer(
data="$data",
custom_schema=schema.to_string(
add_sep=True))
all_nodes = [importtext_node]
inputs = dict([('file', ''), ('predictor_model', self.model)])

score_node = transforms_datasetscorer(
data="$data",
predictor_model="$predictor_model",
scored_data="$scoredVectorData")
all_nodes.extend([score_node])
transform_model="$transform_model",
scored_data="$scoredVectorData")
all_nodes.extend([score_node])
else:
inputs = dict([('data', ''), ('predictor_model', self.model)])
if isinstance(X, FileDataStream):
importtext_node = data_customtextloader(
input_file="$file",
data="$data",
custom_schema=schema.to_string(
add_sep=True))
all_nodes = [importtext_node]
inputs = dict([('file', ''), ('predictor_model', self.model)])

score_node = transforms_datasetscorer(
data="$data",
predictor_model="$predictor_model",
scored_data="$scoredVectorData")
all_nodes.extend([score_node])

if (evaltype in ['binary', 'multiclass']) or \
(hasattr(self, 'steps')
Expand Down Expand Up @@ -1889,6 +1913,10 @@ def _predict(self, X, y=None,
self._run_time = time.time() - start_time
raise e

if is_transformer_chain:
out_data['PredictedLabel'] = out_data['PredictedLabel']*1


if y is not None:
# We need to fix the schema for ranking metrics
if evaltype == 'ranking':
Expand Down