Features Selection based on Enhanced KNN to Predict Raw Material Needs on PT. SANM

− Raw material inventory must be able to meet production needs. So it is necessary to plan / predict raw material needs in the following month to determine the raw material inventory. Currently PT. SANM uses a manual counting method, the expenditure of raw materials for six months, then deducts the current raw material inventory. As a result, there are raw materials that are over order or lacking, which causes production to be constrained. The manual calculation method is not effective enough to meet the raw material inventory. In this research, the researcher proposes an algorithm which is contained in Data Mining, that is Enhanced KNN using GWO to predict raw material needs. Because GWO and Enhanced KNN algorithms give the results are easy to understand, have good accuracy compared to other machine learning methods, can cover the trapped problem from KNN traditional and capable of improving the accuracy using feature selection method. The method used in this study is to compare Enhanced KNN with and without GWO that gives a significant increase in the accuracy value by 16.5%, from 44.6% to 61.1%.


INTRODUCTION
PT. SANM is a company that operates in the field of eyeglass lenses, which includes medical devices. There are many types of raw materials, ranging from different segments, different indexes, white or color and diameter. According to the type of segment, the lens can be divided into three, namely a circular segment or called a kryptok lens, a semicircular segment or called a flattop and does not have a segment called single vision. According to the index there are index lenses 1.50, 1.53, 1.56, 1.57, 1.60, 1.67, 1.74. According to the color there are white, photochromic gray, photochromic brown, nupolar green, nupolar gray and also anti-radiation. Meanwhile, according to the diameter there are lenses with a diameter of 60, 65, 70, 72, 74, 76.
PT. SANM only carries out production according to orders or what is usually called a business process driven by order. When a customer places an order with various types of lenses, spherical size, cylinder or add, then the production process will be carried out. So that there is no production planning. Currently, to order raw materials, the manual calculation method is still used. The raw material for this lens does not have an expiration date, but if it is stored in an inappropriate manner and time, the raw material can no longer be used because it is out of standard or damaged.
To avoid the problem of shortage or excess of raw materials, it is necessary to classify the prediction of raw material needs. One of the classification algorithms that can be used is KNN [1].
Estimates for predicting disturbances from past data/events in the industrial sector using KNN. This study also explains predictions according to supervised data about changes in the characteristics of disorders that have occurred [2]. The classification results using KNN are easy to understand and have good accuracy compared to other machine learning methods [3] or deep learning with newer approach using speech [4] or image [5] as input. The advantage of the KNN method is that it is effectively applied to large amounts of data and is resilient to noise training data, which is data that has the farthest range of values compared to other data but can disrupt the existing data structure. In addition to advantages, KNN also has weaknesses, namely less than optimal in determining the value of k which is the number of nearest neighbors and must determine the attribute to be selected or feature selection in order to get the best results, the presence of outliers in the training data and sensitive to the value of k (there are no clear rules). to determine the optimal value of k). Despite its simplicity and high efficiency, traditional KNNs can easily get stuck [6].
To overcome these shortcomings, an improvement solution is needed to optimize the KNN classification. To overcome these shortcomings, an improvement solution is needed to optimize the KNN classification. One solution that can be applied is to perform optimization by applying EKNN [6] and adding a feature selection process using the GWO algorithm [7][8] [9]. Based on the above studies, the researcher chose the EKNN method to classify and predict the raw material needs of the coming month and used GWO as a feature selection method to improve EKNN performance.

