Temp
This commit is contained in:
parent
d568242cd0
commit
88a7c021d8
2 changed files with 35 additions and 15 deletions
|
@ -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):
|
||||||
|
|
|
@ -22,22 +22,37 @@ 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)
|
||||||
|
|
||||||
|
print(k)
|
||||||
|
print(len(data))
|
||||||
|
print(len(samples))
|
||||||
|
print(bucketsize)
|
||||||
|
|
||||||
|
# K steps
|
||||||
|
for i in range(k):
|
||||||
|
eval_dict = []
|
||||||
|
train_dict = []
|
||||||
|
eval_samples = []
|
||||||
|
train_samples = []
|
||||||
|
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])
|
||||||
|
|
||||||
|
for s in eval_samples:
|
||||||
# Create new dictionaries in the eval lists
|
# Create new dictionaries in the eval lists
|
||||||
X_eval.append({'dc': [x for x in itertools.chain(samples[i:i+k])]})
|
X_eval.append({'dc': s[:-1]})
|
||||||
y_eval.append({'dc': []})
|
y_eval.append({'dc': s[-1]})
|
||||||
|
|
||||||
|
for s in train_samples:
|
||||||
|
X_train.append({'dc': s[:-1]})
|
||||||
|
y_train.append({'dc': s[-1]})
|
||||||
|
|
||||||
for i in range(len(X_eval)):
|
print(len(X_train) / 12)
|
||||||
X_train.append({'dc': []})
|
#print(X_train)
|
||||||
y_train.append({'dc': []})
|
#print(y_train)
|
||||||
for c, d in enumerate(X_eval):
|
|
||||||
if c != i:
|
|
||||||
X_train[i]['dc'].extend(d['dc'])
|
|
||||||
y_train[i]['dc'].append(y_eval[c]['dc'])
|
|
||||||
|
|
||||||
print(X_train)
|
|
||||||
print(y_train)
|
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
return X_train, y_train, X_eval, y_eval
|
return X_train, y_train, X_eval, y_eval
|
||||||
|
|
Loading…
Reference in a new issue