GSP-324 Explore Machine Learning Models With Explainable AI

GSP-324 Explore Machine Learning Models With Explainable AI

Overview

Train the first model

Train the first model on the complete dataset. Use train_data for your data and train_labels for you labels.

1model = Sequential()
2model.add(layers.Dense(200, input_shape=(input_size,), activation='relu'))
3model.add(layers.Dense(50, activation='relu'))
4model.add(layers.Dense(20, activation='relu'))
5model.add(layers.Dense(1, activation='sigmoid'))
6model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
7model.fit(train_data, train_labels, epochs=10, batch_size=2048, validation_split=0.1)

Train your second model

Train your second model on the limited dataset. Use limited_train_data for your data and limited_train_labels for your labels. Use the same input_size for the limited_model

1create the limited_model = Sequential()
2limited_model.add (your layers)
3limited_model.compile
4limited_model.fit
1limited_model = Sequential()
2limited_model.add(layers.Dense(200, input_shape=(input_size,), activation='relu'))
3limited_model.add(layers.Dense(50, activation='relu'))
4limited_model.add(layers.Dense(20, activation='relu'))
5limited_model.add(layers.Dense(1, activation='sigmoid'))
6limited_model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
7limited_model.fit(limited_train_data, limited_train_labels, epochs=10, batch_size=2048, validation_split=0.1)

Add WithConfigBuilder code

1config_builder = (WitConfigBuilder(
2    examples_for_wit[:num_datapoints],feature_names=column_names)
3    .set_custom_predict_fn(limited_custom_predict)
4    .set_target_feature('loan_granted')
5    .set_label_vocab(['denied', 'accepted'])
6    .set_compare_custom_predict_fn(custom_predict)
7    .set_model_name('limited')
8    .set_compare_model_name('complete'))
9WitWidget(config_builder, height=800)

Congratulations, you're all done with the lab 😄