<jupyter_start><jupyter_text>phygnn binary classification exampleHere's an example of how to make a binary classifier using a phygnn model without a p_fun.<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import tensorflow as tf
from rex import init_logger

from phygnn import PhysicsGuidedNeuralNetwork, p_fun_dummy
init_logger('phygnn', log_level='INFO', log_file=None)
x1 = np.arange(500) - 250
x2 = np.arange(500) - 250
x1, x2 = np.meshgrid(x1, x2)
x1 = x1.flatten()
x2 = x2.flatten()
x3 = x1 * x2
features = pd.DataFrame({'x1': x1, 'x2': x2})
features.head()
y = ((x1 * x2) > 0).astype(bool).astype(float)
labels = pd.DataFrame({'y': y})
labels.head()
hidden_layers = [{'units': 16},
                 {'activation': 'relu'},
                 {'units': 16}, 
                 {'activation': 'relu'},
                ]
output_layer = [{'units': 1}, 
                {'activation': 'sigmoid'},
               ]
PhysicsGuidedNeuralNetwork.seed(0)
model = PhysicsGuidedNeuralNetwork(p_fun=p_fun_dummy, 
                                   hidden_layers=hidden_layers,
                                   output_layer=output_layer,
                                   loss_weights=(1.0, 0.0), 
                                   metric='binary_crossentropy',
                                   learning_rate=0.05,
                                   n_features=2, n_labels=1)
model.fit(features, labels, features, n_batch=1, n_epoch=50)
model.history[['training_loss', 'validation_loss']].plot()
plt.ylabel('Loss')
plt.show()
plt.close()

y_pred = model.predict(features)
accuracy = 100 * (np.round(y_pred) == labels.values).sum() / len(labels)
print('Accuracy: {:.2f}%'.format(accuracy))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13386727688787187, 'fraction_numerical': 0.030892448512585814, 'mean_word_length': 2.5548780487804876, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '22642', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 614, 'n_tokens_neox': 564, 'n_words': 122, 'path': 'examples/phygnn_classification.ipynb', 'repo_name': 'leilei-help/phygnn', 'size': '1748'}