Code Monkey home page Code Monkey logo

intake-sklearn's Introduction

intake_sklearn

Intake plugin to load Scikit-Learn model pickle files

  • Declare locations of model pickle files
  • Declare required packages and check for version compatibility
  • Standardize model loading for various model types
    • Scikit-Learn, and eventually XGBoost, Keras/Tensorflow, Dask-ML, etc.

Sklearn driver

import intake

model_source = intake.open_sklearn('optimized_model.pkl')
model_source
<intake_sklearn.source.SklearnModelSource at 0x1143d7a50>
model = model_source.read()
model
    Pipeline(memory=None,
             steps=[('standardscaler',
                     StandardScaler(copy=True, with_mean=True, with_std=True)),
                    ('gradientboostingregressor',
                     GradientBoostingRegressor(alpha=0.9, criterion='friedman_mse',
                                               init=None, learning_rate=0.1,
                                               loss='ls', max_depth=3,
                                               max_features=None,
                                               max_leaf_nodes=None,
                                               min_impurity_decrease=0.0,
                                               min_impurity_split=None,
                                               min_samples_leaf=1,
                                               min_samples_split=2,
                                               min_weight_fraction_leaf=0.0,
                                               n_estimators=100,
                                               n_iter_no_change=None,
                                               presort='auto', random_state=None,
                                               subsample=1.0, tol=0.0001,
                                               validation_fraction=0.1, verbose=0,
                                               warm_start=False))],
             verbose=False)

Incompatible versions?

old_model_source = intake.open_sklearn('old_model.pkl')
old_model_source.read()
    ---------------------------------------------------------------------------

    RuntimeError                              Traceback (most recent call last)

    <ipython-input-3-5b1fd5628c1f> in <module>
          1 old_model_source = intake.open_sklearn('old_model.pkl')
    ----> 2 old_model_source.read()
    

    ~/Development/intake_sklearn/intake_sklearn/source.py in read(self)
         60                    'but version {} has been installed in your current environment.'
         61                   ).format(self.metadata['sklearn_version'], sklearn.__version__)
    ---> 62             raise RuntimeError(msg)
         63 
         64 


    RuntimeError: The model was created with Scikit-Learn version 0.20.1 but version 0.21.3 has been installed in your current environment.

Catalogs

Store models wherever FSSpec can access them. You will need also install appropriate packages (s3fs, etc.)

s3_model = cat.s3_model.read()
data = [
    85.5,  # Max temperature
    6,     # Month
    False, # Holiday
    True,  # Weekend
    True   # home game
]

value = s3_model.predict([data])
array([448.81569766])

What's next?

  • Is pickle the best (or only format)?

    • I've had luck with JSONPickle model files, except DecisionTree
  • Add more drivers

    • XGBoost, Keras/Tensorflow, Dask-ML
  • ONNX getting better

  • pipeline viz PR in Sklearn

intake-sklearn's People

Contributors

albertdefusco avatar

Stargazers

 avatar

Watchers

 avatar  avatar

intake-sklearn's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.