Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
9b16325d
Commit
9b16325d
authored
Feb 22, 2014
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed more grammar
parent
114f677d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
max_cost_assignment.py
python_examples/max_cost_assignment.py
+2
-2
sequence_segmenter.py
python_examples/sequence_segmenter.py
+3
-3
svm_rank.py
python_examples/svm_rank.py
+2
-2
No files found.
python_examples/max_cost_assignment.py
View file @
9b16325d
...
...
@@ -17,14 +17,14 @@
import
dlib
# Lets imagine you need to assign N people to N jobs. Additionally, each person will make
# Let
'
s imagine you need to assign N people to N jobs. Additionally, each person will make
# your company a certain amount of money at each job, but each person has different skills
# so they are better at some jobs and worse at others. You would like to find the best way
# to assign people to these jobs. In particular, you would like to maximize the amount of
# money the group makes as a whole. This is an example of an assignment problem and is
# what is solved by the dlib.max_cost_assignment() routine.
# So in this example, lets imagine we have 3 people and 3 jobs. We represent the amount of
# So in this example, let
'
s imagine we have 3 people and 3 jobs. We represent the amount of
# money each person will produce at each job with a cost matrix. Each row corresponds to a
# person and each column corresponds to a job. So for example, below we are saying that
# person 0 will make $1 at job 0, $2 at job 1, and $6 at job 2.
...
...
python_examples/sequence_segmenter.py
View file @
9b16325d
...
...
@@ -78,7 +78,7 @@ def print_segment(sentence, names):
# Now lets make some training data. Each example is a sentence as well as a set of ranges
# Now let
'
s make some training data. Each example is a sentence as well as a set of ranges
# which indicate the locations of any names.
names
=
dlib
.
ranges
()
# make an array of dlib.range objects.
segments
=
dlib
.
rangess
()
# make an array of arrays of dlib.range objects.
...
...
@@ -159,13 +159,13 @@ params.C = 10
model
=
dlib
.
train_sequence_segmenter
(
training_sequences
,
segments
,
params
)
# Lets print out the things the model thinks are names. The output is a set of ranges
# Let
'
s print out the things the model thinks are names. The output is a set of ranges
# which are predicted to contain names. If you run this example program you will see that
# it gets them all correct.
for
i
in
range
(
len
(
sentences
)):
print_segment
(
sentences
[
i
],
model
(
training_sequences
[
i
]))
# Lets also try segmenting a new sentence. This will print out "Bob Bucket". Note that we
# Let
'
s also try segmenting a new sentence. This will print out "Bob Bucket". Note that we
# need to remember to use the same vector representation as we used during training.
test_sentence
=
"There once was a man from Nantucket whose name rhymed with Bob Bucket"
if
use_sparse_vects
:
...
...
python_examples/svm_rank.py
View file @
9b16325d
...
...
@@ -25,7 +25,7 @@
import
dlib
# Now let
s make some testing data. To make it really simple, let
s suppose that
# Now let
's make some testing data. To make it really simple, let'
s suppose that
# we are ranking 2D vectors and that vectors with positive values in the first
# dimension should rank higher than other vectors. So what we do is make
# examples of relevant (i.e. high ranking) and non-relevant (i.e. low ranking)
...
...
@@ -47,7 +47,7 @@ trainer = dlib.svm_rank_trainer()
# selecting a "simpler" solution which might generalize better.
trainer
.
c
=
10
# So lets do the training.
# So let
'
s do the training.
rank
=
trainer
.
train
(
data
)
# Now if you call rank on a vector it will output a ranking score. In
...
...
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