0

I'm executing pylint in the terminal to clean up my python script a bit. In my script, I also use RandomizedSearchCV. What can I do so that pylint's results do not show the different combinations of the RandomizedSearchCV results? Or how can I suppress the output from RandomizedSearchCV?

Here's a snippet of the code in my .py script that causes this issue, and the screenshots of the start/end of what I see when I execute in the terminal.

LOGGER.info("Fine tune model and fit it (Model 2)")
# with warnings.catch_warnings():
#     warnings.filterwarnings("ignore")

new_model = RandomizedSearchCV(lr_alt, parameters, cv=4, n_iter=15)

# with warnings.catch_warnings():
#     warnings.filterwarnings("ignore")
new_model.fit(train_features_x, train_y)

Can't load images yet, but here's a snippet of the start code in terminal:

(env-stats404-w20-HW5) Franciscos-MacBook-Pro:FRANCISCO-AVALOS franciscoavalosjr$ pylint main.py 
************* Module main
main.py:69:0: C0103: Argument name "Product" doesn't conform to snake_case naming style (invalid-name)
main.py:80:4: R1705: Unnecessary "elif" after "return" (no-else-return)
main.py:89:75: W0108: Lambda may not be necessary (unnecessary-lambda)
Traceback (most recent call last):
  File "/Users/franciscoavalosjr/opt/anaconda3/envs/env-stats404-w20-HW5/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/Users/franciscoavalosjr/opt/anaconda3/envs/env-stats404-w20-HW5/lib/python3.7/site-packages/pylint/__init__.py", line 23, in run_pylint
    PylintRun(sys.argv[1:])

And here's a snippet of the end of that pylint run:

  File "/Users/franciscoavalosjr/opt/anaconda3/envs/env-stats404-w20-HW5/lib/python3.7/site-packages/astroid/decorators.py", line 131, in raise_if_nothing_inferred
    yield next(generator)
  File "/Users/franciscoavalosjr/opt/anaconda3/envs/env-stats404-w20-HW5/lib/python3.7/site-packages/astroid/decorators.py", line 88, in wrapped
    if context.push(node):
  File "/Users/franciscoavalosjr/opt/anaconda3/envs/env-stats404-w20-HW5/lib/python3.7/site-packages/astroid/context.py", line 92, in push
    self.path.add((node, name))
RecursionError: maximum recursion depth exceeded while calling a Python object
(env-stats404-w20-HW5) Franciscos-MacBook-Pro:FRANCISCO-AVALOS franciscoavalosjr$ 

1 Answers1

0

Turns out python didn't like how I assigned my new column. The fix came from creating a new variable with the new formed column instead of adding it to my dataframe. Before and after code below:

Original code: # DF_MAJORITY = SUB_DATA[SUB_DATA['balance'] == 0] # DF_MINORITY = SUB_DATA[SUB_DATA['balance'] == 1]

# NEW_MAJORITY_NUMBER = ((DF_MINORITY.shape[0]/0.075) - DF_MINORITY.shape[0])
# NEW_MAJORITY_NUMBER = int(round(NEW_MAJORITY_NUMBER))

# DF_MAJORITY_DOWNSAMPLED = resample(DF_MAJORITY, replace=False, n_samples=NEW_MAJORITY_NUMBER,
#                                    random_state=29)

# DF_DOWNSAMPLED = pd.concat([DF_MAJORITY_DOWNSAMPLED, DF_MINORITY])

New Code:

BALANCE = SUB_DATA.loc[:, 'Delivery Status'].apply(lambda x: classify_shipping(x))
BALANCE = pd.DataFrame(BALANCE)

DF_MAJORITY = BALANCE[BALANCE['Delivery Status'] == 0]
DF_MINORITY = BALANCE[BALANCE['Delivery Status'] == 1]


NEW_MAJORITY_NUMBER = ((DF_MINORITY.shape[0]/0.075) - DF_MINORITY.shape[0])
NEW_MAJORITY_NUMBER = int(round(NEW_MAJORITY_NUMBER))

DF_MAJORITY_DOWNSAMPLED = resample(DF_MAJORITY, replace=False,
                                   n_samples=NEW_MAJORITY_NUMBER, random_state=29)
DF_DOWNSAMPLED = pd.concat([DF_MAJORITY_DOWNSAMPLED, DF_MINORITY])