# Experimenting with Extreme Learning Machine for Biomedical Image Classification
## 3 The Method  
In this section, we present the method we designed related to the adoption of four ELMs, i.e., the ELM, WELM, ELM, and MELM models aimed to biomedical images classification. The proposed method comprises two main steps: the first, i.e., the training (shown in Figure 1) aims to build a model based on an extreme learning machine while the second step, i.e., the testing (shown in Figure 2) is devoted to evaluating the classification effectiveness of the extreme learning machines model built in the previous step. The first step in Figure 1 is related to the _Biomedical Image Repository_, as a matter of fact, ELM belongs to the category of machine learning models, which signifies their reliance on data-driven approaches. Consequently, they necessitate a substantial quantity of unbiased and accurately labeled data, particularly when applied to biomedical images. Figure 1: The model training step. In the second step, the images, if not already in grayscale, are converted into grayscale format. This conversion has been performed in several previous studies in the biomedical images field that adopted the grayscale conversion [31; 32; 33; 34]. Additionally, the conversion helps reduce the time required for model generation. So, once the biomedical gray-scale images were obtained, we resize the images to a dimension equal to 28 pixels of width of 28 pixels of height and store into a vector the pixel belonging to each grey-scale image: in this way, we obtain, for each image, a vector composed by \(28\times 28=784\) pixels. Once the images have been generated (and stored) into numeric vectors, we can use these data to input the _ELM network_. In Listing 1 we show the Python code snippet related to the ELM model implementation. ```
1 importnumpyasmp
2 importpandasaspd
3 fromxklasern.model_selectionimporttrain_test_split
4 fromsklearn.preprocessingimportOneHotEncoder
5 fromsklearn.preprocessingimportMixMaxScaler
6 fromsklearn.preprocessingimportStandardScaler
7 fromscipy.linalgimportpinv2
8
9 train=pd.read_csv('dataset_training.csv')
10 test=pd.read_csv('dataset_testing.csv')
11 onabotencoder=OneHotEncoder(categories='auto')
12 scaler=StandardScale()
13X_train=scaler.fit_transform(train.values[:,:])
14y_train=onabotencoder.fit_transform(train.values[:,:1]).toarray()
15 xtest=scaler.fit_transform(test.values[:,:])
16y_test=onehotencoder.fit_transform(test.values[:,:]).toarray()
17x_test.shape
18 input_size=X_train.shape[1]
19 hidden_size=2048
20 input_weights=np.random.normal(size=[input_size,hidden_size])
21 bias=np.random.normal(size=[hidden_size])
22 defrelu(x):
23 returnnp.maximum(x,0,x)
24 defhidden_nodes(X):
25G=np.dst(X,input_weights)
26G=G*biases
27H=net(G)
28 returnH
29 output_weights=np.dot(pinv2(hidden_nodes(X_train)),y_train)
30 defpredict(X):
31 out=hidden_nodes(X)
32 out=np.dot(out,output_weights)
33 returnout
34 prediction=predict(X_test)
```  
**Listing 1** The Python code snippet related to the ELM model implementation. In rows from 1 to 7, we load all the necessary Python libraries, i.e., pandas, numpy, sklearn, and scipy. Rows 9 and 10 are aimed to load the training and testing datasets aiming to, respectively, train and test the ELM model. In fact, the training dataset is considered to build the model (i.e., to perform the training step of the proposed method), while the testing dataset is exploited to accomplish the testing step, aiming to evaluate the effectiveness of the ELM model: to this aim, we need to split the dataset previously obtained into two different sets of images: training and testing. Figure 2: The model testing step. We use a \"OneHotEncoder\" (in row 11) to transform our targets into one hot encoding and 'MinMaxScaler' (in row 12) to normalize the features within the range of (0, 1)  
In row 18, we define the size of the input layer as referring to the number of input features of the dataset. Row 19 is related to the initialization of the number of hidden neurons to 1000.