API Documents of AutoKNN application

Your personal token

API Endpoints of AutoKNN

This endpoint is used to register a new user, and then a verification email is being sent. Example of the request body:

{
    "fname": "first_name",
    "lname": "last_name",
    "email": "registered_email@example.com",
    "password": "registered_password",
    "confirmPassword": "registered_password"
}
                                            

Example of the response body:

{"status": "success", "message": "Registration successful. Verification email sent."}
                                            

This endpoint is used to login in the application. Example of the request body:

{
    "email": "your_email@example.com",
    "password": "your_password"
}
                                            

Example of the response body:

{
    "status": "success",
    "token": "your_token",
    "fname": "your_first_name",
    "lname": "your_last_name",
    "allowPublic": "permission_for_uploading_datasets_publicly"
}
                                            

This endpoint is used to edit either the username (first and/or last name), or the password, or both of the user. Example of the request body:

{
    "token": "your_token",
    "firstName": "your_first_name" ?? null,
    "lastName": "your_last_name" ?? null,
    "currentPassword": "your_password" ?? null,
    "newPassword": "your_new_password" ?? null,
    "confirmPassword": "your_new_password" ?? null
}
                                            

Example of the response body:

{"status": "success", "message": "User details updated successfully"}
                                            

This endpoint is used to edit the email of the user. Example of the request body:

{
    "token": "your_token",
    "email": "new_email@example.com"
}
                                            

Example of the response body:

{"status": "success", "message": "Change of email was successful."}
                                            

This endpoint is used to delete the account of the user. Example of the request body:

{
    "email": "your_email@example.com",
    "password": "your_password",
    "confirmPassword": "your_password",
    "token": "your_token"
}
                                            

Example of the response body:

{"status": "success", "message": "Account deleted successfully"}
                                            

This endpoint is used to list all the available datasets. Example of the request body:

{
    "token": "your_token"
}
                                            

Example of the response body:

