making conformance score more robust #16
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
added:
The previous implementation took for the computation of the score value the minimum of the k-nearest neighbours = the 1-nearest neighbour, aka the parameter k had no influence except for the thresholding. This lead in some cases to anomalous behaviour if the corpus had some variance among itself.
The previous implementation could lead to such cases:
![Picture 1](https://private-user-images.githubusercontent.com/20500098/340334804-b7256d9b-ac27-41b7-8f9f-458a2002e822.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUzNTc2MTksIm5iZiI6MTcyNTM1NzMxOSwicGF0aCI6Ii8yMDUwMDA5OC8zNDAzMzQ4MDQtYjcyNTZkOWItYWMyNy00MWI3LThmOWYtNDU4YTIwMDJlODIyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAzVDA5NTUxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThmZTI1MzYwZTJmOTM5MGViNjQ5ZjFiZTY3ZTFlMzk0MjZiMjhmMWU3MDc1YmUyYjQxMTJjODFjN2RjZmE2NzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.8nXA3SDJgI0uPdQEMdeNdRCMTb1HES1pbluWthg6xFY)
Where, notably, the outliers are to the left of the inliers (inliers = generated from same distribution as the corpus). The dataset is here quiet complicated and we do not expect the algorithm to be able to distinguish between inliers and type-2-outliers; but at the very least, the type-2-outliers should not be closer to the corpus than the inliers (in fact, type-2-outliers are generated from a higher variance distribution than the corpus) . However, as evident in this first plot, the type-2-outliers are closer (lower conformance score) than the inliers.
Using the newly proposed median feature for k=10 nearest neighbours, this issue gets fixed:
![Picture 2](https://private-user-images.githubusercontent.com/20500098/340336057-58866399-11c6-4604-a400-d5b42ef5d91b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUzNTc2MTksIm5iZiI6MTcyNTM1NzMxOSwicGF0aCI6Ii8yMDUwMDA5OC8zNDAzMzYwNTctNTg4NjYzOTktMTFjNi00NjA0LWE0MDAtZDViNDJlZjVkOTFiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAzVDA5NTUxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJlOTQ4MWYxODNmOTA1NzQzMGUyZTA4ZTQyMzAyNDYzN2RkNGYzZTEyYzQwODgyNmY5OWMyZWVhNTk5YzBiNDQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.aV4TRBkMsvcXiES_KszgBvXpyjvS4xUC_ieq-y3EkdM)