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

MLeap Scikit Example Broken #367

Closed
donigian opened this issue May 20, 2018 · 10 comments
Closed

MLeap Scikit Example Broken #367

donigian opened this issue May 20, 2018 · 10 comments
Assignees

Comments

@donigian
Copy link

donigian commented May 20, 2018

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.

@donigian donigian changed the title AttributeError: 'function' object has no attribute 'im_class' MLeap Scikit Example Broken May 20, 2018
@MTDzi
Copy link

MTDzi commented Jun 7, 2018

Same here.

@ksoucy
Copy link

ksoucy commented 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.

@ancasarb
Copy link
Member

ancasarb commented Jul 6, 2018

@donigian @MTDzi Yes, @ksoucy is right, we merged #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.

@andyliucoder
Copy link

Ran into this error, so I'm assuming a new version hasn't been published to pypi yet?

Just to be clear, line 90 of data.py needs to be changed to class_name = self.__class__.__name__ (github formatting rendered the underscores in @ksoucy's answer.

@dat-vikash
Copy link

ran into this issue as well ... any updates on when this will be pypi?

@nsutcliffe
Copy link

Also just ran into the same issue 👎

@ancasarb ancasarb self-assigned this Mar 3, 2019
@gyubaekkim
Copy link

I tested the workaround that @ksoucy and @andyliucoder suggested but it doesn't work.
Is there any other workaround to be applied before this issue is fixed?

Thanks.

@ericx10ng
Copy link

ran into the same error

@lalith1403
Copy link

works only with Python 2.7. Python3 gives the following error.

@ancasarb
Copy link
Member

ancasarb commented Mar 9, 2020

We added support for Python 3 as part of Mleap 0.15.0, you can see the tests running successfully against Python 2.7, 3.6 and 3.7 in the Travis CI https://travis-ci.org/combust/mleap. Closing this, please let me know and feel free to re-open if you still find issues in Python 3. Thank you!

@ancasarb ancasarb closed this as completed Mar 9, 2020
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

No branches or pull requests

10 participants