{
    "public": ["public_dataset_1.csv",""public_dataset_2.csv"],
    "private": ["private_dataset_1.csv",""private_dataset_2.csv"]
}
                                            

This endpoint is used to upload a new dataset. Example of the request body:

{
    "token": "your_token",
    "folder": "selected_uploading_folder",
    "allowPublic": "permission_for_uploading_datasets_publicly",
    "file": "uploaded_dataset.csv",
}
                                            

Example of the response body:

{"status": "success", "message": "File uploaded successfully.", "file": "uploaded_dataset.csv"]}
                                            

This endpoint is used to load the dataset that the user has selected. Example of the request body:

{
    "token": "your_token",
    "folder": "folder_of_selected_dataset",
    "file": "selected_dataset.csv"
}
                                            

Example of the response body:

{
    "status": "success",
    "header": [
        "sepal.length",
        "sepal.width",
        "petal.length",
        "petal.width",
        "variety"
    ],
    "data": [
        [
            "5.1",
            "3.5",
            "1.4",
            ".2",
            "Setosa"
        ],
        [
            "4.9",
            "3",
            "1.4",
            ".2",
            "Setosa"
        ],
        [
            "4.7",
            "3.2",
            "1.3",
            ".2",
            "Setosa"
        ],
        ...
    ],
    "counter": "data_row_counter" 
}
                                            

This endpoint is used to download the selected dataset. Example of the request body:

{
    "token": "your_token",
    "file": "selected_dataset.csv"
}
                                            

Example of the response body:

{"status": "success", "message": "Download was successful."}
                                            

This endpoint is used to delete the selected dataset. Example of the request body:

{
    "token": "your_token",
    "folder": "folder_of_selected_dataset",
    "file": "selected_dataset.csv"
}
                                            

Example of the response body:

{"status": "success", "message": "Successfully deleted the 'selected_dataset.csv' dataset from 'folder_of_selected_dataset' folder"}
                                            

This endpoint is used to list all the available unclassified datasets. Example of the request body:

{
    "token": "your_token"
}
                                            

Example of the response body:

{
    "status": "success", 
    "unclassifiedDatasets": ["unclassified_dataset1.csv","unclassified_dataset2.csv"]
}
                                            

This endpoint is used to upload a new (preferably unclassified) dataset that matches the one used to create the selected model. Example of the request body:

{
    "token": "your_token",
    "file": "uploaded_dataset.csv",
}
                                            

Example of the response body:

{"status": "success", "message": "File uploaded successfully.", "file": 'uploaded_dataset.csv'}
                                            

This endpoint is used to load the unclassified dataset that the user has selected. Example of the request body:

{
    "token": "your_token",
    "file": "selected_dataset.csv"
}
                                            

Example of the response body:

{
    "status": "success",
    "header": [
        "sepal.length",
        "sepal.width",
        "petal.length",
        "petal.width",
        "variety"
    ],
    "data": [
        [
            "5.1",
            "3.5",
            "1.4",
            ".2",
            "Setosa"
        ],
        [
            "4.9",
            "3",
            "1.4",
            ".2",
            "Setosa"
        ],
        [
            "4.7",
            "3.2",
            "1.3",
            ".2",
            "Setosa"
        ],
        ...
    ]  
}
                                            

This endpoint is used to download the selected unclassified dataset. Example of the request body:

{
    "token": "your_token",
    "file": "selected_dataset.csv"
}
                                            

Example of the response body:

{"status": "success", "message": "Download was successful."}
                                            

This endpoint is used to delete the selected unclassified dataset. Example of the request body:

{
    "token": "your_token",
    "file": "selected_dataset.csv"
}
                                            

Example of the response body:

{"status": "success", "message": "'selected_dataset.csv' dataset deleted successfully"}
                                            

This endpoint is used to load the classified dataset (from the selected unclassified into classified). Also, if the user uploads a dataset that has the class column, it'll display the class and the one that got predicted and also below the table the metrics per class and the average metrics. Else, only the one that got predicted. Example of the request body:

{
    "token": "your_token",
    "file": "classified_dataset.csv"
}
                                            

Example of the response body:

{
    "status": "success",
    (if dataset has class column)
    "header": [
        "sepal.length",
        "sepal.width",
        "petal.length",
        "petal.width",
        "variety",
        "predicted"
    ],
    "data": [
        [
            "5.1",
            "3.5",
            "1.4",
            ".2",
            "Setosa",
            "Setosa"
        ],
        [
            "4.9",
            "3",
            "1.4",
            ".2",
            "Setosa",
            "Versicolor"
        ],
        [
            "4.7",
            "3.2",
            "1.3",
            ".2",
            "Setosa",
            "Virginica"
        ],
        ...
    ] or
    (if dataset has no class column)
    "header": [
        "sepal.length",
        "sepal.width",
        "petal.length",
        "petal.width",
        "predicted"
    ],
    "data": [
        [
            "5.1",
            "3.5",
            "1.4",
            ".2",
            "Setosa"
        ],
        [
            "4.9",
            "3",
            "1.4",
            ".2",
            "Versicolor"
        ],
        [
            "4.7",
            "3.2",
            "1.3",
            ".2",
            "Virginica"
        ]
    ]
}
                                            

This endpoint is used to download the classified dataset. Example of the request body:

{
    "token": "your_token",
    "file": "classified_dataset.csv"
}
                                            

Example of the response body:

{"status": "success", "message": "Download was successful."}
                                            

This endpoint is used to list all the built models. Example of the request body:

{
    "token": "your_token"
}
                                            

Example of the response body:

{
    "status": "success", 
    "models": [
        {
            "name": "model1.pkl",
            "path": "..\/path\/to\/model1.pkl"
        },
        {
            "name": "model2.pkl",
            "path": "..\/path\/to\/model2.pkl"
        },
        {
            "name": "model2.pkl",
            "path": "..\/path\/to\/model3.pkl"
        }
    ]
}
                                            

This endpoint is used to get the contents of the model (selected features and class). Example of the request body:

{
    "token": "your_token",
    "model": "selected_model.pkl"
}
                                            

Example of the response body:

{
    "status": "success", 
    "features": [
        "sepal.length",
        "sepal.width",
        "petal.length",
        "petal.width"
    ],
    "class": "variety"
}
                                            

This endpoint is used to download the selected model. Example of the request body:

{
    "token": "your_token",
    "model": "selected_model.pkl"
}
                                            

Example of the response body:

{"status": "success", "message": "Download was successful."}
                                            

This endpoint is used to delete the selected model. Example of the request body:

{
    "token": "your_token",
    "model": "selected_model.pkl"
}
                                            

Example of the response body:

{"status": "success", "message": "Model deleted successfully", "model": "name_of_selected_model.pkl"}
                                            

This endpoint is used to execute the KNN algorithm. Example of the request body:

{
    "token": "your_token",
    "file": "selected_dataset.csv",
    "folder": "folder_of_selected_dataset",
    "features": ["selected_feature1", "selected_feature2", "selected_feature3", "..."],
    "target": "selectedClass",
    "k_value": [k_value] or [1,...,50],
    "distance_value": ["metricDistance_value"] or ["euclidean", "manhattan", "chebyshev", "minkowski"],
    "p_value": [] or [3] or [4] or [3, 4],
    "stratify": true or false
}
                                            

Example of the response body:

{
    "message": "Algorithm already executed",
    "dataset_id": "executed_dataset_id",
    "folder": "folder_with_results",
    "status": "Completed"
} or 
{
    "message": "Completed execution of algorithm",
    "dataset_id": "generated_executed_dataset_id",
    "folder": "folder_with_results",
    "status": "Completed" or "Failed"
}
                                            

This endpoint is used to retrieve the results of the KNN algorithm (either before executing it, if it already exists, or after execution). Example of the request body:

{
    "dataset_id": "executed_dataset_id",
    "token": "your_token",
    "folder": "folder_of_executed_dataset"
}
                                            

Example of the response body:

{
    "dataset": "../../path/to/selected_dataset.csv",
    "features": [
        "selected_feature1",
        "selected_feature2",
        "selected_feature3",
        "..."
    ],
    "class": "selectedClass",
    "k_values": [k_value] or [
        1,
        ...,
        50
    ],
    "distance_values": [
        "metricDistance_value"
    ] or [
        "euclidean",
        "manhattan",
        "chebyshev",
        "minkowski"
    ],
    "p_value": [] or [3] or [4] or [3, 4],
    "stratified_sampling": true or false,
    "best_k": result_of_best_k,
    "best_distance": "result_of_best_metricDistance",
    "best_p": result_of_best_p,
    "max_accuracy": result_of_max_accuracy,
    "best_precision": result_of_best_precision,
    "best_recall": result_of_best_recall,
    "best_f1": result_of_best_fscore,
    "average_accuracy": calculated_average_accuracy,
    "average_precision": calculated_average_precision,
    "average_recall": calculated_average_recall,
    "average_f1": calculated_average_fscore,
    "class_metrics": [
        {
            "class": "class_label1",
            "precision": calculated_precision,
            "recall": calculated_recall,
            "f1": calculated_fscore
        },
        {
            "class": "class_label2",
            "precision": calculated_precision,
            "recall": calculated_recall,
            "f1": calculated_fscore
        },
        {
            "class": "class_label3",
            "precision": calculated_precision,
            "recall": calculated_recall,
            "f1": calculated_fscore
        }
    ]
}
                                            

This endpoint is being used to save the built model. Example of the request body:

{
    "token": "your_token",
    "file": "selected_dataset.csv",
    "dataset_id": "executed_dataset_id",
    "folder": "folder_with_results",
    "features": ["selected_feature1", "selected_feature2", "selected_feature3", "..."],
    "target": "selectedClass",
    "k_value": [k_value] or [1,...,50],
    "distance_value": ["metricDistance_value"] or ["euclidean", "manhattan", "chebyshev", "minkowski"],
    "p_value": [] or [3] or [4] or [3, 4],
    "best_k": result_of_best_k,
    "best_distance": "result_of_best_metricDistance",
    "best_p": result_of_best_p,
    "stratify": true or false,
    "model_name": "model_name_the_user_wants_to_save"
}
                                            

Example of the response body:

{"message": "Model saved successfully."}
                                            

This endpoint is being used to classify the dataset, based on the built model the user chose. Example of the request body:

{
    "token": "your_token",
    "features": ["selected_model_feature1", "selected_model_feature2", "selected_model_feature3", "..."],
    "class": "selected_model_class",
    "file": "selected_unclassified_file.csv",
    "model": "selected_model_file.pkl"
}
                                            

Example of the response body:

{
    "message": "Classification completed successfully",
    "results": {
        "dataset": [
            [
                "selected_model_feature1",
                "selected_model_feature2",
                "selected_model_feature3",
                ...,
                "predicted"
            ],
            [
                5.1,
                3.5,
                1.4,
                0.2,
                "selected_model_class_label1"
            ],
            [
                4.9,
                3,
                1.4,
                0.2,
                "selected_model_class_label2"
            ],
            [
                4.7,
                3.2,
                1.3,
                0.2,
                "selected_model_class_label3"
            ],
            ...
        ],
        "labels": [
            "label1",
            "label2",
            "label3",
            ...
        ]
    }, or
    "results": {
        "dataset": [
            [
                "selected_model_feature1",
                "selected_model_feature2",
                "selected_model_feature3",
                ...,
                "name_of_class",
                "predicted"
            ],
            [
                5.1,
                3.5,
                1.4,
                ..,
                "selected_dataset_class_label1",
                "selected_model_class_label1"
            ],
            [
                4.9,
                3,
                1.4,
                ...,
                "selected_dataset_class_label2",
                "selected_model_class_label2"
            ],
            [
                4.7,
                3.2,
                1.3,
                ...,
                "selected_dataset_class_label3",
                "selected_model_class_label3"
            ],
            ...
        ],
        "accuracy": calculated_accuracy,
        "average_precision": calculated_average_precision,
        "average_recall": calculated_average_recall,
        "average_f1_score": calculated_average_fscore,
        "precision_per_label": [
            calculated_label1,
            calculated_label2,
            calculated_label3,
            ...
        ],
        "recall_per_label": [
            calculated_label1,
            calculated_label2,
            calculated_label3,
            ...
        ],
        "f1_score_per_label": [
            calculated_label1,
            calculated_label2,
            calculated_label3,
            ...
        ],
        "labels": [
            "label1",
            "label2",
            "label3",
            ...
        ]
    },
    "classified_file": "../../path/to/classified_file.csv",
    "return_code": 0
}