II.
RESEARCH METHODOLOGY The research stages are outlined in Figure 1. which describes the research process that will be taken. In this research, there are several stages carried out, including: Preparation, includes background creation, problem identification, problem formulation, objectives, problem boundaries, research benefits and novelty. Study literature by conducting a literature review on predictions using EKNN. Data collection, namely data collection by 101 collecting sales data for 2018-2020. Details of the dataset used are shown in Table 1.  Data pre-processing, namely removing data noise such as duplicate data, empty values, transforming data from time series into per material code and data normalization. Data training will be carried out using the EKNN and GWO algorithms. The researcher proposes the EKNN algorithm because it is easy to understand and provides better accuracy results than other machine learning methods [3] and is able to overcome the problem of being trapped in traditional KNN [6]. Then the use of GWO as a feature selection method to increase the accuracy value on EKNN. The experiment in the first step will be trained using the EKNN algorithm and then using EKNN-GWO to get a comparison of the results of accuracy, precision and recall values, as shown in Figure 2.
A. Enhanced KNN The Enhanced KNN algorithm is a development algorithm from K-Nearest Neighbor. Traditional KNN is easily trapped in several situations, such as there are two classes that have the same number of neighbor classifications/series. Examples of traps that may occur in traditional KNN can be seen in Figure 3. Figure 3 Different-types-of-KNN-trapping [6] To overcome this weakness, another parameter is needed to determine the closest neighbor. Like the traditional KNN, the EKNN deals with its closest neighbors with the item being tested in the feature room. However, these neighbors will have different strengths according to the level of closeness to the item being tested and the neighbor's membership level with their class, which is called Item Strength (IS). The EKNN is implemented in two stages, namely; the training and testing phase [6].
In the training phase, all strength is counted. Where item strength is a measure for the relationship level of the item with its hosting class. Assuming n features, m as the target class, to calculate the strength of each item. EKNN training algorithm can be seen in Figure 4 and EKNN training phase flow can be seen in Figure 5. Where C is the class center in the n-dimensional feature space, t is the number of instances in the class, and Vq i is the i-th dimension value of the q-th example. Then, the strength of item Ij can be calculated using equation (2).
Where IS(Ij) is the power of the item Ij, which is the weighted average of the two values. The first measures the strength of an item based on its proximity to another item (example) in its class and is denoted as; ISX(Ij). On the other hand, the value further considers the proximity of the item to the center of the class as an indication of its degree of affiliation with the class and according to its strength, which is denoted as; ISY(Ij). As in the previous equation, α and β are weighting factors that express the relative impact of ISX(Ij) and ISY(Ij), where 0<α≤1 and 0<β≤1. In general, ISX(Ij) and ISY(Ij) can be calculated using equations (3) and (4), respectively.
Where ISX(Ij) and ISY(Ij) are the strength of the item considering the closeness of each class item and class center.
Dis (Ij, Ik) is the Euclidean distance between item Ij and Ik, and Dis(Ij, C) is the Euclidean distance between item Ij and the class center. Calculating the distance between two points px and py in a feature space of dimension n can be calculated using equation (5).
Where pxi and py i are the i-th dimensional values of the px and py points in the n-dimensional feature space, respectively. Then, in place of (2), the power of item Ij can be calculated using equation (6).
An important issue is how to estimate the optimal values of α and β. As tunable parameters, the optimal values of α and β can be calculated empirically by assigning different values in a predetermined scenario, then calculating the resultant accuracy of the EKNN classifier by considering a series of test items. The optimal α and β values are those that provide maximum classification accuracy. The suggested scenario is to start with initial values of α and β, for example α = 0 and β = 0, the values of α and β will be increased using a constant positive step ξ keeping the values of α and β greater than 0 and less than or equal to 1.
In the testing phase, the proposed EKNN, consider ring a target class set m to CL = {c 1, c 2, .... cm}. EKNN testing algorithm can be seen in Figure 6 and EKNN testing phase flow can be seen in Figure 7. Initially, the item under test is projected in a feature of n dimensional space. Then, the closest K-neighbor was identified. The distance from the tested item Ij to each k nearest neighbor is calculated, then the average distance(Davg) is then calculated. Circular spheres are identified whose radius is equal to Davg. Only samples in the identified environment will be considered for classifying new items. Affiliation Degree (AD) items tested for each class are calculated using the equation (7). Where ADxIj is the level of affiliation of item Ij to tested class x∀ x ∈{A B C}. Dk is the distance from the tested problem Ij to the example Ik. Sx is the set of examples in the environment of the items tested Ij. And IS(Ik) is the strength of the Ik example. Finally, the item under test is targeted to the class that has the maximum level of affiliation as illustrated in equation (8).
Where CL is the set of the target class under consideration.

B. Feature Selection
Feature selection is an optimization problem that plays an important role in dealing with classification problems. It is the process of selecting an optimal subset of features from a data set so that the classifier can obtain better accuracy and/or reduced computational load. However, removing irrelevant features is challenging and time consuming due to the large search space and the relationship between features [10]. The traditional FS method has the disadvantage of nesting effects and computational costs. To solve this problem, populationbased optimization algorithms, such as gray wolf optimization (GWO) [8], particle swarm optimization (PSO) [11], genetic algorithm (GA), genetic programming (GP), ant colony optimization (ACO), brain storm optimization (BSO) are used. and harmony search (HS) [12].

