Пример #1
0
 def test_get_item_by_id(self):
     firebase = get_storage()._firebase
     for resource in self._resources:
         data = firebase.get('/data', None).get(resource)
         not_none_element_id = 0
         for element in data:
             if not (element is None):
                 not_none_element_id = element.get('id')
                 break
         result = get_storage().get_item_by_id(resource,
                                               not_none_element_id)
         self.assertIsNotNone(result.get('id'))
Пример #2
0
 def test_connection(self):
     firebase = get_storage()._firebase
     versions = firebase.get('/versions', None)
     data = firebase.get('/data', None)
     for resource in self._resources:
         self.assertIsNotNone(versions.get(resource))
         self.assertIsNotNone(data.get(resource))
Пример #3
0
 def __init__(self, resource: str):
     super().__init__("sync_cbc_%s" % (resource))
     self._ps = get_ps()
     self._ss = get_storage()
     self._resource = resource
     self._iso_lang = get_config()['prestashop']['mainLanguage']
     self._current_lang = self.get_language(self._iso_lang)
Пример #4
0
 def test_get_items_older_version(self):
     for resource in self._resources:
         results = get_storage().get_items_older_version(resource)
         latest_version = get_storage().latest_version(resource)
         for result in results:
             self.assertNotEqual(result.get('version'), latest_version)
Пример #5
0
 def test_get_items(self):
     for resource in self._resources:
         results = get_storage().get_items(resource)
         self.assertTrue(type(results), list)
         for result in results:
             self.assertIsNotNone(result)
Пример #6
0
 def test_latest_version(self):
     for resource in self._resources:
         self.assertEqual(type(get_storage().latest_version(resource)), int)
Пример #7
0
    error_list = cross_val_score(model,
                                 X_train,
                                 y_train,
                                 cv=3,
                                 scoring='neg_mean_squared_error')

    return error_list.mean()


# #### チューニング開始

study = optuna.create_study(direction='maximize',
                            pruner=optuna.pruners.MedianPruner(),
                            study_name='sample',
                            storage=get_storage(),
                            load_if_exists=True)
study.optimize(objective, n_trials=50)

# +
# study = optuna.load_study(study_name='sample', storage=get_storage())
# -

# #### デフォルトパラメータとチューニングしたパラメータの比較

default_model = RandomForestRegressor(random_state=1234)
default_model.fit(X_train, y_train)
default_predict = default_model.predict(X_test)
default_score = mean_squared_error(y_test, default_predict)

# +