I want to make simple predictions with Keras and I'm not really sure if I am doing it right. My data looks like this:
col1,col2 1.68,237537 1.69,240104 1.70,244885 1.71,246196 1.72,246527 1.73,254588 1.74,255112 1.75,259035 1.76,267229 1.77,267314 1.78,268931 1.79,273497 1.80,273900 1.81,277132 1.82,278066
col1,col2
1.68,237537
1.69,240104
1.70,244885
1.71,246196
1.72,246527
1.73,254588
1.74,255112
1.75,259035
1.76,267229
1.77,267314
1.78,268931
1.79,273497
1.80,273900
1.81,277132
1.82,278066
Now, I want to predict col2col2
by col1col1
and this is how I'm doing it:
df = pandas.read_csv('data.csv', usecols=[0, 1], header=None) X = df.iloc[:, :-1].values.astype(np.float64) y = df.iloc[:, -1:].values.astype(np.float64) scalarX, scalarY = MinMaxScaler(), MinMaxScaler() scalarX.fit(X) scalarY.fit(y.reshape(len(y),1)) X = scalarX.transform(X) y = scalarY.transform(y.reshape(len(y),1)) model = Sequential() model.add(Dense(4, input_dim=1, activation='relu')) model.add(Dense(4, activation='relu')) model.add(Dense(1, activation='linear')) model.compile(loss='mse', optimizer='adam') model.fit(x=X, y=y, epochs=3, verbose=1) for num in range(1, 21): Xnew = np.array([[float(Decimal('2.{}'.format(num)))]]) ynew = model.predict(Xnew) print("X=%s, Predicted=%s" % (Xnew[0], ynew[0]))