NIML Base Estimator Wrapper GridSearchCV

The following code is a detailed demonstration on how to run GridSearchCV on the NIML model using a Base Estimator wrapper. Since GridSearch is an exhaustive search means, it is suggested to be used in a situation where a good model is already found and improvements on it are theorized to occur with a specific set of parameters.

import csv
import json
import numpy as np
from niml.encoder import encoder
from pooler_module import Pooler
from sklearn.neighbors import KNeighborsClassifier
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.model_selection import GridSearchCV, RandomizedSearchCV, ShuffleSplit
import pandas as pd
from sklearn.utils.estimator_checks import check_estimator
import time
import os

If you do not already have train and test dataset, load in the desired dataset and split it into a train and test subsets

def load_1hat_cvs_dataset(ds_filename, dup=0, rs=592):
    with open(ds_filename, 'r') as raw_data_fh:
        raw_data = list(csv.reader(raw_data_fh, delimiter = ','))
    full_data = []
    for line in raw_data:
        this_obs = [line[0]]
        this_obs.extend(list(map(float, line[1:])))
        full_data.append(this_obs)
    extended_ds = full_data
    for x in range(dup):
        extended_ds.extend(full_data)
    train,test = train_test_split(extended_ds, test_size=0.20, random_state=rs)
    return train,test,full_data

train,test,full_data = load_1hat_cvs_dataset('wbc_sklearn_labeled_data.csv')

Construct a default pooler object that will be used by the estimator. A Base Estimator requires default values for every variable, some of these values will be overwritten given the hyperparameters you provide.

estimator_p = Pooler(
    # Encoder/Data parameters
    sdr_width=784,
    enc_set_bits=4,
    enc_sparsity=0.25,
    enc_missing_val_ind = "?",
    tts_test_size = 0.20, #Set encoding train_test_split test size
    tts_random_state = np.random.RandomState(seed=592), #Set encoding train_test_split random_state
    
    # NPU
    neurons=500,
    active_neurons=5,
    input_pct=0.75,
    seed= 123, #Typically the arg seed
    synapse_inc=5,
    synapse_dec=1,
    activity_reset_cnt=50,
    decay_cnt_target=10,
    learning=True,
    
    # Boosting
    boost_max=0.9,
    boost_str=2,
    boost_tbl_size=21,
    boost_tbl_step=0.03,
    
    # Classifier
    classifier_ = KNeighborsClassifier(n_neighbors=3), # Set the classifier
)

Define the type of scoring you would like to use, as well as number of cross-validation jobs, total searches, number of jobs to run in parallel, and whether or not you'd like to training scores to be included in the resulting CSV.

SCORING = 'f1_weighted'
NUM_CV_JOBS = 2 #Default is 2
NUM_SEARCHES = 1 #Default is 1
NUM_PARALLEL_JOBS = 1 #Default is all (-1)
TRAIN = True  # whether to include training scores or not

Define the dictionary of hyperparameters over which you would like to perfom a Grid Search. Since this search is exhaustive, the smaller you keep this dictionary the less time it will take for the search to complete.

param_dis = {
    'neurons': [1000],
    'active_neurons' : [500, 600, 700, 1100],
    'input_pct': [0.25],
    'synapse_inc': [17],
    'synapse_dec': [9],
    'activity_reset_cnt': [50],
    'enc_set_bits': [3, 5, 7],
    'enc_sparsity': [0.5],
    'boost_max': [0.9],
    'boost_str': [1],
    'boost_tbl_size': [21],
    'boost_tbl_step': [0.66],
}

Declare the search model you would like to use and pass it the Pooler object created before as the estimator, the desired parameter dictionary, the desired scoring, how many cross-validaiton jobs to perfom, how many parallel jobs to run, whether or not you would like to return the results of the train dataset, and how many messages you would like print as searches are completed.

