Skip to content

Commit

Permalink
Fix WAF notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
fisher85 committed Nov 15, 2020
1 parent a8d0c2d commit 7a4b0db
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions python-waf/machine-learning-waf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The operation may take a long time, 3-5 minutes depending on the computer performance. Uncomment the lines if you don't plan on using a pretrained model (pickle dump)."
"The operation may take a long time, 3-5 minutes depending on the computer performance."
]
},
{
Expand All @@ -159,15 +159,15 @@
"outputs": [],
"source": [
"vectorizer = TfidfVectorizer(min_df = 0.0, analyzer=\"char\", sublinear_tf=True, ngram_range=(1,3)) # converting data to vectors\n",
"# X = vectorizer.fit_transform(queries)\n",
"X = vectorizer.fit_transform(queries)\n",
"\n",
"# X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) # splitting data\n",
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) # splitting data\n",
"\n",
"badCount = len(badQueries)\n",
"validCount = len(validQueries)\n",
"\n",
"lgs = LogisticRegression(solver='lbfgs', class_weight={1: 2 * validCount / badCount, 0: 1.0}) # class_weight='balanced')\n",
"# lgs.fit(X_train, y_train) # training our model"
"lgs.fit(X_train, y_train) # training our model"
]
},
{
Expand Down Expand Up @@ -199,7 +199,7 @@
" ('classifier', lgs)\n",
" ])\n",
"\n",
"# pickle.dump(p, open('trained_waf_model', 'wb'))"
"pickle.dump(p, open('trained_waf_model', 'wb'))"
]
},
{
Expand Down Expand Up @@ -262,7 +262,7 @@
},
"outputs": [],
"source": [
"!wget https://github.com/fisher85/ml-cybersecurity/blob/master/python-waf/trained_waf_model?raw=true -O trained_waf_model\n",
"# !wget https://github.com/fisher85/ml-cybersecurity/blob/master/python-waf/trained_waf_model?raw=true -O trained_waf_model\n",
"p = pickle.load(open('trained_waf_model', 'rb'))"
]
},
Expand Down

0 comments on commit 7a4b0db

Please sign in to comment.