Coder Social home page Coder Social logo

gkuo06 / parfit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jmcarpenter2/parfit

0.0 0.0 0.0 1.57 MB

A package for parallelizing the fit and flexibly scoring of sklearn machine learning models, with visualization routines.

License: MIT License

Python 100.00%

parfit's Introduction

parfit

A package for parallelizing the fit and flexibly scoring of sklearn machine learning models, with visualization routines.

This python package is NO LONGER MAINTAINED.

Alternatives

There are several fantastic alternatives that serve the same purpose as parfit, but do it even better.

Below I list a few libraries that are very effective at solving the particular problem that parfit originally aimed to solve.

Hyper-parameter optimization

Visualization of hyper-parameter optimizations

Deprecated

CURRENT VERSION == 0.220

Installation:

$pip install parfit # first time installation
$pip install -U parfit # upgrade to latest version

and then import into your code using:

from parfit import bestFit # Necessary if you wish to use bestFit

# Necessary if you wish to run each step sequentially
from parfit.fit import *
from parfit.score import *
from parfit.plot import *
from parfit.crossval import *

Once imported, you can use bestFit() or other functions freely.

Easy to use

grid = {
    'min_samples_leaf': [1, 5, 10, 15, 20, 25],
    'max_features': ['sqrt', 'log2', 0.5, 0.6, 0.7],
    'n_estimators': [60],
    'n_jobs': [-1],
    'random_state': [42]
}
paramGrid = ParameterGrid(grid)

best_model, best_score, all_models, all_scores = bestFit(RandomForestClassifier(), paramGrid,
                                                    X_train, y_train, X_val, y_val, # nfolds=5 [optional, instead of validation set]
                                                    metric=roc_auc_score, greater_is_better=True, 
                                                    scoreLabel='AUC')

print(best_model, best_score)
{max_features': 'sqrt', 'min_samples_leaf': 1, 'n_estimators': 60, 'n_jobs': -1, 'random_state': 42}
0.9627794057231478

Interpretable Visualizations

Alt text

Notes

  1. You can either use bestFit() to automate the steps of the process, and optionally plot the scores over the parameter grid, OR you can do each step in order:

fitModels() -> scoreModels() -> plotScores() -> getBestModel() -> getBestScore()

or

crossvalModels() -> plotScores() -> getBestModel() -> getBestScore()

  1. Be sure to specify ALL parameters in the ParameterGrid, even the ones you are not searching over.

  2. For example usage, see parfit_ex.ipynb. Each function is well-documented in the .py file. In Jupyter Notebooks, you can see the docs by pressing Shift+Tab(x3). Also, check out the complete documentation here along with the changelog.

  3. This package is designed for use with sklearn machine learning models, but in theory will work with any model that has a .fit(X,y) function. Furthermore, the sklearn scoring metrics are typically used, but any function that reads in two vectors and returns a score will work.

  4. The plotScores() function will only work for up to a 3D parameterGrid object. That is, you can only view the scores of a grid varying over 1-3 parameters. Other parameters which do not vary can still be set, and you can still train and scores models over a higher dimensional grid.

parfit's People

Contributors

bharathgs avatar jmcarpenter2 avatar

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.