by Juan Brugera Monedero and Javier Muñoz Alonso.
Starting from the Kaggle competition we will try to achieve being in the top 120 private leaderboard to win a silver medal.
In Kaggle, test data is not labeled, so the first thing we did was take a 10% of records from train to test and upload it to Dropbox in case these are no longer available.
Our process automatically dowloand them from Dropbox, but if you want to download yourself, you could do it from here:
All code in our process has been developed with python and third-party libraries, so the first thing you have to do is prepare an eviroment to be able to run all the code.
Don't worry, it's just as easy as follow the steps below.
Asuming you have ever installed Conda and JDK (follow the links if not) you should run these commands in a Terminal (maybe bash):
conda create -n mimape python=3
conda activate mimape # source activate if conda version earlier than 4.6
conda install jupyter
conda install seaborn
conda install matplotlib
conda install scikit-learn
conda install xgboost
conda install pandas
conda install numpy
conda install pyspark
conda install requests
P.S.: Python3 own libraries as warnings, itertools, logging and os are also used in this code.
The main code is at a Jupyter Notebook names as Main.ipynb and it's commented but there are another .py files to have in consideration.
- Utilities.py : Auxiliary functions that are used in the main process frequently.
- Spark.py : Apache Spark initialization for local runs.
- Resources.py : Pre-loaded variables collection.
- DataGetter.py, DataResources.py and Data.py : Auxiliary functions to download Train and Test from Dropbox.
At the beginning of the process there is a configuration cell where you can configure certain parameters.
These are the most important (and the only should be modified):
cv = 3 # Loops in data for cross validation searches
n_iter = 30 # Number of parameter settings that are sampled in RandomizedSearchCV
sample_size = .1 # train sample percentage due to the large volume of data
cut_at = .01 # variable weight (percentage) to be in model
The goal of this competition is to predict a Windows machine’s probability of getting infected by various families of malware.
For this, we make use of classifiers as Decision Trees, Random Forest or XGBoost.
Our principal score will be the Area Under the Curve ROC but we will use also other scores like precision, accuray or recall.
In this chapter, we perfom all the necessary code (like imports, configurations and some defs) to run the process.
At this point, we plot graphics for each variable and its values. You will find it at ./Analysis.tgz.
In our inexperienced opinion, due to the variety of values of each characteristic and its distribution, it was not worth transforming its values.
In fact, we tried, but we made all the scores worse during the process, so we finally dismissed these changes.
Due to a personal (bad) criterion, we decide fitting our model with features which contain less than 100 different values.
Being a bit more reasonable, we decided to create a correlation matrix and based on that try to improve the score of the metrics.
We did it, but we are not yet positioned in the ranking as we would like.
We decided to try all the features obtaining the weights of each of them for each of the models to finally take those with a relevance higher than 1% and perform the process with SparkML.
We also predict against test and we achieve a score of ~0.65.
After obtaining certain conclusions, we launched the process with Spark and with those hyper parameters with which we hope to obtain better results.
A reporting visualization tool with some statistics about process is available at this link.
It's interactive so you can pass the mouse over graphics and select or unselect the things you want to see clicking in the coloured circles.
Finally, we get a ~0.68 score, meaning we reach the top 1 position in the private leaderboard. We are really proud of this fact, even more considering competition difficulty and the complexity of the data.
We are also satisfied with the tools and knowledge acquired about them.
We want to thank the entire faculty of the K-School for the time and patience spent in us, especially Daniel Mateos and Sebastien Perez Vasseur who have guided and cared for us throughout the course, even after class hours.
- SparkConf for running local process can be changed in Spark.py.
- Some information from Main.ipynb may not match with the presented here due to a final run with a 1% (instead of 10%) sample from train.
Unavailable or self-documenting column names are marked with an "NA".
- MachineIdentifier- Individual machine ID
- ProductName- Defender state information e.g. win8defender
- EngineVersion- Defender state information e.g. 1.1.12603.0
- AppVersion- Defender state information e.g. 4.9.10586.0
- AvSigVersion- Defender state information e.g. 1.217.1014.0
- IsBeta- Defender state information e.g. false
- RtpStateBitfield- NA
- IsSxsPassiveMode- NA
- DefaultBrowsersIdentifier- ID for the machine's default browser
- AVProductStatesIdentifier- ID for the specific configuration of a user's antivirus software
- AVProductsInstalled- NA
- AVProductsEnabled- NA
- HasTpm- True if machine has tpm
- CountryIdentifier- ID for the country the machine is located in
- CityIdentifier- ID for the city the machine is located in
- OrganizationIdentifier- ID for the organization the machine belongs in, organization ID is mapped to both specific companies and broad industries
- GeoNameIdentifier- ID for the geographic region a machine is located in
- LocaleEnglishNameIdentifier- English name of Locale ID of the current user
- Platform- Calculates platform name (of OS related properties and processor property)
- Processor- This is the process architecture of the installed operating system
- OsVer- Version of the current operating system
- OsBuild- Build of the current operating system
- OsSuite- Product suite mask for the current operating system.
- OsPlatformSubRelease- Returns the OS Platform sub-release (Windows Vista, Windows 7, Windows 8, TH1, TH2)
- OsBuildLab- Build lab that generated the current OS. Example: 9600.17630.amd64fre.winblue_r7.150109-2022
- SkuEdition- The goal of this feature is to use the Product Type defined in the MSDN to map to a 'SKU-Edition' name that is useful in population reporting. The valid Product Type are defined in %sdxroot%\data\windowseditions.xml. This API has been used since Vista and Server 2008, so there are many Product Types that do not apply to Windows 10. The 'SKU-Edition' is a string value that is in one of three classes of results. The design must hand each class.
- IsProtected- This is a calculated field derived from the Spynet Report's AV Products field. Returns: a. TRUE if there is at least one active and up-to-date antivirus product running on this machine. b. FALSE if there is no active AV product on this machine, or if the AV is active, but is not receiving the latest updates. c. null if there are no Anti Virus Products in the report. Returns: Whether a machine is protected.
- AutoSampleOptIn- This is the SubmitSamplesConsent value passed in from the service, available on CAMP 9+
- PuaMode- Pua Enabled mode from the service
- SMode- This field is set to true when the device is known to be in 'S Mode', as in, Windows 10 S mode, where only Microsoft Store apps can be installed
- IeVerIdentifier- NA
- SmartScreen- This is the SmartScreen enabled string value from registry. This is obtained by checking in order, HKLM\SOFTWARE\Policies\Microsoft\Windows\System\SmartScreenEnabled and HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SmartScreenEnabled. If the value exists but is blank, the value "ExistsNotSet" is sent in telemetry.
- Firewall- This attribute is true (1) for Windows 8.1 and above if windows firewall is enabled, as reported by the service.
- UacLuaenable- This attribute reports whether or not the "administrator in Admin Approval Mode" user type is disabled or enabled in UAC. The value reported is obtained by reading the regkey HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA.
- Census_MDC2FormFactor- A grouping based on a combination of Device Census level hardware characteristics. The logic used to define Form Factor is rooted in business and industry standards and aligns with how people think about their device. (Examples: Smartphone, Small Tablet, All in One, Convertible...)
- Census_DeviceFamily- AKA DeviceClass. Indicates the type of device that an edition of the OS is intended for. Example values: Windows.Desktop, Windows.Mobile, and iOS.Phone
- Census_OEMNameIdentifier- NA
- Census_OEMModelIdentifier- NA
- Census_ProcessorCoreCount- Number of logical cores in the processor
- Census_ProcessorManufacturerIdentifier- NA
- Census_ProcessorModelIdentifier- NA
- Census_ProcessorClass- A classification of processors into high/medium/low. Initially used for Pricing Level SKU. No longer maintained and updated
- Census_PrimaryDiskTotalCapacity- Amount of disk space on primary disk of the machine in MB
- Census_PrimaryDiskTypeName- Friendly name of Primary Disk Type - HDD or SSD
- Census_SystemVolumeTotalCapacity- The size of the partition that the System volume is installed on in MB
- Census_HasOpticalDiskDrive- True indicates that the machine has an optical disk drive (CD/DVD)
- Census_TotalPhysicalRAM- Retrieves the physical RAM in MB
- Census_ChassisTypeName- Retrieves a numeric representation of what type of chassis the machine has. A value of 0 means xx
- Census_InternalPrimaryDiagonalDisplaySizeInInches- Retrieves the physical diagonal length in inches of the primary display
- Census_InternalPrimaryDisplayResolutionHorizontal- Retrieves the number of pixels in the horizontal direction of the internal display.
- Census_InternalPrimaryDisplayResolutionVertical- Retrieves the number of pixels in the vertical direction of the internal display
- Census_PowerPlatformRoleName- Indicates the OEM preferred power management profile. This value helps identify the basic form factor of the device
- Census_InternalBatteryType- NA
- Census_InternalBatteryNumberOfCharges- NA
- Census_OSVersion- Numeric OS version Example - 10.0.10130.0
- Census_OSArchitecture- Architecture on which the OS is based. Derived from OSVersionFull. Example - amd64
- Census_OSBranch- Branch of the OS extracted from the OsVersionFull. Example - OsBranch = fbl_partner_eeap where OsVersion = 6.4.9813.0.amd64fre.fbl_partner_eeap.140810-0005
- Census_OSBuildNumber- OS Build number extracted from the OsVersionFull. Example - OsBuildNumber = 10512 or 10240
- Census_OSBuildRevision- OS Build revision extracted from the OsVersionFull. Example - OsBuildRevision = 1000 or 16458
- Census_OSEdition- Edition of the current OS. Sourced from HKLM\Software\Microsoft\Windows NT\CurrentVersion@EditionID in registry. Example: Enterprise
- Census_OSSkuName- OS edition friendly name (currently Windows only)
- Census_OSInstallTypeName- Friendly description of what install was used on the machine i.e. clean
- Census_OSInstallLanguageIdentifier- NA
- Census_OSUILocaleIdentifier- NA
- Census_OSWUAutoUpdateOptionsName- Friendly name of the WindowsUpdate auto-update settings on the machine.
- Census_IsPortableOperatingSystem- Indicates whether OS is booted up and running via Windows-To-Go on a USB stick.
- Census_GenuineStateName- Friendly name of OSGenuineStateID. 0 = Genuine
- Census_ActivationChannel- Retail license key or Volume license key for a machine.
- Census_IsFlightingInternal- NA
- Census_IsFlightsDisabled- Indicates if the machine is participating in flighting.
- Census_FlightRing- The ring that the device user would like to receive flights for. This might be different from the ring of the OS which is currently installed if the user changes the ring after getting a flight from a different ring.
- Census_ThresholdOptIn- NA
- Census_FirmwareManufacturerIdentifier- NA
- Census_FirmwareVersionIdentifier- NA
- Census_IsSecureBootEnabled- Indicates if Secure Boot mode is enabled.
- Census_IsWIMBootEnabled- NA
- Census_IsVirtualDevice- Identifies a Virtual Machine (machine learning model)
- Census_IsTouchEnabled- Is this a touch device ?
- Census_IsPenCapable- Is the device capable of pen input ?
- Census_IsAlwaysOnAlwaysConnectedCapable- Retreives information about whether the battery enables the device to be AlwaysOnAlwaysConnected.
- Wdft_IsGamer- Indicates whether the device is a gamer device or not based on its hardware combination.
- Wdft_RegionIdentifier- NA
- HasDetections is the ground truth and indicates that Malware was detected on the machine.