I have data which essentially plots two tails in a 2-D histogram as shown below. I want to build a model that could either identify the two tails by fitting a linear regression between the tails, or something like SVM has been done in the past.
I am fairly new to TensorFlow, and I do not necessarily know where to start with this kind of project. I can provide sample code and data for this as well, if needed.
Hope you are familiarized with the tensorflow concepts by this time. Few more pointers are added here. you can build different models to identify two tails. The below is the generaalized code to build a tensorflow model with the sample data.
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
# It's a sample data with two distinct tails. Please add your data.
np.random.seed(42)
x = np.concatenate([np.random.normal(loc=0, scale=1, size=500),
np.random.normal(loc=5, scale=1, size=500)])
y = np.concatenate([np.random.normal(loc=0, scale=1, size=500),
np.random.normal(loc=5, scale=1, size=500)])
X = np.vstack([x, y]).T
# TensorFlow Model (Neural Network)
# Define and train a simple model. You can configure the ndes, layers, filters..
model = tf.keras.Sequential([
tf.keras.layers.InputLayer(input_shape=(2,)),
tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(32, activation='relu'),
tf.keras.layers.Dense(1, activation='sigmoid')
])
model.compile(optimizer='adam',
loss='binary_crossentropy',
metrics=['accuracy'])
y_labels_nn = np.concatenate([np.zeros(500), np.ones(500)])
# Train the model
model.fit(X, y_labels_nn, epochs=10, batch_size=32, verbose=0)
y_pred_nn = model.predict(X).flatten()
plt.figure(figsize=(6, 6))
plt.scatter(x, y, c=y_pred_nn, cmap='coolwarm', edgecolor='k')
plt.xlabel('X')
plt.ylabel('Y')
plt.title('Neural Network Classification')
plt.colorbar(label='Probability')
plt.show()
The complete guidance to build a tensorflow models can find here. For further assistance specifically, please provide your data and code.