search = GridSearchCV(
    estimator=estimator_p,
    param_grid=param_dis,
    scoring=SCORING,
    cv=NUM_CV_JOBS,
    n_jobs=NUM_PARALLEL_JOBS,
    return_train_score=TRAIN,
    verbose=3
)
print("Grid search - %d searches x %d cross validations" % (NUM_SEARCHES, NUM_CV_JOBS))
Grid search - 1 searches x 2 cross validations

Configure the train and test data and encode them.

pd_df_train = pd.DataFrame(train)
pd_df_test = pd.DataFrame(test)
estimator_p._get_dtypes()
estimator_p._configure_encoder_params()
estimator_p.encoder_ = estimator_p._create_encoder(full_data) # Use full dataset as the _create_encoder performs a train_test_split and configs encoder on the train split 
train_labels, train_isdrs, sdr_width = estimator_p.encoder_.encode(input_data=pd_df_train.iloc[:, 1:], label_col=None)
test_labels, test_isdrs, sdr_width = estimator_p.encoder_.encode(input_data=pd_df_test.iloc[:, 1:], label_col=None)
# Flatten and convert into integers
train_labels = [int(train[index][0]) for index in range(len(train))]
# Flatten and convert into integers
test_labels = [int(test[index][0]) for index in range(len(test))]
df = pd.DataFrame()

Determine how many time you would like to perform a Grid Search. Only one run is necessary as each combination of parameters will be tested.

runs = 1 # Total number of runs to perfrom (Default 1)

Declare the name of the resulting pooler state files (JSON and binary) and CSV you would like to save.

pooler_file = "JupyterNB_Grid"
csv_file = "JupyterNB_Grid"

Define what parameters will be saved in the CSV file.

params = ['sdr_width', 'neurons', 'active_neurons', 'input_pct', 'seed', 'synapse_inc',
            'synapse_dec', 'activity_reset_cnt', 'decay_cnt_target', 'feat_count', 'boost_max', 
            'boost_str', 'boost_tbl_size', 'boost_tbl_step', 'enc_set_bits', 'enc_sparsity', 'enc_missing_val_ind',
            'learning']

Perform as many runs as declared previosuly by running a fit on the train data and searching for the best scoring Base Estimator.

best_score = 0
best_score_params = []
run_count = 0
while (run_count < runs):
    print("#############################################")
    print("Run %d" % run_count)
    search.fit(train_isdrs,train_labels)
    clf = search.best_estimator_
    print("params:", search.best_estimator_.get_params())
    print("score:", search.best_score_)
    run_count = run_count + 1
    ### Keep track of the best overall score
    if search.best_score_ >= best_score:
        best_score = search.best_score_
        best_score_params = search.best_estimator_.get_params()
        search.best_estimator_.save_pooler("%s_pooler.bin" % pooler_file, format="bin")
        search.best_estimator_.save_pooler("%s_pooler.json" % pooler_file)
        
    ## Save the CSV after each run, so no data is lost
    clf_params = clf.get_params()
    defaults = {}
    for param in params:
        if param in clf_params:
            defaults[f'param_{param}'] = clf_params[param] 
    df_ap = pd.DataFrame(search.cv_results_)
    for param, val in defaults.items():
        if param not in df.columns:
            df[params] = val
    df = df.append(df_ap, ignore_index=True)
    name = csv_file + "_RUNNING.csv"
    df.to_csv("%s" % name) # Save the CSV in case of the user cancelling a run, or error
    print("Saved running file %s" % name)
#############################################
Run 0
Fitting 2 folds for each of 12 candidates, totalling 24 fits
[CV] active_neurons=500, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 


[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.


[CV]  active_neurons=500, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.969, test=0.943), total=  10.9s
[CV] active_neurons=500, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 


[Parallel(n_jobs=1)]: Done   1 out of   1 | elapsed:   11.3s remaining:    0.0s


[CV]  active_neurons=500, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.965, test=0.942), total=  10.3s
[CV] active_neurons=500, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 


