0

I am working on a neural network in Tensorflow. My network performs multilabel classification to predict which users bid on which cars. I have a CSV with three columns; User IDs, Highest bid, and Make names (car models), however I only use User IDs and Make names. User IDs are the input and Make names are the labels, where 86 unique Make names exist. My problem is that when I train my model with the dataset, my loss is decreasing very slowly and accuracy is almost not changing at all.

I have tried changing the amount of layers I am using, as well as trying different amounts of neurons in each hidden layer, however I did not have any luck with that.

from __future__ import absolute_import, division, print_function, unicode_literals

import os
import matplotlib.pyplot as plt
import tensorflow as tf
import pandas as pd
import numpy as np

#
# READ FILE AND SET FEATURE & LABEL
#
raw_train_data = pd.read_csv("data2016NEW.csv", usecols=["USERID"])
#raw_test_data = pd.read_csv("data2017.csv", usecols=["USERID"])

train_target = pd.read_csv("data2016NEW.csv", usecols=["MAKENAME"])
#test_target = pd.read_csv("data2017.csv", usecols=["MAKENAME"])

train_dataset = tf.data.Dataset.from_tensor_slices((raw_train_data.values, train_target.values))
#test_dataset = tf.data.Dataset.from_tensor_slices((raw_test_data.values, test_target.values))


train_dataset_shuffled_batched = train_dataset.shuffle(len(raw_train_data)).batch(512)
#test_dataset_shuffled_batched = test_dataset.shuffle(len(raw_test_data)).batch(512)

def get_compiled_model():
    model = tf.keras.Sequential([
        #input layer
        tf.keras.layers.Dropout(0.2, input_shape=raw_train_data.shape[1:]),
        #hidden layers
        tf.keras.layers.Dense(360, activation='relu'),
        tf.keras.layers.Dense(360, activation='relu'),
        tf.keras.layers.Dense(360, activation='relu'),
        tf.keras.layers.Dense(360, activation='relu'),
        tf.keras.layers.Dense(360, activation='relu'),
        tf.keras.layers.Dense(360, activation='relu'),
        #output layer
        tf.keras.layers.Dense(90, activation='softmax')
    ])

    model.compile(
        optimizer=tf.keras.optimizers.Adam(learning_rate=0.01),
        loss=tf.keras.losses.sparse_categorical_crossentropy,
        metrics=['accuracy']
    )

    return model

model = get_compiled_model()
model.summary()

history = model.fit(train_dataset_shuffled_batched, epochs=1000, verbose=2)

Here is an image that shows a small sample of my data (my dataset is around 160000 rows): Dataset example

As you can see, User IDs are normalized between 0 and 1, while the label Make name are integers.

Appreciate all the help, cheers!

SquishyAura
  • 43
  • 2
  • 8
  • I know this is way too late, but how exactly is this a multilabel problem? I only see a single label (make) and that's it. You are not predicting multiple labels together as far as I can see. – Everyone Nov 05 '19 at 08:30

1 Answers1

0

Before you train, you should see whether you can see a correlation between your features.

For example : can you predict if what car you will buy based on your birthday ? Is this sole information enough ?

The fact that the learning rate changes slowly can be linked to the absence of correlation between x and y

To see if it is the case, simply replace your values with random values, then with value that have a clear pattern like (ID<0.5 => target >20). If your accuracy improves with the pattern but not the random values, it may indicate you need more features.

If you are sure about the correlation Did you try changing the learning rate ? A very high learning rate on a well-defined task would create a "vibrating" pattern, where learning rate goes up and down. This could imply you need to fine-tune it.

Hope this helps.