Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
AAGGY
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
23-153
AAGGY
Commits
36dbc539
Commit
36dbc539
authored
Nov 03, 2023
by
Sajana_it20194130
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
356a0da0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
untitled4.py
untitled4.py
+41
-0
No files found.
untitled4.py
0 → 100644
View file @
36dbc539
import
re
import
numpy
as
np
from
sklearn.preprocessing
import
StandardScaler
import
joblib
# Function to extract features
def
extract_features
(
url
):
url_length
=
len
(
url
)
special_chars
=
len
(
re
.
findall
(
r'[!@#$
%
^&*(),.?":{}|<>]'
,
url
))
return
[
url_length
,
special_chars
]
# Load the best-trained text and engineered feature classifiers
best_text_classifier
=
joblib
.
load
(
'best_text_classifier.joblib'
)
best_engineered_classifier
=
joblib
.
load
(
'best_engineered_classifier.joblib'
)
# Create a StandardScaler instance and fit it to a placeholder example
scaler
=
StandardScaler
()
# Placeholder example (replace with actual training data if available)
placeholder_example
=
np
.
array
([[
100
,
5
],
[
120
,
8
],
[
90
,
3
]])
# Fit the scaler to the placeholder example
scaler
.
fit
(
placeholder_example
)
# Input URL from the console
new_url
=
input
(
"Enter the URL to predict: "
)
# Feature extraction for the new URL
new_text_features
=
extract_features
(
new_url
)
# Standardize the new features using the fitted scaler
new_text_features
=
scaler
.
transform
([
new_text_features
])
# Make predictions using the text-based classifier
text_prediction
=
best_text_classifier
.
predict
([
new_url
])
# Make predictions using the engineered feature-based classifier
engineered_prediction
=
best_engineered_classifier
.
predict
(
new_text_features
)
# Print predictions
print
(
"Text-Based Prediction:"
,
text_prediction
[
0
])
print
(
"Engineered Feature-Based Prediction:"
,
engineered_prediction
[
0
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment