Fix kcross validation
This commit is contained in:
parent
88a7c021d8
commit
2dfe5ef1b6
2 changed files with 11 additions and 19 deletions
|
@ -24,15 +24,8 @@ def split(data, k):
|
||||||
|
|
||||||
bucketsize = int(len(samples) / k)
|
bucketsize = int(len(samples) / k)
|
||||||
|
|
||||||
print(k)
|
|
||||||
print(len(data))
|
|
||||||
print(len(samples))
|
|
||||||
print(bucketsize)
|
|
||||||
|
|
||||||
# K steps
|
# K steps
|
||||||
for i in range(k):
|
for i in range(k):
|
||||||
eval_dict = []
|
|
||||||
train_dict = []
|
|
||||||
eval_samples = []
|
eval_samples = []
|
||||||
train_samples = []
|
train_samples = []
|
||||||
for j in range(k):
|
for j in range(k):
|
||||||
|
@ -41,19 +34,18 @@ def split(data, k):
|
||||||
else:
|
else:
|
||||||
train_samples.extend(samples[i*bucketsize:(i+1)*bucketsize])
|
train_samples.extend(samples[i*bucketsize:(i+1)*bucketsize])
|
||||||
|
|
||||||
for s in eval_samples:
|
|
||||||
# Create new dictionaries in the eval lists
|
# Create new dictionaries in the eval lists
|
||||||
X_eval.append({'dc': s[:-1]})
|
X_eval.append({'dc': eval_samples[:-1]})
|
||||||
y_eval.append({'dc': s[-1]})
|
y_eval.append({'dc': eval_samples[-1]})
|
||||||
|
|
||||||
for s in train_samples:
|
X_train.append({'dc': train_samples[:-1]})
|
||||||
X_train.append({'dc': s[:-1]})
|
y_train.append({'dc': train_samples[-1]})
|
||||||
y_train.append({'dc': s[-1]})
|
|
||||||
|
|
||||||
print(len(X_train) / 12)
|
print(len(X_eval))
|
||||||
#print(X_train)
|
print(len(y_eval))
|
||||||
#print(y_train)
|
|
||||||
exit(0)
|
print(len(X_train))
|
||||||
|
print(len(y_train))
|
||||||
|
|
||||||
return X_train, y_train, X_eval, y_eval
|
return X_train, y_train, X_eval, y_eval
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ n = pywatts.neural.Net(feature_cols=feature_col)
|
||||||
(X_train, y_train, X_eval, y_eval) = kcross.split(df, K)
|
(X_train, y_train, X_eval, y_eval) = kcross.split(df, K)
|
||||||
|
|
||||||
|
|
||||||
train_eval = {}
|
#train_eval = {}
|
||||||
|
|
||||||
if TRAIN:
|
if TRAIN:
|
||||||
# Train the model with the steps given
|
# Train the model with the steps given
|
||||||
|
|
Loading…
Reference in a new issue