Assuming you want to predict the ‘SalePrice’ target variable based on other features
Extract features (X) and target variable (y)
X = data.drop(columns=['SalePrice']) # Assuming 'SalePrice' is the target variable y = data['SalePrice']
Perform train-test split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
Standardize features
scaler = StandardScaler() X_train_scaled = scaler.fit_transform(X_train) X_test_scaled = scaler.transform(X_test)
Define the neural network architecture
your text
model = tf.keras.models.Sequential([
tf.keras.layers.Dense(128, activation=’relu’, input_shape=(X_train_scaled.shape[1],)),
tf.keras.layers.Dense(64, activation=’relu’),
tf.keras.layers.Dense(1) # Output layer with single neuron (for regression)`
])
Compile the model
model.compile(optimizer='adam', loss='mean_squared_error')
Train the model
history = model.fit(X_train_scaled, y_train, epochs=50, batch_size=32, validation_split=0.2)
Evaluate the model on test data
loss = model.evaluate(X_test_scaled, y_test) print("Test Loss:", loss)
1