文章目录

1 example

Y=w1* x1+w2* x2+b

2 keras实现
import pandas as pd
import keras
from keras import layers

data=pd.read_csv('./Advertising.csv')
print(data.head())

x=data[data.columns[0:-1]]
y=data.iloc[:,-1]
print(x)
print(y)

model=keras.Sequential()
model.add(layers.Dense(1,input_dim=3))
print(model.summary())

model.compile(optimizer='adam',
    loss='mse'
)

model.fit(x,y,epochs=2000)

print(model.predict(pd.DataFrame([[300,0,0]])))

Keras【Deep Learning With Python】实现多元线性回归_人工智能