concept set in category machine learning

This is an excerpt from Manning's book Machine Learning with TensorFlow, Second Edition.
Feature engineering is a refreshingly philosophical pursuit. For those who enjoy thought-provoking escapades into the meaning of self, we invite you to meditate on feature selection, because it’s still an open problem. Fortunately for the rest of you, to alleviate extensive debates, recent advances have made it possible to automatically determine which features to track. You’ll be able to try it out for yourself in chapter 7.
Figure 3.1 Different values of the parameter w result in different linear equations. The set of all these linear equations is what constitutes the linear model M.
![]()
Listing 12.3 Select the set of 5000 horse images and display them
x = np.matrix(data)#A y = np.array(labels)#B horse_indices = np.where(y == 7)[0]#C horse_x = x[horse_indices] #D print('Some examples of horse images we will feed to the autoencoder for training') plt.rcParams['figure.figsize'] = (10, 10) #E num_examples = 5#E for i in range(num_examples):#E horse_img = np.reshape(horse_x[i, :], (32, 32))#F plt.subplot(1, num_examples, i+1)#F plt.imshow(horse_img, cmap='Greys_r')#F plt.show()#F

This is an excerpt from Manning's book Grokking Machine Learning.
Reinforcement learning is a different type of machine learning, in which no data is given, and we must solve a problem. Instead of data, an environment is given, and an agent who is supposed to navigate in this environment. The agent has a goal, or a set of goals. The environment has rewards and punishments, which guide the agent to take the right decisions in order to reach its goal. That all sounded a bit abstract, but let’s look at some examples.
Now, of all the possible lines (each one with its own equation), why did we pick this one in particular? The reason is, because that one passes by the points pretty closely. There may be a better one, but at least we know this one is very good, as opposed to one that goes nowhere near the points. Now we are back into the original problem, where we have a set of houses, and we want to pass a road as closely as possible for them!
Figure 7.18. Our five sets with their corresponding Gini impurities. Notice that sets 1 and 5 are the most pure, and they have an index of 0. The least pure set is set 3, which has an index of 0.5. Sets 2 and 4 are in between, with indices of 0.375.
![]()

This is an excerpt from Manning's book Human-in-the-Loop Machine Learning.
Just like there is no one algorithm, architecture, or set of parameters that will make one Machine Learning model more accurate in all cases, there is no one strategy for Active Learning that will be optimal across all use cases and data sets. But just like with Machine Learning models, there are some approaches that you should try first because they are more likely to work.
The simplest way to use a model as an annotator is to trust the model predictions as labels. Given a set of model predictions for the unlabeled data, you take the predictions made beyond a certain confidence threshold, and then trust those predictions to be the labels. Figure 9.11 shows an example of this.

This is an excerpt from Manning's book Machine Learning Bookcamp.
In this example, we looked at the input data manually and analyzed it in an attempt to extract patterns from it. As a result of the analysis, we got a set of rules that transforms the input data (emails) to one of the two possible outcomes: spam or not.
Sets are faster than lists for checking if the collection contains an element. We use the “in” operator for checking it:
To add an element to the set, we use the add method:
numbers.add(17)To iterate over all the elements of the set we again use a for loop:
Figure C.17 We can think of matrix-matrix multiplication XU as a set of matrix-vector multiplications vi = Xui, where ui's are the columns of U. The results is a matrix V with all the vi's stacked together.
![]()
![]()

This is an excerpt from Manning's book Machine Learning with R, the tidyverse, and mlr.
Confusingly, R has a data structure called an atomic vector that may or may not represent a mathematical vector. An atomic vector in R contains a set of values that must all be the same type (this is where the word atomic comes from in the name). If the atomic vector’s elements are numeric, then it will also be a vector in the mathematical sense, because the values encode magnitude and direction. But if we have atomic vectors with character or logical elements, neither of these can encode magnitude and direction; so while we refer to them as vectors within R, they are not vectors in the mathematical sense. Here is how we can create numeric, character, and logical atomic vectors using the c() function.
This is probably difficult to picture in your head, so let’s look at an analogy. Imagine that you have a big jar of beads with your sewing kit. There are beads of different sizes and weights, and some are more elongated than others. It’s raining, and there’s nothing better to do, so you decide that you will organize your beads into sets to make it easier to find the beads you need in the future. You arrange a grid of bowls on the table and consider each bead in turn. You then place beads that are most similar to each other in the same bowl. You put beads that are similar, but not the same, in adjacent bowls, while beads that are very different go into bowls that are far away from each other. An example of what this might look like is shown in figure 15.1.
Figure 15.12. The distance between each case and every other case is calculated, and their k-nearest neighbors are assigned (distance along the z-axis in the top-left plot is indicated by the size of the circle). For each case, the algorithm learns a set of weights, one for each nearest neighbor, that sum to 1. Each neighbor’s variable values are multiplied by its weight (so row 1 becomes x = 3.1 × 0.1, y = 2.0 × 0.1, z = 0.1 × 0.1). The weighted values of each neighbor are summed (the columns are summed) to approximate the original values of the selected case.
![]()
SOMs learn patterns in the data by updating the weights of each node until the map converges to a set of weights that preserves similarities among the cases.

