►
From YouTube: How to Retrain Your ML.NET Model
Description
This video shows how to use your previously saved model to retrain a new model with new data.
Code - https://github.com/jwood803/MLNetExamples/blob/master/MLNetExamples/RetrainModel/Program.cs
ML.NET Playlist - https://www.youtube.com/watch?v=8gVhJKszzzI&list=PLl_upHIj19Zy3o09oICOutbNfXj332czx
Contact:
Twitter: https://twitter.com/JWood/
Blog: https://jonwood.co/
Gear used (affiliate links):
Mic - https://amzn.to/2YEXtxI
Mouse - https://amzn.to/2ZtASoQ
A
Hey
everyone,
so
sometimes
if
your
model
gets
hit
with
a
lot
of
data
every
day,
it
can
eventually
become
stale,
that
is,
it
can
start
to
not
generalize
well
to
the
new
data
and
give
much
worse
performance
than
it
used
to
you
when
the
model
was
first
put
into
production.
Now
you
can
take
the
new
data
and
merge
it
with
the
old
data
that
you
use
to
train
the
original
model
with.
However,
instead
of
starting
from
scratch,
you
can
actually
take
the
model.
A
You
already
have
and
retrain
it
with
the
new
data
and
in
London
it
has
the
ability
to
retrain
models
and
that's
what
I'll
show
how
to
do
in
this
video
but
first
to
get
started.
I'm
in
MO,
dotnet,
documentation
for
retraining
a
model
and
I
just
want
to
highlight
that
only
these
trainers
are
the
ones
that
you
can
currently
be
able
to
retrain
with.
A
I
create
a
pipeline,
that's
strictly
just
the
data
preparation
that
would
create
my
transforms
and
then
I
fit
on
the
data
of
with
that
and
then
I
create
another
small
pipeline.
Here.
That's
just
that
the
training
that
we're
going
to
use
and
I'm
gonna
using
the
Poisson
regression.
And
if
you
look
back
at
this
documentation,
you
see
that
the
Poisson
regression
is
someone
that
is
able
to
be
retrained
and
emerge.
The
data
preparation
pipelines
with
the
trainer
pipelines
to
get
my
full
pipeline
here
then
use
that
to
create
my
own
model.
A
Alright,
so
I'm
here
in
Visual,
Studio
I
have
a
console
project
loaded
up
here
and
first
thing
is:
first,
that's
down
on
the
latest
version
of
my
net
and
it's
going
to
be
the
1.4
virgin
alright
and
let's
also
get
the
azure
blob
storage
package
right
and
I'm
going
to
create
a
new
folder
just
to
hold
the
models
where
we
download
them.
The
first
thing,
I'm
gonna,
create
here
or
a
couple
of
file
paths
first,
is
going
to
be
flat.
Trainer
and
I
do
a
path
that
combine
to
create
my
my
training
path
here.
A
I'm
gonna
use
the
directory,
get
current
directory
and
they're
gonna
go
back
three
times
and
the
file
directory,
and
that's
when
I'll
go
to
the
models,
folder
that
we
created
and
I'm
gonna
call
it
housing
trainer
that
zip
and
that's
the
same
thing.
We
called
it
in
as
your
Bob
storage
and
I'm
gonna
do
the
same
thing
for
the
pipeline
model,
their
housing
data
and
I'ma
get
a
reference
to
the
model
directory
itself.
That's
gonna,
be
a
path.
Kabam
now
just
take
a
pipeline
file
path
and
I'll
go
up.
A
One
item
all
right:
now:
let's
connect
to
our
storage
account.
You
know:
I
used
a
cloud
storage
account
static
class
on
that
nougat
package.
We
get.
It
will
parse
out
this
connection,
string
that
I've
already
added
here
next
we'll
get
to
client
from
storage
accounts
by
creating
a
cloud,
Bob
client
and
then
we'll
get
a
reference
to
the
container
with
the
client
using
get
container
reference.
The
container
is
models
and
I'm
get
a
reference
to
the
data
prep
model.
A
The
container
I
get
block
blob
reference,
this
housing
data,
Fred,
zip,
I'm
gonna,
do
the
same
thing
for
the
training,
housing,
trainer
and
I'ma
call
it
training
model.
Now,
I
have
those
references
to
the
files
on
my
storage
account
I
can
make
an
if
check
if
the
file
exists
or
the
file
doesn't
exist.
A
I
will
do
the
pipeline
path
first,
and
if
the
directory
that
it's
in
doesn't
exist
through
the
model
directory,
we
would
do
we'll
create
that
directory
and
since
the
file
already
doesn't
exist,
we'll
wait
on
a
data
model
that
download
file
async,
passing
that
pop
of
path
and
we'll
give
it
the
foul
mode
to
create
another
small
error
here,
because
we're
using
a
weight
in
the
method
is
an
async,
so
we
just
put
a
sink
on
it.
Instead,
it's
now
fall
models
fall
mode.
There
we
go
and
we
do
the
same.
A
If
check
here
fell
that
exists.
If
it
doesn't
exist
this
time
it's
going
to
be
on
the
training
file
path,
if
it
doesn't
exist,
will
download
the
training
model
to
follow
training,
file
path
and
you're
still
gonna,
be
tough
fall
mode
like
great
alright,
so
that
should
give
us
our
both
our
our
data
prep
and
our
training
files
from
as
your
storage.
A
Now,
for
the
mo
been
apart,
we
can
start
by
creating
our
context
and
then
we're
actually
going
to
use
the
context
that
model
that
load
methods
to
load
in
our
models
and
we
use
turn
the
file
path.
This
next
parameter
is
an
output
parameter.
So
what
we
can
do,
as
we
saw
it,
was
a
data
view
schema
type,
so
we're
going
create
the
variables
here
for
our
model
schema
and
then
again
for
pipeline
schema.
Then
we
can
get
out
model
schema
and
we
can
do
the
same
thing
with
our
pipeline.
A
We're
gonna,
gonna,
take
our
training
model
and
then
we're
eventually
going
to
call
the
model
property
from
it.
But,
as
you
can
see
here,
we
get
an
error
and
we
don't
get
any
intelligence
that
that
model
property
exists.
So
what
we're
gonna
have
to
do
is
we're.
Gonna
have
to
cast
this
trainer
model
into
an
interface.
There's
gonna
be
a
specific
interface.
It
was
called
a
single
feature,
prediction
transformer
and
this
generic,
and
but
we
can
just
pass
in
and
objects
in
here
and
from
there.
A
We
get
that
model
property,
but
we're
not
done
yet
from
here.
It's
just
another
object
because
we
casted
it
here
and
so
what
we
can
do
is
we
can
cast
that
as
the
poi
song
regression
model
parameters
and
I'm
using
Poisson
regression,
because
if
you
remember,
when
we
created
the
model,
we
used
a
place
on
regression
trainer.
So
that's
why
I'm
using
the
Poisson
regression
model
parameters
here,
and
that
gives
us
our
original
model
parameters
now.
Do
you
need
to
give
it
some
new
data
to
train
on
so
I
got
some
new
data
here?
A
I'll
pull
this
over
and
I'll
make
sure
this
copies
over.
Just
take
a
look
at
it:
real,
quick!
It's
going
to
be
the
same
structure
as
our
original
housing
and
data
set
got
the
same
header,
and
it's
just
about
five
rows
here
of
some
new
data
that
I
want
to
add
to
it
and
then
read
this
I
can
just
go
and
use
the
file,
read
ol
ons
and
pass
in
the
file
name
here.
I
mean
I'll.
Just
use
some
link
magic
to
read
in
the
data
here.
A
First
I'm
gonna
do
is
skip
the
first
lon,
because
if
you
run,
that
first
line
is
the
header.
So
I
don't
need
to
use
that
then
I'll
select
each
line
and
from
each
lon.
How
will
split
on
it
using
a
comma
because
it
was
common
to
Lebanon
and
I'm
gonna
take
each
of
those
while
the
row
isn't
no
or
whitespace
just
so
I
know
when
it
stops.
When
there's
an
empty
line
and
the
data
and
then
I'll
select,
then
I'll
select
each
row.
A
It's
gonna
be
a
new
housing
data,
and
we
don't
have
this
in
here.
So
I
will
create
this
real,
quick
now
just
paste
in
what
we've
had
and
previous
videos.
It
just
defines
what
that
schema
of
the
data
file
is
gonna,
be
based
on
the
headers
they're,
not
paste
in
the
mappings
of
info
file
to
our
properties.
A
Now
using
the
context,
regression,
trainers
and
I'm
going
to
use
that
same
voice
on
regression,
then
I'll
fit
on
it
and
then
in
here
in
previous
times
that
we,
when
you're,
when
you're
first
training
on
the
model
you're
just
going
to
give
it
the
transform
data.
But
remember
when
we
created
our
when
we
got
our
original
model
parameters,
we
can
pass
that
in
that's
kind
of
a
baseline
to
to
follow
in
when
it
fits
on
this
new
data.
A
Let
you
know
that
your
model
has
retrained
is
that
we
can
get
the
weight
diff
the
difference
in
our
model
weights
here
or
the
or
the
parameters
that
we
just
used,
and
we
can
do
that
by
getting
the
original
model
parameters,
get
the
weights
property
on
it
and
it
will
call
the
zip
method
and
what
this
is
going
to
do.
Is
it's
going
to
take
the
weights
collection
here
and
then
I
can
pass
it
in
a
new
collection.
A
So
I'll
passing
the
new
model
parameters
weights
as
well,
and
now
I
have
access
to
both
of
those
at
the
same
time,
and
then
I
can
call
a
method
on
it
and
I'll
use
a
lambda
here.
Yeah
I
can
get
the
original
and
in
the
updated
values.
So
the
original
is
going
to
values,
and
here
the
original
model
parameter
weights.
A
Now
do
a
for
loop
within
the
white
divs
that
count
from
here
to
another
console
right
long
and
so
the
original
model
parameters
that
weights
and
the
index
tab
over
there's
a
new
model
parameters
weights
at
that
index,
tab
over
then
I
do
the
Boyd
ifs
and
that
index
and
to
make
sure
the
console
stays
up.
I'll
do
a
read
on
on
it.
Alright,
so
let's
run
this
and
see
how
well
this
model
retrained,
all
right
like
we
have
an
area
here,
specify
container
does
not
exist.
A
So,
let's
see
no,
it
helps
if
we
spill
a
container
correctly
here.
Let's
try
this
again
alright,
so
we
have
our.
We
have
our
parameters,
then
our
retrained
ones-
and
we
have
a
difference
here.
It's
nothing
not
much
of
a
difference,
but
then
again
we
only
have
five
new
rows
of
data
that
we
added
to
it
so
I'm
sure
the
more
new
data
that
you
give
it
the
more
difference,
you'll
probably
see
here.
Alright
I'll
leave
things
here,
taste
watching
hope
you
got
a
little
bit
out
of
this
and
I'll
see
y'all
next
time.
Thanks.