allowed varianes field for results object
@@ -7,14 +7,13 @@ Created on Wed Feb 19 14:42:47 2020
"""
import numpy as np
-import h5py
-import os
import pyrsa.model
from pyrsa.util.file_io import write_dict_hdf5
from pyrsa.util.file_io import write_dict_pkl
from pyrsa.util.file_io import read_dict_hdf5
from pyrsa.util.file_io import read_dict_pkl
+
class Result:
""" Result class storing results for a set of models with the models,
the results matrix and the noise ceiling
@@ -39,7 +38,9 @@ class Result:
as inputs
"""
- def __init__(self, models, evaluations, method, cv_method, noise_ceiling):
+
+ def __init__(self, models, evaluations, method, cv_method, noise_ceiling,
+ variances=None):
if isinstance(models, pyrsa.model.Model):
models = [models]
assert len(models) == evaluations.shape[1], 'evaluations shape does' \
@@ -50,6 +51,7 @@ class Result:
self.method = method
self.cv_method = cv_method
self.noise_ceiling = noise_ceiling
+ self.variances = variances
def save(self, filename, file_type='hdf5'):
""" saves the results into a file.
@@ -78,6 +80,7 @@ class Result:
"""
result_dict = {}
result_dict['evaluations'] = self.evaluations
+ result_dict['variances'] = self.variances
result_dict['noise_ceiling'] = self.noise_ceiling
result_dict['method'] = self.method
result_dict['cv_method'] = self.cv_method
@@ -120,6 +123,8 @@ def result_from_dict(result_dict):
result(Result): the recreated object
"""
+ if 'variances' in result_dict.keys():
+ variances = result_dict['variances']
evaluations = result_dict['evaluations']
method = result_dict['method']
cv_method = result_dict['cv_method']
@@ -129,4 +134,5 @@ def result_from_dict(result_dict):
key = 'model_%d' % i_model
models[i_model] = pyrsa.model.model_from_dict(
result_dict['models'][key])
- return Result(models, evaluations, method, cv_method, noise_ceiling)
+ return Result(models, evaluations, method, cv_method, noise_ceiling,
+ variances=variances)