This is an excerpt from Manning's book Real-World Machine Learning.
When we talk about human learning, we distinguish between rote learning, or memorization, and true intelligence. Memorizing a telephone number or a set of instructions is undoubtedly learning. But when we say learning, we frequently mean something more.
Listing 6.3. Converting categorical columns to numerical features
def cat_to_num(data): #1 categories = unique(data) #1 features = {} #1 for cat in categories: #1 binary = (data == cat) #1 features["%s:%s"%(data.name, cat)] = binary.astype("int") #1 return pandas.DataFrame(features) #1 payment_type_cats = cat_to_num(data['payment_type']) #2 vendor_id_cats = cat_to_num(data['vendor_id']) #2 store_and_fwd_flag_cats = cat_to_num(data['store_and_fwd_flag']) #2 rate_code_cats = cat_to_num(data['rate_code']) #2 data = data.join(payment_type_cats) #3 data = data.join(vendor_id_cats) #3 data = data.join(store_and_fwd_flag_cats) #3 data = data.join(rate_code_cats) #3 #1 - Function for converting a categorical column to a set of numerical columns #2 - Converts four categorical features in the dataset to numerical #3 - Adds the converted data to the full dataset used for training and testing
You can use your bag-of-words dictionary to generate features to use in your ML models. After defining the dictionary, you can convert any text to a set of numbers corresponding to the occurrences of each dictionary word in the text. Figure 7.2 shows this process, which is called vectorization.
PCA allows you to take a set of images and find “typical” images that can be used as building blocks to represent the original images. Combining the first couple of principal components enables you to rebuild a large portion of the training images, whereas subsequent components will cover less-frequent patterns in the images. Features for a new image are generated by finding the “distance” from a principal image, thus representing the new image by a single number per principal image. You can use as many principal components as make sense in your ML problem.

This is an excerpt from Manning's book Mahout in Action.
We could also take a broader view of the recommender problem: it’s not strictly necessary to estimate preference values in order to produce recommendations. In many cases, presenting an ordered list of recommendations, from best to worst, is sufficient, without including estimated preference values. In fact, in some cases the exact ordering of the list doesn’t matter much—a set of a few good recommendations is fine.
Taking this more general view, we could also apply classic information retrieval metrics to evaluate recommenders: precision and recall. These terms are typically applied to things like search engines, which return a set of best results for a query out of many possible results.
K-means is to clustering as Vicks is to cough syrup. It’s a simple algorithm and it’s more than 50 years old. Stuart Lloyd first proposed the standard algorithm in 1957 as a technique for pulse code modulation, but it wasn’t until 1982 that it was published.[1] It’s widely used as a clustering algorithm in many fields of science. The algorithm requires the user to set the number of clusters, k, as the input parameter. You’ve already seen the algorithm in action in chapter 7 when you clustered a set of points in a 2-D plane. Let’s look at the details to understand the algorithm.
When you have a set of points in n-dimensions, you can do two things: assume that all points belong to a single cluster and start dividing the cluster into smaller clusters, or assume that each of the data point begins in its own cluster and start grouping them iteratively. The former is a top-down approach and the latter is a bottom-up approach.
The bottom-up clustering algorithms work as follows: from a set of points in an n-dimensional space, the algorithm finds the pairs of points close to each other and merges them into one cluster, as illustrated in figure 9.9. This merge is done only if the distance between them is below a certain threshold value. If not, those points are left alone. This process of merging the clusters using the distance measure is repeated until nothing can be merged anymore.

This is an excerpt from Manning's book Collective Intelligence in Action.
With the growing list of content and products available on the site, John and Jane now found it too cumbersome and expensive to manually maintain the classification of content on their site. The users also provided feedback that content navigation menus were too rigid. So they introduced dynamic navigation via a tag cloud—navigation built by an alphabetical listing of terms, where font size correlates with importance or number of occurrences of a tag. The terms were automatically extracted from the content by analyzing the content. The application analyzed each user’s interaction and provided users with a personalized set of tags for navigating the site. The set of tags changed as the type of content visited by the users changed. Further, the content displayed when a user clicked on a tag varied from user to user and changed over time. Some tags pulled the data from a search engine, while others from the recommendation engine and external catalogs.
A learning algorithm needs data in order to learn and find patterns; this data can be in the form of examples, where each example consists of a set of attributes or dimensions. Each attribute should be independent of other attributes; it shouldn’t be possible to compute the value of an attribute based on another attribute’s value. Depending on whether the attributes can be ordered and the kind of values they can take, we can categorize attributes into the following three forms: