cancel
Showing results for 
Search instead for 
Did you mean: 

FIRE python sample code has 422 client error

cookie_yamyam
Linear Actuator

FIRE python sample code has 422 client error

Hello,

 

When I run this code from FIRE Sample code in python, I got 422 client error messages.

 

[Code]

# Adjust the function's parameters for your purposes
best_model = main_feature_selection(project.id,
partition='crossValidation',
best_model_search_params={'sample_pct__lte': 65})

 

[Results]

422 client error: {'message': 'Feature list named Reduced FL by Median Rank, top1 already exists'} 
Will try again with a ratio decay ...  New ratio=0.440
Request Feature Impact calculations
422 client error: {'message': 'Invalid field data', 'errors': {'features': 'list length is less than 1'}} 
Will try again with a ratio decay ...  New ratio=0.194
Request Feature Impact calculations
422 client error: {'message': 'Invalid field data', 'errors': {'features': 'list length is less than 1'}} 
Will try again with a ratio decay ...  New ratio=0.038
Request Feature Impact calculations 

 

The 422 error results are on the loop endlessly.

 

1) 422 client error: {'message': 'Feature list named Reduced FL by Median Rank, top1 already exists'} 

=> This code cannot catch the case when the next new feature list's name is same with before one(because before one selected only one feature.).

 

2) 422 client error: {'message': 'Invalid field data', 'errors': {'features': 'list length is less than 1'}}

=> When the selected feature was only one, this error message occur and code run endlessly. 

 

How can I fix this code out?

I tried to stop the line when the feature list's name is same before one, but I cannot check out feature list's name by using "project.get_featurelists()[:]" code.

 

I'm not good at coding in python.

Please help me.

 

Thank you. 

 

Labels (3)
0 Kudos
2 Replies
Lukas
Data Scientist
Data Scientist

Hi @cookie_yamyam 

it looks like you have a fairly small feature list to begin with - FIRE works best when you have > 100 features in your original data. What you are running into is a situation where there is only one single feature left, nothing more to reduce, so the FIRE process is complete.

 

What follows is a way to fix the infinite loop, but that's not strictly necessary - you can already work with your project and see if you found a reduced feature list that suits you better.

 

 

 

I assume you use this example.

What you can do as a quick fix is to add the line lives -= 1 like so:

 

 

except dr.errors.ClientError as e:
    # decay the ratio
    lives -= 1
    ratio *= ratio
    print(e, f'\nWill try again with a ratio decay ...  New ratio={ratio:.3f}')
    continue

 

 

That should get you out of the infinite loop. 

 

Hope that helps.

 

Lukas

You save my life, also.

Thank you very much!!