Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
med:lab_2 [2021/03/09 23:18]
pszwed [Metody Eksploracji Danych: Laboratorium 2]
med:lab_2 [2022/03/06 23:01]
pszwed [Knowledge Explorer]
Line 47: Line 47:
   * Punkt 2.5 :!: W tej wersji Weka grupowanie nie działa   * Punkt 2.5 :!: W tej wersji Weka grupowanie nie działa
  
 +---
 +<code python>
 +from keras import layers
 +from keras import models
 +from keras.models import Sequential,InputLayer
 +from keras.layers import Dense
 +from io import StringIO
  
 +import tensorflow as tf
 +import matplotlib.pyplot as plt
 +import numpy as np
 +
 +# 005.arff
 +data = """
 +-4.84295,-27.856212
 +...
 +"""
 +#enter data as a string
 +inp =  StringIO(data)
 +x, y = np.loadtxt(inp, delimiter=',', usecols=(0, 1), unpack=True,skiprows=0)
 +X = np.stack((x,x**2,x**3),axis=-1)
 +
 +tf.random.set_seed(1)
 +model = models.Sequential()
 +model.add(layers.InputLayer(input_shape=(X.shape[1],)))
 +model.add(layers.Dense(1))
 +model.summary()
 +model.compile(optimizer=tf.keras.optimizers.RMSprop(????), loss='mse', metrics=['mse','mae'])
 +hist = model.fit(X,y,epochs=???,verbose=1)
 +
 +
 +y_pred = model.predict(X)
 +
 +plt.scatter(x,y)
 +plt.plot(x,(x+4)*(x+1)*(x-3),c='g')
 +plt.plot(x,y_pred,c='r')
 +
 +</code>
med/lab_2.txt · Last modified: 2022/03/10 16:48 by pszwed
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0