question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MLeap Scikit Example Broken

See original GitHub issue

Hi, I tried to get the Scikit-learn example from the documentation to work

# Initialize a FeatureExtractor, which subselects only the features we want
# to run the Standard Scaler against
input_features = ['a', 'c', 'd']
output_vector_name = 'unscaled_continuous_features' # Used only for serialization purposes
output_features = ["{}_scaled".format(x) for x in input_features]

feature_extractor_tf = FeatureExtractor(input_scalars=input_features,
                                        output_vector=output_vector_name,
                                        output_vector_items=output_features)


# Define the Standard Scaler as we normally would
standard_scaler_tf = StandardScaler(with_mean=True,
                                    with_std=True)

# Execute ML-Init to add the require attributes to the transformer object
# Op and Name will be initialized automatically
standard_scaler_tf.mlinit(prior_tf=feature_extractor_tf,
                          output_features='scaled_continuous_features')

But ran into the following error:


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-a38e6a0355a2> in <module>()
     17 # Op and Name will be initialized automatically
     18 standard_scaler_tf.mlinit(prior_tf=feature_extractor_tf,
---> 19                           output_features='scaled_continuous_features')

/Users/avd/anaconda/envs/py35_auto_/lib/python3.5/site-packages/mleap/sklearn/preprocessing/data.py in mleap_init(self, prior_tf, output_features)
     88         output_feature_name = prior_tf.output_features
     89 
---> 90     class_name = "{}".format(self.__init__.im_class).split('.')[-1].replace('>','').replace("'",'')
     91 
     92     if output_features is not None:

AttributeError: 'function' object has no attribute 'im_class'

Any suggestions?

AirBnb price regression example breaks due to the same error.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ancasarbcommented, Jul 6, 2018

@donigian @MTDzi Yes, @ksoucy is right, we merged https://github.com/combust/mleap/pull/344 in order to make mleap scikit-learn work with python 3.

I’ll try to get a new version of the package published to pypi so that you don’t need to rebuild from source.

1reaction
ksoucycommented, Jun 19, 2018

I experienced the same issue, it looks related to changes made in #344 which were merged to master.

If you change line 90 in your local /Users/avd/anaconda/envs/py35_auto_mrm/lib/python3.5/site-packages/mleap/sklearn/preprocessing/data.py file, to match the master branch, the demo notebook works:

  • class_name = “{}”.format(self.init.im_class).split(‘.’)[-1].replace(‘>’,‘’).replace(“'”,‘’)
  • class_name = self.class.name

Alternatively, you could also rebuild from source from the current master branch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MLeap broken with Skicit-learn when serialising: object has ...
1 Answer 1 ... I found the solution. ... was missing. You can also use a pipeline to do that: from mleap.sklearn.logistic import...
Read more >
combust/mleap - Scaladex
MLeap allows data scientists and engineers to deploy machine learning pipelines from Spark and Scikit-learn to a portable format and execution engine.
Read more >
combust/mleap - Gitter
I had to migrate to sbt 1.+ recently in order to enable a scalapb/java upgrade (combust/mleap#818) and it looks like something broke in...
Read more >
MLeap Model Export Demo (Python) - Databricks
MLeap is a common serialization format and execution engine for machine learning pipelines. It supports Apache Spark, scikit-learn, and TensorFlow for ...
Read more >
Source code for mlflow.mleap
NOTE: You cannot load the MLeap model flavor in Python; you must download it ... code-block:: python :caption: Example import mlflow import mlflow.mleap...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found