# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python Docker image:
[Link]
# For example, here's several helpful packages to load
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
# Input data files are available in the read-only "../input/" directory
# For example, running this (by clicking run or pressing Shift+Enter) will list all
files under the input directory
import os
for dirname, _, filenames in [Link]('/kaggle/input'):
for filename in filenames:
print([Link](dirname, filename))
# You can write up to 20GB to the current directory (/kaggle/working/) that gets
preserved as output when you create a version using "Save & Run All"
# You can also write temporary files to /kaggle/temp/, but they won't be saved
outside of the current session
/kaggle/input/computer-virus-predictor/sample_submission.csv
/kaggle/input/computer-virus-predictor/[Link]
/kaggle/input/computer-virus-predictor/[Link]
train_df = pd.read_csv('/kaggle/input/computer-virus-predictor/[Link]')
train_1_df = train_df.drop(columns = ['MachineID','ProductName','EngineVersion',
'AppVersion','SignatureVersion', 'IsBetaUser', 'PlatformType','Processor',
'OSVersion','OsPlatformSubRelease','OSBuildLab',
'SKUEditionName','MDC2FormFactor','DeviceFamily','PrimaryDiskType','ChassisType','P
owerPlatformRole','NumericOSVersion','OSArchitecture','OSBranch','OSEdition','OSSku
FriendlyName','OSInstallType','AutoUpdateOptionsName','OSGenuineState','LicenseActi
vationChannel','FlightRing','DateAS','DateOS'])
train_1_df["id"] = train_1_df.index
train_1_df.head()
train_1_df.tail()
train_1_df.dtypes
import [Link] as plt
import seaborn as sns
[Link](train_1_df.corr(numeric_only=True))
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
train_1_df = train_1_df[train_1_df['RealTimeProtectionState'].notna()]
train_1_df = train_1_df[train_1_df['AntivirusConfigID'].notna()]
train_1_df = train_1_df[train_1_df['CityID'].notna()]
train_1_df = train_1_df[train_1_df['SMode'].notna()]
train_1_df = train_1_df[train_1_df['IEVersionID'].notna()]
train_1_df = train_1_df[train_1_df['ProcessorCoreCount'].notna()]
train_1_df = train_1_df[train_1_df['PrimaryDisplayDiagonalInches'].notna()]
train_1_df = train_1_df[train_1_df['FirewallEnabled'].notna()]
train_1_df = train_1_df[train_1_df['TotalPhysicalRAMMB'].notna()]
train_1_df = train_1_df[train_1_df['EnableLUA'].notna()]
train_1_df = train_1_df[train_1_df['OEMModelID'].notna()]
train_1_df = train_1_df[train_1_df['InternalBatteryNumberOfCharges'].notna()]
train_1_df = train_1_df[train_1_df['IsGamer'].notna()]
train_1_df = train_1_df[train_1_df['OSInstallLanguageID'].notna()]
train_1_df = train_1_df[train_1_df['IsFlightsDisabled'].notna()]
train_1_df = train_1_df[train_1_df['FirmwareManufacturerID'].notna()]
train_1_df = train_1_df[train_1_df['IsVirtualDevice'].notna()]
X_train = train_1_df.drop(columns = ['target'])
Y_train = train_1_df['target']
x_train, x_test, y_train, y_test = train_test_split(X_train, Y_train,
test_size=0.3)
train_1_df.isna().sum()
#Create the model
from [Link] import RandomForestClassifier
model = RandomForestClassifier()
[Link](X_train, Y_train)
prediction = [Link](x_test)
from [Link] import classification_report, confusion_matrix, accuracy_score
print(classification_report(y_test,prediction))
print(confusion_matrix(y_test,prediction))
test_df = pd.read_csv('/kaggle/input/computer-virus-predictor/[Link]')
x_test = test_df.drop(columns = ['MachineID','ProductName','EngineVersion',
'AppVersion','SignatureVersion', 'IsBetaUser', 'PlatformType','Processor',
'OSVersion','OsPlatformSubRelease','OSBuildLab',
'SKUEditionName','MDC2FormFactor','DeviceFamily','PrimaryDiskType','ChassisType','P
owerPlatformRole','NumericOSVersion','OSArchitecture','OSBranch','OSEdition','OSSku
FriendlyName','OSInstallType','AutoUpdateOptionsName','OSGenuineState','LicenseActi
vationChannel','FlightRing','DateAS','DateOS'])
x_test["id"] = x_test.index
x_test = x_test[x_test['RealTimeProtectionState'].notna()]
x_test = x_test[x_test['AntivirusConfigID'].notna()]
x_test = x_test[x_test['CityID'].notna()]
x_test = x_test[x_test['SMode'].notna()]
x_test = x_test[x_test['IEVersionID'].notna()]
x_test = x_test[x_test['ProcessorCoreCount'].notna()]
x_test = x_test[x_test['PrimaryDisplayDiagonalInches'].notna()]
x_test = x_test[x_test['FirewallEnabled'].notna()]
x_test = x_test[x_test['TotalPhysicalRAMMB'].notna()]
x_test = x_test[x_test['EnableLUA'].notna()]
x_test = x_test[x_test['OEMModelID'].notna()]
x_test = x_test[x_test['InternalBatteryNumberOfCharges'].notna()]
x_test = x_test[x_test['IsGamer'].notna()]
x_test = x_test[x_test['OSInstallLanguageID'].notna()]
x_test = x_test[x_test['IsFlightsDisabled'].notna()]
x_test = x_test[x_test['FirmwareManufacturerID'].notna()]
x_test = x_test[x_test['IsVirtualDevice'].notna()]
prediction = [Link](x_test)
final_prediction = [Link]({'id': x_test.id, 'target': prediction})
final_prediction.to_csv('[Link]', index=False)