Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scikit-learn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ian Johnson
scikit-learn
Commits
426dc63c
Commit
426dc63c
authored
14 years ago
by
Olivier Grisel
Browse files
Options
Downloads
Patches
Plain Diff
use a SGD model in the mlcomp demo since it is the fastest for this problem
parent
1abd0703
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/mlcomp_sparse_document_classification.py
+7
-7
7 additions, 7 deletions
examples/mlcomp_sparse_document_classification.py
with
7 additions
and
7 deletions
examples/mlcomp_sparse_document_classification.py
+
7
−
7
View file @
426dc63c
...
@@ -46,7 +46,7 @@ import pylab as pl
...
@@ -46,7 +46,7 @@ import pylab as pl
from
scikits.learn.datasets
import
load_mlcomp
from
scikits.learn.datasets
import
load_mlcomp
from
scikits.learn.feature_extraction.text.sparse
import
Vectorizer
from
scikits.learn.feature_extraction.text.sparse
import
Vectorizer
from
scikits.learn.s
vm
.sparse
import
LinearSVC
from
scikits.learn.s
gd
.sparse
import
SGD
from
scikits.learn.metrics
import
confusion_matrix
from
scikits.learn.metrics
import
confusion_matrix
from
scikits.learn.metrics
import
classification_report
from
scikits.learn.metrics
import
classification_report
...
@@ -70,17 +70,17 @@ print "n_samples: %d, n_features: %d" % X_train.shape
...
@@ -70,17 +70,17 @@ print "n_samples: %d, n_features: %d" % X_train.shape
assert
sp
.
issparse
(
X_train
)
assert
sp
.
issparse
(
X_train
)
y_train
=
news_train
.
target
y_train
=
news_train
.
target
print
"
Training a linear
SVM (hinge loss and L2 regulariz
er
)
...
"
print
"
Training a linear
classifi
er...
"
parameters
=
{
parameters
=
{
'
loss
'
:
'
l2
'
,
'
loss
'
:
'
hinge
'
,
'
penalty
'
:
'
l2
'
,
'
penalty
'
:
'
l2
'
,
'
C
'
:
1
0
,
'
n_iter
'
:
5
0
,
'
dual
'
:
False
,
'
alpha
'
:
0.00001
,
'
ep
s
'
:
1e-4
,
'
fit_interc
ep
t
'
:
True
,
}
}
print
"
parameters:
"
,
parameters
print
"
parameters:
"
,
parameters
t0
=
time
()
t0
=
time
()
clf
=
LinearSVC
(
**
parameters
).
fit
(
X_train
,
y_train
)
clf
=
SGD
(
**
parameters
).
fit
(
X_train
,
y_train
)
print
"
done in %fs
"
%
(
time
()
-
t0
)
print
"
done in %fs
"
%
(
time
()
-
t0
)
print
"
Percentage of non zeros coef: %f
"
%
(
np
.
mean
(
clf
.
coef_
!=
0
)
*
100
)
print
"
Percentage of non zeros coef: %f
"
%
(
np
.
mean
(
clf
.
coef_
!=
0
)
*
100
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment