Tensorflow Beginner, Basic Question On Linear Model

Viewed 48

https://www.tensorflow.org/tutorials/estimator/linear

I am following the Tensorflow documentation to implement a Linear Classifier but I like to use my own data instead of the tutorial set. I just have a few general questions.

My dataset is as follows. It's not a time series.

row[0] - float (changed to binary, 0 = negative, 1 = positive) VALUE TO ESTIMATE

row[1] - string (categorical, changed to vocabulary, ints 1,2,3,4,5,6,7,8,9)

row[2-19] - float (positive and negative)

row[20-60] - ints (percentile ranks, ints 10,20,30,40,50,60,70,80,90)

row[61-95] - ints (binary 1, 0)

I started by using 50k (45k training) rows of data and num_epochs=100, batch_size=256.

{'accuracy': 0.8912, 'accuracy_baseline': 0.8932, 'auc': 0.7101819, 'auc_precision_recall': 0.2830853, 'average_loss': 0.30982444, 'label/mean': 0.1068, 'loss': 0.31013006, 'precision': 0.4537037, 'prediction/mean': 0.11840516, 'recall': 0.0917603, 'global_step': 17600}

  1. Does the column I want to estimate need to be a column of binaries for this model?

  2. Is it a bad idea to mix data types like this? Would it be necessary to normalize the data using something like preprocessing.Normalization ?

  3. Should I alter the epochs/batch if I want to use more data?

  4. The accuracy seems high but the loss also seems quite high, why is that?

  5. Any other suggestions?

Thanks for any help or advice.

1 Answers

Here is the answer to your questions.

  1. By default tf.estimator.LinearClassifier considers as binary classification with n_classes=2, but you can have more than 2 classes as well.
  2. For a linear classification normalizing data won't affect much in terms of accuracy compared to non linear classifier accuracy change after normalizing on the same data.
  3. You can observe the change in accuracy and loss, if it does not change much for about 5-10 epochs, you can restrict the number of epochs there only. Again you can repeat the same step by changing the batch size.
  4. Accuracy and loss are not dependent on each other, consider an example of your case to classify 0 and 1. A model with 2 classes that always predicts 0.51 for the true class would have the same accuracy as one that predicts 0.99. Best model would be with high accuracy and with less loss, if your model is giving good accuracy and high loss that means your model made huge errors on few data.

Try to tune your model hyper parameters based on several observations and to feed quality data with some preprocessing is always best way to reach high accuracy and less loss, with some additional data would be good to have always.

Related