This commit is contained in:
Paul Schaub 2018-08-07 15:04:23 +02:00
parent d568242cd0
commit 88a7c021d8
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 35 additions and 15 deletions

View file

@ -3,7 +3,12 @@ from peewee import *
from playhouse import sqlite_ext from playhouse import sqlite_ext
from playhouse.sqlite_ext import SqliteExtDatabase from playhouse.sqlite_ext import SqliteExtDatabase
db = SqliteExtDatabase('pywatts.db') import os.path
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
db_path = os.path.join(BASE_DIR, "../pywatts.db")
print(db_path)
db = SqliteExtDatabase(db_path)
class WeatherStation(Model): class WeatherStation(Model):

View file

@ -22,23 +22,38 @@ def split(data, k):
# Randomly shuffle samples # Randomly shuffle samples
random.shuffle(samples) random.shuffle(samples)
for i in range(0, len(samples), k): bucketsize = int(len(samples) / k)
# Create new dictionaries in the eval lists
X_eval.append({'dc': [x for x in itertools.chain(samples[i:i+k])]})
y_eval.append({'dc': []})
print(k)
print(len(data))
print(len(samples))
print(bucketsize)
for i in range(len(X_eval)): # K steps
X_train.append({'dc': []}) for i in range(k):
y_train.append({'dc': []}) eval_dict = []
for c, d in enumerate(X_eval): train_dict = []
if c != i: eval_samples = []
X_train[i]['dc'].extend(d['dc']) train_samples = []
y_train[i]['dc'].append(y_eval[c]['dc']) for j in range(k):
if j == i:
eval_samples.extend(samples[i*bucketsize:(i+1)*bucketsize])
else:
train_samples.extend(samples[i*bucketsize:(i+1)*bucketsize])
print(X_train) for s in eval_samples:
print(y_train) # Create new dictionaries in the eval lists
exit(0) X_eval.append({'dc': s[:-1]})
y_eval.append({'dc': s[-1]})
for s in train_samples:
X_train.append({'dc': s[:-1]})
y_train.append({'dc': s[-1]})
print(len(X_train) / 12)
#print(X_train)
#print(y_train)
exit(0)
return X_train, y_train, X_eval, y_eval return X_train, y_train, X_eval, y_eval