cancel
Showing results for 
Search instead for 
Did you mean: 


Attribute Error Question in Python code

metaworld
Blue LED

Hello,

I keep receiving the following attribute error when run the datarobot in Python. 

 

Error: 'NoneType' object has no attribute 'get'

 

The following code is used to get the accuracy of models:

 

list_row = [mth_model.model_type, mth_model.metrics.get(chosen_metric).get('crossValidation'),\
mth_model.metrics.get('Accuracy').get('validation')]

 

Does anyone know how to solve this error for a quick? Thanks in advance.

 

 

3 Replies
metaworld
Blue LED

Here is a similar problem shown when picking up a model:

test_model = models.get_models(search_params={'name':'Light Gradient Boosting on ElasticNet Predictions '})[0]

The error message again is shown as:

'list' object has no attribute 'get_models'

0 Kudos
IraWatt
Laser

Hey @metaworld to get metrics for a particular model on your project leader board you can use the get_cross_validation_scores method, if you don't specify a metric in the parameter DR will send you all the metrics. 

## Here I get my project and use it to get a list of the models in that project
project = dr.Project.get('61825fd1c17009a4ecbf8e72')
models = project.get_models()
## I take the first model in the list
model = models[0]
## Get metrics from the models cross validation score
print(model.get_cross_validation_scores(metric = "R Squared"))

 

IraWatt
Laser

For your second example the 'get_models' method needs to be called on your project variable not on a model or list of models.