Skip to main content

A Fast model parameter adjustment tool Using evolutionary thinking

Project description

lightgrid

A Fast model parameter adjustment tool .author email: yan_shw@dlmu.edu.cn

  • Applicable to all machine learning algorithms and deep learning algorithms conforming to sklearn code specification such as SVM,DecisionTree,XGBoost,lightGBM,RandomForest,catBoost and so on
  • Only rely on Python native code packages
  • Grid search speed is extremely fast than gridsearchCV
  • Adapt single parameter search and multiple parameter search .even both them can be setted to run in same process
  • Use given train data and test data to get the best parameter collection
  • Auto save Operation results and error log , facilitate offline training

Installation

Easiest way is to use pip:

	pip install lightgrid

Usage

To use the tool, the importance content is comprehend the difference between paramList and crossParamList.All keys in paramList are irrelevant. When the program runs, it will only search the optimal value of one key at a time, and then turn to the next. All keys in the crossParamList are related. When the program runs, it will search for the optimal value of the free combination of all keys in the crossParamList. Therefore, the conclusion of crossParamList is often more accurate but slower. Lightgrid allows you to set paramList and crossParamList at the same time to get the best effect, but it should be noted that there can be no key intersection between paramList and crossParamList, and the number of elements in crossParamList should be greater than 2. detail and example is given as bellow:

Parameters

IN

  • function: you should input a class name such as : test
  • paramList: independent features assemble . type as dict ,such as {'a':[1,2,3]}
  • crossParamList: features be valid in a crossed way . type as dict ,such as {'a':[1,2,3],'b':[1,2,3]} . default: {}
  • optimal_fun: optimal function ,option invoke 'R2_score' or 'succe_percent'. default :'succe_percent'
  • silent: boolean,Whether to output logs during program operation. default :True
  • save_model: boolean,save model or not. default :False
  • x_train :train collection feature data
  • y_train :train collection object data
  • x_val :test collection feature data
  • y_val :test collection object data

OUT

  • bst_param :the best parameter collection
  • bst_score :model performance under the best parameter collection and given test data

code example

from sklearn.tree import DecisionTreeClassifier  
from sklearn.datasets import load_breast_cancer
import lightgrid
data = load_breast_cancer()
x_train = data['data'][:400,:]
y_train = data['target'][:400]
x_val = data['data'][400:,:]
y_val = data['target'][400:]
DecisionTreeClassifier()

param_grid = {'max_depth':[10,20],
             'min_samples_split':[2,4,6,8,10],
             'min_samples_leaf':[1,3,5]
             }
autograd = lightgrid.lightgrid(DecisionTreeClassifier,param_grid,valid_times=1,save_model=False)
autograd.fit(x_train=x_train,y_train=y_train,x_val=x_val,y_val=y_val)
print('the best param is '+str(autograd.bst_param))
print('the best score is '+str(autograd.bst_score))

Algorithm Performance

Under different data sets, the comparison between lightgrid and gridsearchCV algorithm is shown in the table below. The reason for this situation is that lightgrid algorithm is more flexible and avoids meaningless calculation

All tests are run on a 12 core (hyperthreaded) Intel(R) Xeon(R) CPU E5-2678 v3.

Data Set Target lightgrid Time gridSearchCV Time lightgrid score gridSearchCV score
breast_cancer 0-1 0.76817s 1.93696s 0.91420 0.89940
digits 0-9 1.50722s 3.25618s 0.77365 0.7728
wine 0-3 0.11532s 0.50491s 0.38461 0.30769

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lightgrid-4.1.0.tar.gz (5.7 kB view details)

Uploaded Source

File details

Details for the file lightgrid-4.1.0.tar.gz.

File metadata

  • Download URL: lightgrid-4.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.12

File hashes

Hashes for lightgrid-4.1.0.tar.gz
Algorithm Hash digest
SHA256 f8bdc5be920ff7c8595f7df0dcee54b0952732ef7d00cbbc8459a07d7b736d92
MD5 d66648b3740caefee094fc8502dc852b
BLAKE2b-256 cb0cc224db64672629045bf467cba956d45cbf4719ef0633a546942a3199319a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page