Dinfio Playground

Let's play with Dinfio!




Machine Learning: Iris Classification using k-Nearest Neighbours

This is the implementation of k-Nearest Neighbours (kNN) algorithm with Iris (https://archive.ics.uci.edu/ml/datasets/Iris) as dataset.

' ------------------------------------
'  Machine Learning Example in Dinfio
' ------------------------------------
'  k-Nearest Neighbours classifier
'  Dataset: Iris
'  By: Faruq
' ------------------------------------
 
import math
import string, fileio
 
start
    var KNN: knn = KNN(3)
 
    dataset = knn.load_dataset("iris")
    test_index = 4
    testing = dataset.testing.features[test_index]
 
    knn.train(dataset.training.features, dataset.training.labels)
    prediction = knn.predict(testing)
 
    print()
stop
 
class KNN
    field x_train, y_train
    field k
 
    function construct(k)
        this.k = k
    stop
 
    function train(features, labels)
        this.x_train = features
        this.y_train = labels
    stop
 
    function predict(test)
        best_distance = this.distance(this.x_train[0], test)
        prediction = this.y_train[0]
 
        for i, 1, size(this.x_train) - 1
            dist = this.distance(this.x_train[i], test)
 
            if dist < best_distance
                best_distance = dist
                prediction = this.y_train[i]
            endif
        endfor
 
        return {label: prediction, distance: best_distance}
    stop
 
    function distance(point_1, point_2)
        sum = 0
 
        for i, 0, size(point_1) - 1
            sum += (point_1[i] - point_2[i]) ^ 2
        endfor
 
        return sum ^ 0.5
    stop
 
    function load_dataset(dataset)
        training_features = []; training_labels = []
        testing_features = []; testing_labels = []
 
 
        ' Load training data
 
        path = getfoldername(getcurrentfile()) & "/" & dataset & "-training.data"
        var file: f = file(path, file_read)
 
        iif(is_nothing(f), exit("Training data not found"), nothing)
 
        i = -1
 
        while !f.eof()
            d = split(f.readln(), ",")
 
            if i == -1
                header = d
            else
                c = size(d) - 1
                temp = []
 
                for j, 0, c - 1
                    temp[j] = getnumber(d[j])
                endfor
 
                training_features[i] = temp
                training_labels[i] = d[c]
            endif
 
            i += 1
        endwhile
 
 
        ' Load testing data
 
        path = getfoldername(getcurrentfile()) & "/" & dataset & "-testing.data"
        f = file(path, file_read)
 
        iif(is_nothing(f), exit("Testing data not found"), nothing)
 
        i = -1
 
        while !f.eof()
            d = split(f.readln(), ",")
 
            if i != -1
                c = size(d) - 1
                temp = []
 
                for j, 0, c - 1
                    temp[j] = getnumber(d[j])
                endfor
 
                testing_features[i] = temp
                testing_labels[i] = d[c]
            endif
 
            i += 1
        endwhile
 
        return {
            header: header,
            training: {
                features: training_features,
                labels: training_labels
            },
            testing: {
                features: testing_features,
                labels: testing_labels
            }
        }
    stop
endclass
 
function print()
    writeln("-----------------------")
    writeln(" kNN Example in Dinfio")
    writeln("-----------------------")
    writeln("\nInput:")
 
    for i, 0, size(dataset.header) - 2
        writeln(dataset.header[i] & " = " & testing[i])
    endfor
 
    writeln()
    writeln("Prediction result: " & prediction.label)
    writeln("Actual result: " & dataset.testing.labels[test_index])
    writeln("Euclidean distance: " & prediction.distance)
    writeln("Total training data: " & size(dataset.training.features))
stop

Screenshot:

iris-training.data:
sepal length,sepal width,petal length,petal width,label
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.4,3.7,1.5,0.2,Iris-setosa
4.8,3.4,1.6,0.2,Iris-setosa
4.8,3.0,1.4,0.1,Iris-setosa
4.3,3.0,1.1,0.1,Iris-setosa
5.8,4.0,1.2,0.2,Iris-setosa
5.7,4.4,1.5,0.4,Iris-setosa
5.4,3.9,1.3,0.4,Iris-setosa
5.1,3.5,1.4,0.3,Iris-setosa
5.7,3.8,1.7,0.3,Iris-setosa
5.1,3.8,1.5,0.3,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
4.6,3.6,1.0,0.2,Iris-setosa
5.1,3.3,1.7,0.5,Iris-setosa
4.8,3.4,1.9,0.2,Iris-setosa
5.0,3.0,1.6,0.2,Iris-setosa
5.0,3.4,1.6,0.4,Iris-setosa
5.2,3.5,1.5,0.2,Iris-setosa
5.2,3.4,1.4,0.2,Iris-setosa
4.7,3.2,1.6,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa
5.2,4.1,1.5,0.1,Iris-setosa
5.5,4.2,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.0,3.2,1.2,0.2,Iris-setosa
5.5,3.5,1.3,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
4.4,3.0,1.3,0.2,Iris-setosa
5.1,3.4,1.5,0.2,Iris-setosa
5.0,3.5,1.3,0.3,Iris-setosa
4.5,2.3,1.3,0.3,Iris-setosa
4.4,3.2,1.3,0.2,Iris-setosa
5.0,3.5,1.6,0.6,Iris-setosa
5.1,3.8,1.9,0.4,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
6.4,3.2,4.5,1.5,Iris-versicolor
6.9,3.1,4.9,1.5,Iris-versicolor
5.5,2.3,4.0,1.3,Iris-versicolor
6.5,2.8,4.6,1.5,Iris-versicolor
5.7,2.8,4.5,1.3,Iris-versicolor
6.3,3.3,4.7,1.6,Iris-versicolor
4.9,2.4,3.3,1.0,Iris-versicolor
6.6,2.9,4.6,1.3,Iris-versicolor
5.2,2.7,3.9,1.4,Iris-versicolor
5.0,2.0,3.5,1.0,Iris-versicolor
5.9,3.0,4.2,1.5,Iris-versicolor
6.0,2.2,4.0,1.0,Iris-versicolor
6.1,2.9,4.7,1.4,Iris-versicolor
5.6,2.9,3.6,1.3,Iris-versicolor
6.7,3.1,4.4,1.4,Iris-versicolor
5.6,3.0,4.5,1.5,Iris-versicolor
5.8,2.7,4.1,1.0,Iris-versicolor
6.2,2.2,4.5,1.5,Iris-versicolor
5.6,2.5,3.9,1.1,Iris-versicolor
5.9,3.2,4.8,1.8,Iris-versicolor
6.1,2.8,4.0,1.3,Iris-versicolor
6.3,2.5,4.9,1.5,Iris-versicolor
6.1,2.8,4.7,1.2,Iris-versicolor
6.4,2.9,4.3,1.3,Iris-versicolor
6.6,3.0,4.4,1.4,Iris-versicolor
6.8,2.8,4.8,1.4,Iris-versicolor
6.7,3.0,5.0,1.7,Iris-versicolor
6.0,2.9,4.5,1.5,Iris-versicolor
5.7,2.6,3.5,1.0,Iris-versicolor
5.5,2.4,3.8,1.1,Iris-versicolor
5.5,2.4,3.7,1.0,Iris-versicolor
5.8,2.7,3.9,1.2,Iris-versicolor
6.0,2.7,5.1,1.6,Iris-versicolor
5.4,3.0,4.5,1.5,Iris-versicolor
6.0,3.4,4.5,1.6,Iris-versicolor
6.7,3.1,4.7,1.5,Iris-versicolor
6.3,2.3,4.4,1.3,Iris-versicolor
5.6,3.0,4.1,1.3,Iris-versicolor
5.5,2.5,4.0,1.3,Iris-versicolor
5.5,2.6,4.4,1.2,Iris-versicolor
6.1,3.0,4.6,1.4,Iris-versicolor
5.8,2.6,4.0,1.2,Iris-versicolor
5.0,2.3,3.3,1.0,Iris-versicolor
5.6,2.7,4.2,1.3,Iris-versicolor
6.3,3.3,6.0,2.5,Iris-virginica
5.8,2.7,5.1,1.9,Iris-virginica
7.1,3.0,5.9,2.1,Iris-virginica
6.3,2.9,5.6,1.8,Iris-virginica
6.5,3.0,5.8,2.2,Iris-virginica
7.6,3.0,6.6,2.1,Iris-virginica
4.9,2.5,4.5,1.7,Iris-virginica
7.3,2.9,6.3,1.8,Iris-virginica
6.7,2.5,5.8,1.8,Iris-virginica
7.2,3.6,6.1,2.5,Iris-virginica
6.5,3.2,5.1,2.0,Iris-virginica
6.4,2.7,5.3,1.9,Iris-virginica
6.8,3.0,5.5,2.1,Iris-virginica
5.7,2.5,5.0,2.0,Iris-virginica
5.8,2.8,5.1,2.4,Iris-virginica
6.4,3.2,5.3,2.3,Iris-virginica
6.5,3.0,5.5,1.8,Iris-virginica
7.7,3.8,6.7,2.2,Iris-virginica
7.7,2.6,6.9,2.3,Iris-virginica
6.0,2.2,5.0,1.5,Iris-virginica
6.9,3.2,5.7,2.3,Iris-virginica
5.6,2.8,4.9,2.0,Iris-virginica
7.7,2.8,6.7,2.0,Iris-virginica
6.3,2.7,4.9,1.8,Iris-virginica
6.7,3.3,5.7,2.1,Iris-virginica
7.2,3.2,6.0,1.8,Iris-virginica
6.2,2.8,4.8,1.8,Iris-virginica
6.1,3.0,4.9,1.8,Iris-virginica
6.4,2.8,5.6,2.1,Iris-virginica
7.2,3.0,5.8,1.6,Iris-virginica
7.4,2.8,6.1,1.9,Iris-virginica
7.9,3.8,6.4,2.0,Iris-virginica
6.4,2.8,5.6,2.2,Iris-virginica
6.3,2.8,5.1,1.5,Iris-virginica
6.1,2.6,5.6,1.4,Iris-virginica
7.7,3.0,6.1,2.3,Iris-virginica
6.3,3.4,5.6,2.4,Iris-virginica
6.4,3.1,5.5,1.8,Iris-virginica
6.0,3.0,4.8,1.8,Iris-virginica
6.9,3.1,5.4,2.1,Iris-virginica
6.7,3.1,5.6,2.4,Iris-virginica
6.9,3.1,5.1,2.3,Iris-virginica
5.8,2.7,5.1,1.9,Iris-virginica
6.8,3.2,5.9,2.3,Iris-virginica
6.7,3.3,5.7,2.5,Iris-virginica

iris-testing.data:
sepal length,sepal width,petal length,petal width,label
4.8,3.0,1.4,0.3,Iris-setosa
5.1,3.8,1.6,0.2,Iris-setosa
4.6,3.2,1.4,0.2,Iris-setosa
5.3,3.7,1.5,0.2,Iris-setosa
5.0,3.3,1.4,0.2,Iris-setosa
5.7,3.0,4.2,1.2,Iris-versicolor
5.7,2.9,4.2,1.3,Iris-versicolor
6.2,2.9,4.3,1.3,Iris-versicolor
5.1,2.5,3.0,1.1,Iris-versicolor
5.7,2.8,4.1,1.3,Iris-versicolor
6.7,3.0,5.2,2.3,Iris-virginica
6.3,2.5,5.0,1.9,Iris-virginica
6.5,3.0,5.2,2.0,Iris-virginica
6.2,3.4,5.4,2.3,Iris-virginica
5.9,3.0,5.1,1.8,Iris-virginica

Iris dataset dump writer(dataset):
object(
    .header = array(
        [0] = "sepal length"
        [1] = "sepal width"
        [2] = "petal length"
        [3] = "petal width"
        [4] = "label"
    )
    .training = object(
        .features = array(
            [0] = array(
                [0] = 5.1
                [1] = 3.5
                [2] = 1.4
                [3] = 0.2
            )
            [1] = array(
                [0] = 4.9
                [1] = 3
                [2] = 1.4
                [3] = 0.2
            )
            [2] = array(
                [0] = 4.7
                [1] = 3.2
                [2] = 1.3
                [3] = 0.2
            )
            [3] = array(
                [0] = 4.6
                [1] = 3.1
                [2] = 1.5
                [3] = 0.2
            )
            [4] = array(
                [0] = 5
                [1] = 3.6
                [2] = 1.4
                [3] = 0.2
            )
            [5] = array(
                [0] = 5.4
                [1] = 3.9
                [2] = 1.7
                [3] = 0.4
            )
            [6] = array(
                [0] = 4.6
                [1] = 3.4
                [2] = 1.4
                [3] = 0.3
            )
            [7] = array(
                [0] = 5
                [1] = 3.4
                [2] = 1.5
                [3] = 0.2
            )
            [8] = array(
                [0] = 4.4
                [1] = 2.9
                [2] = 1.4
                [3] = 0.2
            )
            [9] = array(
                [0] = 4.9
                [1] = 3.1
                [2] = 1.5
                [3] = 0.1
            )
            [10] = array(
                [0] = 5.4
                [1] = 3.7
                [2] = 1.5
                [3] = 0.2
            )
            [11] = array(
                [0] = 4.8
                [1] = 3.4
                [2] = 1.6
                [3] = 0.2
            )
            [12] = array(
                [0] = 4.8
                [1] = 3
                [2] = 1.4
                [3] = 0.1
            )
            [13] = array(
                [0] = 4.3
                [1] = 3
                [2] = 1.1
                [3] = 0.1
            )
            [14] = array(
                [0] = 5.8
                [1] = 4
                [2] = 1.2
                [3] = 0.2
            )
            [15] = array(
                [0] = 5.7
                [1] = 4.4
                [2] = 1.5
                [3] = 0.4
            )
            [16] = array(
                [0] = 5.4
                [1] = 3.9
                [2] = 1.3
                [3] = 0.4
            )
            [17] = array(
                [0] = 5.1
                [1] = 3.5
                [2] = 1.4
                [3] = 0.3
            )
            [18] = array(
                [0] = 5.7
                [1] = 3.8
                [2] = 1.7
                [3] = 0.3
            )
            [19] = array(
                [0] = 5.1
                [1] = 3.8
                [2] = 1.5
                [3] = 0.3
            )
            [20] = array(
                [0] = 5.4
                [1] = 3.4
                [2] = 1.7
                [3] = 0.2
            )
            [21] = array(
                [0] = 5.1
                [1] = 3.7
                [2] = 1.5
                [3] = 0.4
            )
            [22] = array(
                [0] = 4.6
                [1] = 3.6
                [2] = 1
                [3] = 0.2
            )
            [23] = array(
                [0] = 5.1
                [1] = 3.3
                [2] = 1.7
                [3] = 0.5
            )
            [24] = array(
                [0] = 4.8
                [1] = 3.4
                [2] = 1.9
                [3] = 0.2
            )
            [25] = array(
                [0] = 5
                [1] = 3
                [2] = 1.6
                [3] = 0.2
            )
            [26] = array(
                [0] = 5
                [1] = 3.4
                [2] = 1.6
                [3] = 0.4
            )
            [27] = array(
                [0] = 5.2
                [1] = 3.5
                [2] = 1.5
                [3] = 0.2
            )
            [28] = array(
                [0] = 5.2
                [1] = 3.4
                [2] = 1.4
                [3] = 0.2
            )
            [29] = array(
                [0] = 4.7
                [1] = 3.2
                [2] = 1.6
                [3] = 0.2
            )
            [30] = array(
                [0] = 4.8
                [1] = 3.1
                [2] = 1.6
                [3] = 0.2
            )
            [31] = array(
                [0] = 5.4
                [1] = 3.4
                [2] = 1.5
                [3] = 0.4
            )
            [32] = array(
                [0] = 5.2
                [1] = 4.1
                [2] = 1.5
                [3] = 0.1
            )
            [33] = array(
                [0] = 5.5
                [1] = 4.2
                [2] = 1.4
                [3] = 0.2
            )
            [34] = array(
                [0] = 4.9
                [1] = 3.1
                [2] = 1.5
                [3] = 0.1
            )
            [35] = array(
                [0] = 5
                [1] = 3.2
                [2] = 1.2
                [3] = 0.2
            )
            [36] = array(
                [0] = 5.5
                [1] = 3.5
                [2] = 1.3
                [3] = 0.2
            )
            [37] = array(
                [0] = 4.9
                [1] = 3.1
                [2] = 1.5
                [3] = 0.1
            )
            [38] = array(
                [0] = 4.4
                [1] = 3
                [2] = 1.3
                [3] = 0.2
            )
            [39] = array(
                [0] = 5.1
                [1] = 3.4
                [2] = 1.5
                [3] = 0.2
            )
            [40] = array(
                [0] = 5
                [1] = 3.5
                [2] = 1.3
                [3] = 0.3
            )
            [41] = array(
                [0] = 4.5
                [1] = 2.3
                [2] = 1.3
                [3] = 0.3
            )
            [42] = array(
                [0] = 4.4
                [1] = 3.2
                [2] = 1.3
                [3] = 0.2
            )
            [43] = array(
                [0] = 5
                [1] = 3.5
                [2] = 1.6
                [3] = 0.6
            )
            [44] = array(
                [0] = 5.1
                [1] = 3.8
                [2] = 1.9
                [3] = 0.4
            )
            [45] = array(
                [0] = 7
                [1] = 3.2
                [2] = 4.7
                [3] = 1.4
            )
            [46] = array(
                [0] = 6.4
                [1] = 3.2
                [2] = 4.5
                [3] = 1.5
            )
            [47] = array(
                [0] = 6.9
                [1] = 3.1
                [2] = 4.9
                [3] = 1.5
            )
            [48] = array(
                [0] = 5.5
                [1] = 2.3
                [2] = 4
                [3] = 1.3
            )
            [49] = array(
                [0] = 6.5
                [1] = 2.8
                [2] = 4.6
                [3] = 1.5
            )
            [50] = array(
                [0] = 5.7
                [1] = 2.8
                [2] = 4.5
                [3] = 1.3
            )
            [51] = array(
                [0] = 6.3
                [1] = 3.3
                [2] = 4.7
                [3] = 1.6
            )
            [52] = array(
                [0] = 4.9
                [1] = 2.4
                [2] = 3.3
                [3] = 1
            )
            [53] = array(
                [0] = 6.6
                [1] = 2.9
                [2] = 4.6
                [3] = 1.3
            )
            [54] = array(
                [0] = 5.2
                [1] = 2.7
                [2] = 3.9
                [3] = 1.4
            )
            [55] = array(
                [0] = 5
                [1] = 2
                [2] = 3.5
                [3] = 1
            )
            [56] = array(
                [0] = 5.9
                [1] = 3
                [2] = 4.2
                [3] = 1.5
            )
            [57] = array(
                [0] = 6
                [1] = 2.2
                [2] = 4
                [3] = 1
            )
            [58] = array(
                [0] = 6.1
                [1] = 2.9
                [2] = 4.7
                [3] = 1.4
            )
            [59] = array(
                [0] = 5.6
                [1] = 2.9
                [2] = 3.6
                [3] = 1.3
            )
            [60] = array(
                [0] = 6.7
                [1] = 3.1
                [2] = 4.4
                [3] = 1.4
            )
            [61] = array(
                [0] = 5.6
                [1] = 3
                [2] = 4.5
                [3] = 1.5
            )
            [62] = array(
                [0] = 5.8
                [1] = 2.7
                [2] = 4.1
                [3] = 1
            )
            [63] = array(
                [0] = 6.2
                [1] = 2.2
                [2] = 4.5
                [3] = 1.5
            )
            [64] = array(
                [0] = 5.6
                [1] = 2.5
                [2] = 3.9
                [3] = 1.1
            )
            [65] = array(
                [0] = 5.9
                [1] = 3.2
                [2] = 4.8
                [3] = 1.8
            )
            [66] = array(
                [0] = 6.1
                [1] = 2.8
                [2] = 4
                [3] = 1.3
            )
            [67] = array(
                [0] = 6.3
                [1] = 2.5
                [2] = 4.9
                [3] = 1.5
            )
            [68] = array(
                [0] = 6.1
                [1] = 2.8
                [2] = 4.7
                [3] = 1.2
            )
            [69] = array(
                [0] = 6.4
                [1] = 2.9
                [2] = 4.3
                [3] = 1.3
            )
            [70] = array(
                [0] = 6.6
                [1] = 3
                [2] = 4.4
                [3] = 1.4
            )
            [71] = array(
                [0] = 6.8
                [1] = 2.8
                [2] = 4.8
                [3] = 1.4
            )
            [72] = array(
                [0] = 6.7
                [1] = 3
                [2] = 5
                [3] = 1.7
            )
            [73] = array(
                [0] = 6
                [1] = 2.9
                [2] = 4.5
                [3] = 1.5
            )
            [74] = array(
                [0] = 5.7
                [1] = 2.6
                [2] = 3.5
                [3] = 1
            )
            [75] = array(
                [0] = 5.5
                [1] = 2.4
                [2] = 3.8
                [3] = 1.1
            )
            [76] = array(
                [0] = 5.5
                [1] = 2.4
                [2] = 3.7
                [3] = 1
            )
            [77] = array(
                [0] = 5.8
                [1] = 2.7
                [2] = 3.9
                [3] = 1.2
            )
            [78] = array(
                [0] = 6
                [1] = 2.7
                [2] = 5.1
                [3] = 1.6
            )
            [79] = array(
                [0] = 5.4
                [1] = 3
                [2] = 4.5
                [3] = 1.5
            )
            [80] = array(
                [0] = 6
                [1] = 3.4
                [2] = 4.5
                [3] = 1.6
            )
            [81] = array(
                [0] = 6.7
                [1] = 3.1
                [2] = 4.7
                [3] = 1.5
            )
            [82] = array(
                [0] = 6.3
                [1] = 2.3
                [2] = 4.4
                [3] = 1.3
            )
            [83] = array(
                [0] = 5.6
                [1] = 3
                [2] = 4.1
                [3] = 1.3
            )
            [84] = array(
                [0] = 5.5
                [1] = 2.5
                [2] = 4
                [3] = 1.3
            )
            [85] = array(
                [0] = 5.5
                [1] = 2.6
                [2] = 4.4
                [3] = 1.2
            )
            [86] = array(
                [0] = 6.1
                [1] = 3
                [2] = 4.6
                [3] = 1.4
            )
            [87] = array(
                [0] = 5.8
                [1] = 2.6
                [2] = 4
                [3] = 1.2
            )
            [88] = array(
                [0] = 5
                [1] = 2.3
                [2] = 3.3
                [3] = 1
            )
            [89] = array(
                [0] = 5.6
                [1] = 2.7
                [2] = 4.2
                [3] = 1.3
            )
            [90] = array(
                [0] = 6.3
                [1] = 3.3
                [2] = 6
                [3] = 2.5
            )
            [91] = array(
                [0] = 5.8
                [1] = 2.7
                [2] = 5.1
                [3] = 1.9
            )
            [92] = array(
                [0] = 7.1
                [1] = 3
                [2] = 5.9
                [3] = 2.1
            )
            [93] = array(
                [0] = 6.3
                [1] = 2.9
                [2] = 5.6
                [3] = 1.8
            )
            [94] = array(
                [0] = 6.5
                [1] = 3
                [2] = 5.8
                [3] = 2.2
            )
            [95] = array(
                [0] = 7.6
                [1] = 3
                [2] = 6.6
                [3] = 2.1
            )
            [96] = array(
                [0] = 4.9
                [1] = 2.5
                [2] = 4.5
                [3] = 1.7
            )
            [97] = array(
                [0] = 7.3
                [1] = 2.9
                [2] = 6.3
                [3] = 1.8
            )
            [98] = array(
                [0] = 6.7
                [1] = 2.5
                [2] = 5.8
                [3] = 1.8
            )
            [99] = array(
                [0] = 7.2
                [1] = 3.6
                [2] = 6.1
                [3] = 2.5
            )
            [100] = array(
                [0] = 6.5
                [1] = 3.2
                [2] = 5.1
                [3] = 2
            )
            [101] = array(
                [0] = 6.4
                [1] = 2.7
                [2] = 5.3
                [3] = 1.9
            )
            [102] = array(
                [0] = 6.8
                [1] = 3
                [2] = 5.5
                [3] = 2.1
            )
            [103] = array(
                [0] = 5.7
                [1] = 2.5
                [2] = 5
                [3] = 2
            )
            [104] = array(
                [0] = 5.8
                [1] = 2.8
                [2] = 5.1
                [3] = 2.4
            )
            [105] = array(
                [0] = 6.4
                [1] = 3.2
                [2] = 5.3
                [3] = 2.3
            )
            [106] = array(
                [0] = 6.5
                [1] = 3
                [2] = 5.5
                [3] = 1.8
            )
            [107] = array(
                [0] = 7.7
                [1] = 3.8
                [2] = 6.7
                [3] = 2.2
            )
            [108] = array(
                [0] = 7.7
                [1] = 2.6
                [2] = 6.9
                [3] = 2.3
            )
            [109] = array(
                [0] = 6
                [1] = 2.2
                [2] = 5
                [3] = 1.5
            )
            [110] = array(
                [0] = 6.9
                [1] = 3.2
                [2] = 5.7
                [3] = 2.3
            )
            [111] = array(
                [0] = 5.6
                [1] = 2.8
                [2] = 4.9
                [3] = 2
            )
            [112] = array(
                [0] = 7.7
                [1] = 2.8
                [2] = 6.7
                [3] = 2
            )
            [113] = array(
                [0] = 6.3
                [1] = 2.7
                [2] = 4.9
                [3] = 1.8
            )
            [114] = array(
                [0] = 6.7
                [1] = 3.3
                [2] = 5.7
                [3] = 2.1
            )
            [115] = array(
                [0] = 7.2
                [1] = 3.2
                [2] = 6
                [3] = 1.8
            )
            [116] = array(
                [0] = 6.2
                [1] = 2.8
                [2] = 4.8
                [3] = 1.8
            )
            [117] = array(
                [0] = 6.1
                [1] = 3
                [2] = 4.9
                [3] = 1.8
            )
            [118] = array(
                [0] = 6.4
                [1] = 2.8
                [2] = 5.6
                [3] = 2.1
            )
            [119] = array(
                [0] = 7.2
                [1] = 3
                [2] = 5.8
                [3] = 1.6
            )
            [120] = array(
                [0] = 7.4
                [1] = 2.8
                [2] = 6.1
                [3] = 1.9
            )
            [121] = array(
                [0] = 7.9
                [1] = 3.8
                [2] = 6.4
                [3] = 2
            )
            [122] = array(
                [0] = 6.4
                [1] = 2.8
                [2] = 5.6
                [3] = 2.2
            )
            [123] = array(
                [0] = 6.3
                [1] = 2.8
                [2] = 5.1
                [3] = 1.5
            )
            [124] = array(
                [0] = 6.1
                [1] = 2.6
                [2] = 5.6
                [3] = 1.4
            )
            [125] = array(
                [0] = 7.7
                [1] = 3
                [2] = 6.1
                [3] = 2.3
            )
            [126] = array(
                [0] = 6.3
                [1] = 3.4
                [2] = 5.6
                [3] = 2.4
            )
            [127] = array(
                [0] = 6.4
                [1] = 3.1
                [2] = 5.5
                [3] = 1.8
            )
            [128] = array(
                [0] = 6
                [1] = 3
                [2] = 4.8
                [3] = 1.8
            )
            [129] = array(
                [0] = 6.9
                [1] = 3.1
                [2] = 5.4
                [3] = 2.1
            )
            [130] = array(
                [0] = 6.7
                [1] = 3.1
                [2] = 5.6
                [3] = 2.4
            )
            [131] = array(
                [0] = 6.9
                [1] = 3.1
                [2] = 5.1
                [3] = 2.3
            )
            [132] = array(
                [0] = 5.8
                [1] = 2.7
                [2] = 5.1
                [3] = 1.9
            )
            [133] = array(
                [0] = 6.8
                [1] = 3.2
                [2] = 5.9
                [3] = 2.3
            )
            [134] = array(
                [0] = 6.7
                [1] = 3.3
                [2] = 5.7
                [3] = 2.5
            )
        )
        .labels = array(
            [0] = "Iris-setosa"
            [1] = "Iris-setosa"
            [2] = "Iris-setosa"
            [3] = "Iris-setosa"
            [4] = "Iris-setosa"
            [5] = "Iris-setosa"
            [6] = "Iris-setosa"
            [7] = "Iris-setosa"
            [8] = "Iris-setosa"
            [9] = "Iris-setosa"
            [10] = "Iris-setosa"
            [11] = "Iris-setosa"
            [12] = "Iris-setosa"
            [13] = "Iris-setosa"
            [14] = "Iris-setosa"
            [15] = "Iris-setosa"
            [16] = "Iris-setosa"
            [17] = "Iris-setosa"
            [18] = "Iris-setosa"
            [19] = "Iris-setosa"
            [20] = "Iris-setosa"
            [21] = "Iris-setosa"
            [22] = "Iris-setosa"
            [23] = "Iris-setosa"
            [24] = "Iris-setosa"
            [25] = "Iris-setosa"
            [26] = "Iris-setosa"
            [27] = "Iris-setosa"
            [28] = "Iris-setosa"
            [29] = "Iris-setosa"
            [30] = "Iris-setosa"
            [31] = "Iris-setosa"
            [32] = "Iris-setosa"
            [33] = "Iris-setosa"
            [34] = "Iris-setosa"
            [35] = "Iris-setosa"
            [36] = "Iris-setosa"
            [37] = "Iris-setosa"
            [38] = "Iris-setosa"
            [39] = "Iris-setosa"
            [40] = "Iris-setosa"
            [41] = "Iris-setosa"
            [42] = "Iris-setosa"
            [43] = "Iris-setosa"
            [44] = "Iris-setosa"
            [45] = "Iris-versicolor"
            [46] = "Iris-versicolor"
            [47] = "Iris-versicolor"
            [48] = "Iris-versicolor"
            [49] = "Iris-versicolor"
            [50] = "Iris-versicolor"
            [51] = "Iris-versicolor"
            [52] = "Iris-versicolor"
            [53] = "Iris-versicolor"
            [54] = "Iris-versicolor"
            [55] = "Iris-versicolor"
            [56] = "Iris-versicolor"
            [57] = "Iris-versicolor"
            [58] = "Iris-versicolor"
            [59] = "Iris-versicolor"
            [60] = "Iris-versicolor"
            [61] = "Iris-versicolor"
            [62] = "Iris-versicolor"
            [63] = "Iris-versicolor"
            [64] = "Iris-versicolor"
            [65] = "Iris-versicolor"
            [66] = "Iris-versicolor"
            [67] = "Iris-versicolor"
            [68] = "Iris-versicolor"
            [69] = "Iris-versicolor"
            [70] = "Iris-versicolor"
            [71] = "Iris-versicolor"
            [72] = "Iris-versicolor"
            [73] = "Iris-versicolor"
            [74] = "Iris-versicolor"
            [75] = "Iris-versicolor"
            [76] = "Iris-versicolor"
            [77] = "Iris-versicolor"
            [78] = "Iris-versicolor"
            [79] = "Iris-versicolor"
            [80] = "Iris-versicolor"
            [81] = "Iris-versicolor"
            [82] = "Iris-versicolor"
            [83] = "Iris-versicolor"
            [84] = "Iris-versicolor"
            [85] = "Iris-versicolor"
            [86] = "Iris-versicolor"
            [87] = "Iris-versicolor"
            [88] = "Iris-versicolor"
            [89] = "Iris-versicolor"
            [90] = "Iris-virginica"
            [91] = "Iris-virginica"
            [92] = "Iris-virginica"
            [93] = "Iris-virginica"
            [94] = "Iris-virginica"
            [95] = "Iris-virginica"
            [96] = "Iris-virginica"
            [97] = "Iris-virginica"
            [98] = "Iris-virginica"
            [99] = "Iris-virginica"
            [100] = "Iris-virginica"
            [101] = "Iris-virginica"
            [102] = "Iris-virginica"
            [103] = "Iris-virginica"
            [104] = "Iris-virginica"
            [105] = "Iris-virginica"
            [106] = "Iris-virginica"
            [107] = "Iris-virginica"
            [108] = "Iris-virginica"
            [109] = "Iris-virginica"
            [110] = "Iris-virginica"
            [111] = "Iris-virginica"
            [112] = "Iris-virginica"
            [113] = "Iris-virginica"
            [114] = "Iris-virginica"
            [115] = "Iris-virginica"
            [116] = "Iris-virginica"
            [117] = "Iris-virginica"
            [118] = "Iris-virginica"
            [119] = "Iris-virginica"
            [120] = "Iris-virginica"
            [121] = "Iris-virginica"
            [122] = "Iris-virginica"
            [123] = "Iris-virginica"
            [124] = "Iris-virginica"
            [125] = "Iris-virginica"
            [126] = "Iris-virginica"
            [127] = "Iris-virginica"
            [128] = "Iris-virginica"
            [129] = "Iris-virginica"
            [130] = "Iris-virginica"
            [131] = "Iris-virginica"
            [132] = "Iris-virginica"
            [133] = "Iris-virginica"
            [134] = "Iris-virginica"
        )
    )
    .testing = object(
        .features = array(
            [0] = array(
                [0] = 4.8
                [1] = 3
                [2] = 1.4
                [3] = 0.3
                [4] = 0
            )
            [1] = array(
                [0] = 5.1
                [1] = 3.8
                [2] = 1.6
                [3] = 0.2
                [4] = 0
            )
            [2] = array(
                [0] = 4.6
                [1] = 3.2
                [2] = 1.4
                [3] = 0.2
                [4] = 0
            )
            [3] = array(
                [0] = 5.3
                [1] = 3.7
                [2] = 1.5
                [3] = 0.2
                [4] = 0
            )
            [4] = array(
                [0] = 5
                [1] = 3.3
                [2] = 1.4
                [3] = 0.2
                [4] = 0
            )
            [5] = array(
                [0] = 5.7
                [1] = 3
                [2] = 4.2
                [3] = 1.2
                [4] = 0
            )
            [6] = array(
                [0] = 5.7
                [1] = 2.9
                [2] = 4.2
                [3] = 1.3
                [4] = 0
            )
            [7] = array(
                [0] = 6.2
                [1] = 2.9
                [2] = 4.3
                [3] = 1.3
                [4] = 0
            )
            [8] = array(
                [0] = 5.1
                [1] = 2.5
                [2] = 3
                [3] = 1.1
                [4] = 0
            )
            [9] = array(
                [0] = 5.7
                [1] = 2.8
                [2] = 4.1
                [3] = 1.3
                [4] = 0
            )
            [10] = array(
                [0] = 6.7
                [1] = 3
                [2] = 5.2
                [3] = 2.3
                [4] = 0
            )
            [11] = array(
                [0] = 6.3
                [1] = 2.5
                [2] = 5
                [3] = 1.9
                [4] = 0
            )
            [12] = array(
                [0] = 6.5
                [1] = 3
                [2] = 5.2
                [3] = 2
                [4] = 0
            )
            [13] = array(
                [0] = 6.2
                [1] = 3.4
                [2] = 5.4
                [3] = 2.3
                [4] = 0
            )
            [14] = array(
                [0] = 5.9
                [1] = 3
                [2] = 5.1
                [3] = 1.8
                [4] = 0
            )
        )
        .labels = array(
            [0] = "Iris-setosa"
            [1] = "Iris-setosa"
            [2] = "Iris-setosa"
            [3] = "Iris-setosa"
            [4] = "Iris-setosa"
            [5] = "Iris-versicolor"
            [6] = "Iris-versicolor"
            [7] = "Iris-versicolor"
            [8] = "Iris-versicolor"
            [9] = "Iris-versicolor"
            [10] = "Iris-virginica"
            [11] = "Iris-virginica"
            [12] = "Iris-virginica"
            [13] = "Iris-virginica"
            [14] = "Iris-virginica"
        )
    )
)


← Back to the Dinfio Playground / Download this program