OSDN Git Service

comit latest2
[stux/ultron.git] / src / main / Python / Predictor.py
diff --git a/src/main/Python/Predictor.py b/src/main/Python/Predictor.py
new file mode 100644 (file)
index 0000000..953b2bc
--- /dev/null
@@ -0,0 +1,31 @@
+from keras.models import Model
+from Learning import ModelGenerator
+import Learning
+import numpy
+
+
+def predict(target: str):
+    """
+    与えられたパターン(50 x 10)を使い、連続期間を判定する。
+    :param target:
+    :return:
+    """
+    # データ分割
+    target = target.split(",")
+
+    # データサイズ確認
+    if(500 != len(target)):
+        # 例外をスロー
+        print("Unsuported Process. yet")
+
+    # データ変換
+    target = numpy.array(target, dtype=numpy.float32)
+    target = target.reshape(1, 500).astype(float)
+    model = Learning.regenerate_leaning_model() #type: Model
+    result = model.predict(target,batch_size=1).astype(float)
+
+    # 結果をログ出力(debug)
+    numpy.set_printoptions(precision=3, suppress=True)
+    return result
+
+