Skip to Content
Machine Learning for Cybersecurity Cookbook
book

Machine Learning for Cybersecurity Cookbook

by Emmanuel Tsukerman
November 2019
Intermediate to advanced content levelIntermediate to advanced
346 pages
9h 36m
English
Packt Publishing
Content preview from Machine Learning for Cybersecurity Cookbook

How to do it…

To localize an entity based on the Wi-Fi signal using machine learning, observe the following steps:

  1. Collect a dataset of Wi-Fi signal strengths from different locations in the area of interest.
  2. Load the data into a data frame using pandas:
import pandas as pddf = pd.read_csv("wifi_localization.txt", sep="\t", header=None)df = df.rename(columns={7: "room"})
  1. Train-test split the data frame:
from sklearn.model_selection import train_test_splitdf_train, df_test = train_test_split(df)
  1. Distribute the features and labels into an array:
y_train = df_train.pop("room").valuesy_test = df_test.pop("room").valuesX_train = df_train.valuesX_test = df_test.values
  1. Instantiate a random forest classifier:
from sklearn.ensemble import ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Machine Learning for Cybersecurity

Hands-On Machine Learning for Cybersecurity

Soma Halder, Sinan Ozdemir
Machine Learning on Kubernetes

Machine Learning on Kubernetes

Faisal Masood, Ross Brigoli

Publisher Resources

ISBN: 9781789614671Supplemental Content