C. Grey Wolf Optimization (GWO)
Gray Wolf Optimization (GWO) is a population-based metaheuristic algorithm that simulates leadership hierarchies and the mechanism of hunting grey wolves in nature discovered by Mirjalili in 2014 [8]. The gray wolf (Gray Wolf) is a carnivorous animal that is at the highest level in the food chain, otherwise known as the Apex Predator. Gray wolves live in groups, where each group consists of 5-12 individuals [7]. The interesting thing about gray wolves is their social level. The gray wolf is divided into four social levels, as in Figure 8.
The first level is called Alpha (α), which is the leader of a group where they are female and male wolves. The first level wolf has the most right to make all decisions, regarding hunting activities, hunting time, resting place and so on. The wolf's orders of the first level will be obeyed by all wolves that are in the lower levels. The second level wolf is also called Beta (β), which is in charge of assisting the first level wolf in making decisions, as an advisor and as a substitute for the first level wolf when it dies. The second level wolf can be male or female. The third level wolf or Delta (δ) is usually called subordinate. The third level wolf has several categories; scouts are in charge of guarding the territory and giving warnings when in danger, sentinels as group protectors, elders who are experienced and have the potential to replace first and second level wolves, hunters who help first and second level wolves in hunting and provide food, and caretakers as carers for a wolf that is sick or injured.
Apart from the social level, another interesting thing about the gray wolf is group hunting. At the first level GWO is considered the best solution.
The steps of hunting and mathematical models on GWO are as follows: Step 1: Encircling prey Where t denotes the current iteration, ⃗ and ⃗ is the vector coefficient, ⃗ is the vector of the prey position, and ⃗ denotes the vector of the position of the gray wolf. Where ⃗ and ⃗ can be calculated by the equation below.
Where the component is derived linearly from 2 to 0 during iteration and r1, r2 are random vectors in [0,1]. ⃗ Step 2: Hunting: hunting activities are usually guided by Alpha level wolves. Beta and Delta might participate in the hunt every now and then. In the mathematical model of the gray wolf hunting behavior, it is assumed that Alpha, Beta, and Delta have better knowledge of the potential location of the prey. The first three best solutions are saved and the other wolves must update their position according to the position of the best seeker wolf as shown in the equation below.
Step 3: Attacking the prey (exploitation): The gray wolf completes the hunt by attacking its prey when it stops moving. The vector is a random value in the interval [-2a, 2a], where a is lowered from 2 to 0 during iteration. When the wolf attacks the prey, that represents a process of exploitation. ⃗ ⃗ < 1 Step 4: Looking for prey (exploration): The roaming process in GWO is applied according to different positions and positions to find prey and gather to attack the prey. The exploration process is modeled mathematically by utilizing A with a random value greater than 1 or less than -1 to oblige the seeker group to deviate from its prey. When | A |> 1, the wolf is forced to deviate from its prey to become a fitter prey.

D. Validation
One alternative approach to "train and test" that is often adopted in some cases (and some regardless of size) is called K-Fold Cross Validation. [13] by testing the amount of error in the test data [14]. We use the k-1 sample for training and the remaining 1 sample for testing. For example, there are 10 data subsets, we use 9 subsets for training and the remaining 1 subset for testing. There are 10 training times where in each training there are 9 data subsets for training and 1 subset is used for testing. After that, the average error and standard deviation of error are calculated [14]. Each k part is in turn used as the test set and the other k -1 parts are used as the training set [15].

E. Measurement Stages
Confusion matrix is a dataset having only two classes, one class as positive and the other class as negative [15]. This method uses a configuration matrix model table. Where p is the number of correct predictions that the instance will be negative. q is the number of incorrect predictions that the instance will be positive. u is the number of incorrect predictions that the instance will be negative. v is the number of correct predictions that the instance will be positive.
Here The data pre-processing stage used in this study is to set aside unused attributes and data transformation. Data transformation is used to change the number class data type to nominal. This research classification method uses Enhanced KNN based [6]. One alternative approach to "train and test" that is often adopted in some cases (and some regardless of size) is called K-Fold Cross Validation. [17]. The results of the accuracy of each fold are shown in Table 3. From 10 tests, the average accuracy of the EKNN method is 44.6%, with the highest accuracy value of 83% and the lowest accuracy value of 17%. Then the test was carried out using the GWO-EKNN method with an average accuracy value of 61.1%, with the highest accuracy value of 100% and the lowest accuracy value of 0%.
Based on the accuracy value data between the EKNN and GWO-EKNN methods, the results show that the GWO-EKNN accuracy value is better than the EKNN with an average accuracy value of 61.1% with a difference of 16.5%. The following is a graphical comparison result to see a clearer difference in accuracy values.  Figure 9, the highest average accuracy value is found in the GWO-EKNN algorithm. In the experiments that have been carried out, it can be concluded that the experimental results are in the table below: Based on Table 4, it shows that the best experimental results are in the GWO-EKNN algorithm with an accuracy value of 61.1%, a precision value of 52.5% and a recall value of 62.8%. The second method is the EKNN algorithm with an accuracy value of 44.6%, a precision value of 23.3% and a recall value of 44.4%.

IV.
CONCLUSION Based on the research that has been done to improve the performance of EKNN in predicting raw material needs by selecting features using GWO, it can be concluded that GWO is able to increase EKNN performance by 16.5%, from 44.6% to 61.1%. Based on the GWO feature selection method, it was found that the features that can increase the accuracy of the prediction of raw material requirements include BL01, BL01BB, BL01P, BL01PUV, BL02, BL02PUV, BL05BB, BL05BB1.6, BL05BL, BL05DW and Target. So that the GWO-EKNN method can predict the raw material needs more precisely on the sales dataset of PT. SANM in 2018-2020.
Based on the above conclusions, for future research it is recommended to use other metaheuristic feature selection methods, such as: PSO, GA, ACO, BCO, and others as well as using optimization of metaheuristic methods.