Test run: Convert numeric data to classified data

Source: Internet
Author: User
Tags numeric

The basic task of machine learning is to convert numerical data into classified data. For example, if you have a dataset with a person's height (in inches), such as 59.5, 64.0, and 75.5, you might want to convert this numeric data to classified data, such as 0, 1, and 2, to indicate low, medium, and high. This process is sometimes commonly known as "data boxing." In machine learning literature, this process is often referred to as "discretization of continuous data".

You may need to scatter data in the following situations. Many machine learning algorithms (such as Naive Bayes Classification and prediction) apply only to categorical data. Therefore, if your raw data is numeric data and you want to apply Naive Bayes, you must scatter the data. You can also mix numeric data with classified data, such as data that is often found in an Excel spreadsheet. Because only a handful of machine learning algorithms apply to mixed data, you can convert numeric data to classified data and then use machine learning algorithms that apply to categorical data. For example, the classification utility can be used for data clustering analysis.

Perhaps due to the lack of attractiveness of this topic, there are very few available resources to accurately describe how to implement discretization algorithms. In this article, I'll introduce a powerful discretization algorithm. Although these ideas are not up to date, the implementation described in this article has not been published before, as far as I know.

The best way to understand the view in this article is to look at the demo shown in Figure 1. The demo sets 20 data points to indicate the height of the person in inches. The histogram in Figure 2 shows the original data. The demo analyzes the data and creates a Discretizer object, and then displays an internal representation of the object. The Discretizer retains a copy of the different values from the original data in the sorted (from low to High) array named "." The calculated number of categories is 3 and is stored in the member variable K.

Figure 1 Converting numeric data to classified data

Figure 2 Raw data to be sorted

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.