[Parallel(n_jobs=1)]: Done   2 out of   2 | elapsed:   22.0s remaining:    0.0s


[CV]  active_neurons=500, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.965, test=0.943), total=  10.6s
[CV] active_neurons=500, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=500, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.965, test=0.947), total=  10.8s
[CV] active_neurons=500, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=500, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.965, test=0.943), total=  10.8s
[CV] active_neurons=500, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=500, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.965, test=0.947), total=  10.9s
[CV] active_neurons=600, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=600, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.969, test=0.943), total=  11.9s
[CV] active_neurons=600, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=600, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.969, test=0.956), total=  11.4s
[CV] active_neurons=600, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=600, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.973, test=0.952), total=  12.1s
[CV] active_neurons=600, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=600, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.965, test=0.951), total=  12.2s
[CV] active_neurons=600, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=600, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.973, test=0.952), total=  12.1s
[CV] active_neurons=600, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=600, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.965, test=0.951), total=  11.7s
[CV] active_neurons=700, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=700, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.969, test=0.943), total=  13.6s
[CV] active_neurons=700, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=700, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.965, test=0.956), total=  13.7s
[CV] active_neurons=700, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=700, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.969, test=0.943), total=  13.5s
[CV] active_neurons=700, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=700, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.965, test=0.956), total=  13.5s
[CV] active_neurons=700, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=700, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.969, test=0.943), total=  12.6s
[CV] active_neurons=700, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=700, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=0.965, test=0.956), total=  13.4s
[CV] active_neurons=1100, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=1100, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=nan, test=nan), total=   0.0s
[CV] active_neurons=1100, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=1100, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=3, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=nan, test=nan), total=   0.0s
[CV] active_neurons=1100, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=1100, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=nan, test=nan), total=   0.0s
[CV] active_neurons=1100, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=1100, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=5, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=nan, test=nan), total=   0.0s
[CV] active_neurons=1100, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=1100, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=nan, test=nan), total=   0.0s
[CV] active_neurons=1100, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17 
[CV]  active_neurons=1100, activity_reset_cnt=50, boost_max=0.9, boost_str=1, boost_tbl_size=21, boost_tbl_step=0.66, enc_set_bits=7, enc_sparsity=0.5, input_pct=0.25, neurons=1000, synapse_dec=9, synapse_inc=17, score=(train=nan, test=nan), total=   0.0s


Exception ignored in: <bound method SpatialPooler.__del__ of <niml.model.nispooler.sp_pooler_c.SpatialPooler object at 0x7f2a36867fd0>>
Traceback (most recent call last):
  File "niml/model/nispooler/sp_pooler_c.py", line 189, in niml.model.nispooler.sp_pooler_c.SpatialPooler.__del__
TypeError: delete_pooler(): incompatible function arguments. The following argument types are supported:
    1. (handle: niml.model.nispooler.sp_cpooler.Pooler) -> bool

Invoked with: None
/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_validation.py:552: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_validation.py", line 531, in _fit_and_score
    estimator.fit(X_train, y_train, **fit_params)
  File "/home/mpeterson/Skopt_fix/scikit-optimize/Skiml_DSA/pooler_module/pooler_estimator.py", line 265, in fit
    self.pooler_ = self._create_pooler(self.sdr_width)
  File "/home/mpeterson/Skopt_fix/scikit-optimize/Skiml_DSA/pooler_module/pooler_estimator.py", line 503, in _create_pooler
    boost_tbl_size=self.boost_tbl_size,
  File "niml/model/nispooler/sp_pooler_c.py", line 168, in niml.model.nispooler.sp_pooler_c.SpatialPooler.__init__
  File "niml/model/nispooler/sp_pooler_c.py", line 404, in niml.model.nispooler.sp_pooler_c.SpatialPooler.set_properties
  File "niml/model/nispooler/sp_pooler_c.py", line 402, in niml.model.nispooler.sp_pooler_c.SpatialPooler.set_properties
  File "niml/model/nispooler/sp_pooler_c.py", line 465, in niml.model.nispooler.sp_pooler_c.SpatialPooler.validate_neuron_settings
ValueError: Value for active_neurons parameter (1100) cannot be larger than the value for neurons parameter (1000).

  FitFailedWarning)
Exception ignored in: <bound method SpatialPooler.__del__ of <niml.model.nispooler.sp_pooler_c.SpatialPooler object at 0x7f2a36867fd0>>
Traceback (most recent call last):
  File "niml/model/nispooler/sp_pooler_c.py", line 189, in niml.model.nispooler.sp_pooler_c.SpatialPooler.__del__
TypeError: delete_pooler(): incompatible function arguments. The following argument types are supported:
    1. (handle: niml.model.nispooler.sp_cpooler.Pooler) -> bool

Invoked with: None
Exception ignored in: <bound method SpatialPooler.__del__ of <niml.model.nispooler.sp_pooler_c.SpatialPooler object at 0x7f2a368672e8>>
Traceback (most recent call last):
  File "niml/model/nispooler/sp_pooler_c.py", line 189, in niml.model.nispooler.sp_pooler_c.SpatialPooler.__del__
TypeError: delete_pooler(): incompatible function arguments. The following argument types are supported:
    1. (handle: niml.model.nispooler.sp_cpooler.Pooler) -> bool

Invoked with: None
Exception ignored in: <bound method SpatialPooler.__del__ of <niml.model.nispooler.sp_pooler_c.SpatialPooler object at 0x7f2a365d1eb8>>
Traceback (most recent call last):
  File "niml/model/nispooler/sp_pooler_c.py", line 189, in niml.model.nispooler.sp_pooler_c.SpatialPooler.__del__
TypeError: delete_pooler(): incompatible function arguments. The following argument types are supported:
    1. (handle: niml.model.nispooler.sp_cpooler.Pooler) -> bool

Invoked with: None
Exception ignored in: <bound method SpatialPooler.__del__ of <niml.model.nispooler.sp_pooler_c.SpatialPooler object at 0x7f2a365d1eb8>>
Traceback (most recent call last):
  File "niml/model/nispooler/sp_pooler_c.py", line 189, in niml.model.nispooler.sp_pooler_c.SpatialPooler.__del__
TypeError: delete_pooler(): incompatible function arguments. The following argument types are supported:
    1. (handle: niml.model.nispooler.sp_cpooler.Pooler) -> bool

Invoked with: None
Exception ignored in: <bound method SpatialPooler.__del__ of <niml.model.nispooler.sp_pooler_c.SpatialPooler object at 0x7f2a365d1eb8>>
Traceback (most recent call last):
  File "niml/model/nispooler/sp_pooler_c.py", line 189, in niml.model.nispooler.sp_pooler_c.SpatialPooler.__del__
TypeError: delete_pooler(): incompatible function arguments. The following argument types are supported:
    1. (handle: niml.model.nispooler.sp_cpooler.Pooler) -> bool

Invoked with: None
[Parallel(n_jobs=1)]: Done  24 out of  24 | elapsed:  3.7min finished


params: {'sdr_width': 784, 'neurons': 1000, 'active_neurons': 600, 'input_pct': 0.25, 'seed': 123, 'synapse_inc': 17, 'synapse_dec': 9, 'activity_reset_cnt': 50, 'decay_cnt_target': 10, 'learning': False, 'feat_count': 30, 'boost_max': 0.9, 'boost_str': 1, 'boost_tbl_size': 21, 'boost_tbl_step': 0.66, 'enc_set_bits': 5, 'enc_sparsity': 0.5}
score: 0.9513156255364192
Saved running file JupyterNB_Grid_RUNNING.csv

Print the highest scoring fit and the parameters that achieved it.
print("#############################################")
print("Best score after %d runs: %f" % (run_count, best_score))
print("Best parameters: ", best_score_params)
print("#############################################")
#############################################
Best score aft