-
Notifications
You must be signed in to change notification settings - Fork 1
/
testModel.py
42 lines (31 loc) · 1.15 KB
/
testModel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import csv
from NeuralLibrary import NeuralModel
import numpy as np
import pandas as pd
import sys
from random import random
from operator import add
from pyspark.sql import SparkSession
def main():
spark = SparkSession\
.builder\
.appName("PredictTemperature")\
.getOrCreate()
data_path="/Spark-TFLite/jena_weather_dataset_roof.csv"
#data_raw = data_from_file(data_path)
# Specify which model to use
model = NeuralModel("/Spark-TFLite/model_bilstm.tflite")
# Format data
#input_data = model.input_data(data_raw)
# print("Output details:", model.get_details()[1])
# Run the model with input data
output=spark.read.csv(data_path).rdd.map(lambda r: r[0]).flatMap(lambda x:x.split('')).map(lambda i: NeuralModel("/Spark-TFLite/model_bilstm.tflite").input_data(i[0])).map(lambda m: NeuralModel("/Spark-TFLite/model_bilstm.tflite").run(m)) #problem: where to place inputdata(m)
#output = model.run(input_data)
print("*********\nOutput =\n")
print(output)
#def data_from_file(data_path):
#data = pd.read_csv(data_path)
#return data
if __name__ == '__main__':
main()