Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_mexicanhat_nbh_dist_weight_mode():
som = susi.SOMRegressor(nbh_dist_weight_mode="mexican-hat")
som.fit(X_train, y_train)
som.predict(X_test)
with pytest.raises(Exception):
som = susi.SOMRegressor(nbh_dist_weight_mode="pseudogaussian")
som.fit(X_train, y_train)
def test_mexicanhat_nbh_dist_weight_mode():
som = susi.SOMRegressor(nbh_dist_weight_mode="mexican-hat")
som.fit(X_train, y_train)
som.predict(X_test)
with pytest.raises(Exception):
som = susi.SOMRegressor(nbh_dist_weight_mode="pseudogaussian")
som.fit(X_train, y_train)
def test_som_regressor_init(n_rows, n_columns):
som_reg = susi.SOMRegressor(
n_rows=n_rows, n_columns=n_columns)
assert(som_reg.n_rows == n_rows)
assert(som_reg.n_columns == n_columns)
def test_MultiOutputRegressor():
mor = MultiOutputRegressor(
estimator=susi.SOMRegressor(n_jobs=2),
n_jobs=2
)
mor.fit(X, y)
def test_get_estimation_map(super_som):
som = susi.SOMRegressor() # works the same with SOMClassifier
som.super_som_ = super_som
assert np.array_equal(som.get_estimation_map(), super_som)
def test_init_super_som_regressor(X, y, init_mode):
som = susi.SOMRegressor(init_mode_supervised=init_mode)
som.X_ = X
som.y_ = y
som.labeled_indices_ = np.where(som.y_ != -1)[0]
som.init_super_som()
# test type
assert isinstance(som.super_som_, np.ndarray)
# test shape
n_rows = som.n_rows
n_columns = som.n_columns
assert som.super_som_.shape == (n_rows, n_columns, som.n_regression_vars_)
with pytest.raises(Exception):
som = susi.SOMRegressor(init_mode_supervised="pca")
som.X_ = X
som = susi.SOMRegressor(init_mode_supervised=init_mode)
som.X_ = X
som.y_ = y
som.labeled_indices_ = np.where(som.y_ != -1)[0]
som.init_super_som()
# test type
assert isinstance(som.super_som_, np.ndarray)
# test shape
n_rows = som.n_rows
n_columns = som.n_columns
assert som.super_som_.shape == (n_rows, n_columns, som.n_regression_vars_)
with pytest.raises(Exception):
som = susi.SOMRegressor(init_mode_supervised="pca")
som.X_ = X
som.y_ = y
som.init_super_som()
def test_calc_estimation_output(n_rows, n_columns, unsuper_som, super_som,
datapoint, expected):
som = susi.SOMRegressor(n_rows=n_rows, n_columns=n_columns)
som.unsuper_som_ = unsuper_som
som.super_som_ = super_som
output = som.calc_estimation_output(datapoint)
print(output)
assert np.array_equal(output, expected)
with pytest.raises(ValueError):
som.calc_estimation_output(datapoint, mode="wrong")