import tensorflow as tf
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Multilayer perceptron
data = pd.read_csv('Advertising.csv') # Predict advertising delivery and effectiveness For one more Including TV 、 Radio and newspapers
print(data.head())
plt.scatter(data.TV, data.sales)
plt.show()
x = data.iloc[:, 1:-1]
y = data.iloc[:, -1]
model = tf.keras.Sequential([tf.keras.layers.Dense(10, input_shape=(3,), activation='relu'), tf.keras.layers.Dense(1)])
print(model.summary())
model.compile(optimizer='adam', loss='mse')
model.fit(x, y, epochs=100)
test = data.iloc[:10, 1:-1]
pre = model.predict(test)
print(pre)