Data Science Stack Exchange
2021-01-22 13:01 UTC
Score 21.0
AI-111-20210122-social-media-08200684
Full article
I am training a CNN, it runs well but I get an error when I try to get precision_score , recall_score and the f1_score . Here is a snippet of my code; # The next step is to split training and testing data. For this we will use sklearn function train_test_split(). features_train, features_test, labels_train, labels_test = train_test_split(features, labels, test_size=.2) features_train.shape, features_test.shape, labels_train.shape, labels_test.shape ((180568, 2677356), (45143, 2677356), (180568,), (45143,)) features_train.shape[0], features_train.shape[1], labels_train.shape[0] (180568, 2677356, 180568) n_timesteps, n_features, n_outputs = features_train.shape[0], features_train.shape[1], labels_train.shape[0] X_train = np.zeros((180568, 82, 1)) y_train = np.zeros((180568, 82)) n_timesteps, n_features, n_outputs = X_train.shape[1], X_train.shape[2], y_train.shape[1] n_samples = 1000 X = np.random.uniform(0,1, (n_samples, n_timesteps, n_features)) y = pd.get_dummies(np.random.randint(0,n_outputs, n_samples)).values model = tf.keras.models.Sequential([ tf.keras.layers.Conv1D(input_shape=(n_timesteps, n_features), activation='relu', kernel_size=2, filters=32), tf.keras.layers.MaxPooling1D(strides=3), #tf.nn.local_response_normalization((1, 1, 1, 1), depth_radius=5, bias=1, alpha=1, beta=0.5, name=None), tf.keras.layers.LayerNormalization(axis=1), tf.keras.layers.Conv1D(input_shape=(n_timesteps, n_features), activation='relu', kernel_size=2, filters=64), tf.keras.layers.MaxPoolin…