1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-16 01:06:56 +08:00

Black(new version) Format

This commit is contained in:
Young
2022-02-06 22:33:16 +08:00
parent 76b7b5f24b
commit 6a946761cf
14 changed files with 35 additions and 35 deletions

View File

@@ -160,7 +160,7 @@ class DEnsembleModel(Model, FeatureInt):
h_avg = h.groupby("bins")["h_value"].mean()
weights = pd.Series(np.zeros(N, dtype=float))
for i_b, b in enumerate(h_avg.index):
weights[h["bins"] == b] = 1.0 / (self.decay ** k_th * h_avg[i_b] + 0.1)
weights[h["bins"] == b] = 1.0 / (self.decay**k_th * h_avg[i_b] + 0.1)
return weights
def feature_selection(self, df_train, loss_values):

View File

@@ -682,9 +682,9 @@ class MMD_loss(nn.Module):
if fix_sigma:
bandwidth = fix_sigma
else:
bandwidth = torch.sum(L2_distance.data) / (n_samples ** 2 - n_samples)
bandwidth = torch.sum(L2_distance.data) / (n_samples**2 - n_samples)
bandwidth /= kernel_mul ** (kernel_num // 2)
bandwidth_list = [bandwidth * (kernel_mul ** i) for i in range(kernel_num)]
bandwidth_list = [bandwidth * (kernel_mul**i) for i in range(kernel_num)]
kernel_val = [torch.exp(-L2_distance / bandwidth_temp) for bandwidth_temp in bandwidth_list]
return sum(kernel_val)

View File

@@ -742,7 +742,7 @@ def evaluate(pred):
score = pred.score
label = pred.label
diff = score - label
MSE = (diff ** 2).mean()
MSE = (diff**2).mean()
MAE = (diff.abs()).mean()
IC = score.corr(label, method="spearman")
return {"MSE": MSE, "MAE": MAE, "IC": IC}

View File

@@ -27,11 +27,11 @@ def count_parameters(models_or_parameters, unit="m"):
counts = sum(v.numel() for v in models_or_parameters)
unit = unit.lower()
if unit in ("kb", "k"):
counts /= 2 ** 10
counts /= 2**10
elif unit in ("mb", "m"):
counts /= 2 ** 20
counts /= 2**20
elif unit in ("gb", "g"):
counts /= 2 ** 30
counts /= 2**30
elif unit is not None:
raise ValueError("Unknown unit: {:}".format(unit))
return counts

View File

@@ -55,7 +55,7 @@ class TemporalConvNet(nn.Module):
layers = []
num_levels = len(num_channels)
for i in range(num_levels):
dilation_size = 2 ** i
dilation_size = 2**i
in_channels = num_inputs if i == 0 else num_channels[i - 1]
out_channels = num_channels[i]
layers += [