concept matrix in category machine learning

appears as: matrices, matrix, A matrix, The matrix, matrix
Machine Learning with TensorFlow, Second Edition

This is an excerpt from Manning's book Machine Learning with TensorFlow, Second Edition.

Similar to the way recipes can be shared and used by other people, the learned model is reused by other software. The learning stage is the most time consuming. Running an algorithm may take hours, if not days or weeks, to converge into a useful model as you will see soon when you begin to build your own in chapter 3 and later. Figure 1.4 outlines the learning pipeline.

Figure 1.5 The inference approach generally uses a model that has already been either learned or given. After converting data into a usable representation, such as a feature vector, it uses the model to produce intended output.

Softmax logistic regression is a bit different. The output is a matrix of size(num_samples, num_classes) or size (rows, columns). When you give the algorithm one review or row and trying to classify the input into two classes or columns you get a matrix like [[0.02 98.4]]. This indicates the algorithm is 0.02% confident that the input is a negative sentiment (the 0th column) and 98.4% confident that this is a positive (the 1 th column). For 25,000 reviews you would get a matrix with 25,000 rows of those two-column confidence values for each class. So, the softmax output isn’t a 0 or a 1 as it is in binary logistic regression and as such the predict_softmax function needs to take that into account and figure out what the maximum value is in the column dimension.

Machine Learning Bookcamp

This is an excerpt from Manning's book Machine Learning Bookcamp.

After we collect all the required data and determine that it's good, we find a way to process the data, and then proceed to training a machine learning model. In our spam example, this happens after we get all the spam reports, process the mails, and have a matrix ready to be put to a model.

Figure 2.13 The function column_stack takes a list of NumPy arrays and stacks them in columns. In our case, the function appends the array with ones as the first column of the matrix.

In addition to introducing NumPy, the appendix also covers a bit of linear algebra useful for machine learning. This includes the matrix and vector multiplication, inverse and the normal equation.

When we apply np.concatenate to matrices, it stacks then vertically, not horizontally, like one-dimensional arrays, creating a new matrix with 6 rows:

array([[0, 1],
       [2, 3],
       [4, 5],
       [0, 1],
       [2, 3],
       [4, 5]])

Another useful method for combining NumPy arrays is np.column_stack: it allows us to stack vectors and matrices together. For example, suppose we want to add an extra column to our matrix. For that we simply pass a list that contains the vector, and then the matrix: