It's not really inheritance that's lost, it's the actual module code.
You should be able to solve this by just adding a 'use
Algorithm::NaiveBayes::Model::Frequency;' to the second script.
Or if you don't want to hard-code that, you can do:
$nb = AI::Categorizer::Learner::NaiveBayes->restore_state('filename');
eval( 'use ' . ref($nb) );
To solve this correctly, I think I'd have to add this to the
restore_state() method in the NaiveBayes learner class.
-Ken
On Aug 31, 2004, at 6:12 AM, PerlDiscuss - Perl Newsgroups and mailing
I'm doing some constrained optimization experiments that can take
several days, even a week, to run in the background, but I have a
computer (Mac OS X 10.4.8) that is shared, and I need to install
software and restart it almost daily.
I would like to save the entire thing about every hour, but I can
handle the timing part myself.
Sincerely,
Gregg Allen
Cerebra, Inc.
Cheers,
Brad Larsen
If you throw something like this into the bottom of one of your perl
files, you should be able just to call
$gen->store_state('filename') and then $gen->restore_state
('filename') (where $gen is an instance of AI::Genetic)
package AI::Genetic;
use strict;
use Storable;
use File::Spec ();
use File::Path ();
sub save_state {
my ($self, $path) = @_;
if (-e $path) {
File::Path::rmtree($path) or die "Couldn't overwrite $path: $!";
}
mkdir($path, 0777) or die "Can't create $path: $!";
Storable::nstore($self, File::Spec->catfile($path, 'self'));
}
sub restore_state {
my ($package, $path) = @_;
return Storable::retrieve(File::Spec->catfile($path, 'self'));
}
1;
Ben
> I don't actually have any experience with
> AI::Genetic, but
> Storable.pm is probably your best bet. Take a look
> at how
> AI::Categorizer interfaces with it:
>
http://search.cpan.org/src/KWILLIAMS/AI-Categorizer-0.07/lib/AI/
>
> Categorizer/Storable.pm
>
> If you throw something like this into the bottom of
> one of your perl
> files, you should be able just to call
> $gen->store_state('filename') and then
> $gen->restore_state
> ('filename') (where $gen is an instance of
> AI::Genetic)
[snip code]
Thanks. That's an excellent suggestion. I'll add that
to AI::Genetic and upload a new version soon.
Thanks,
--Ala
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
Thanks for creating that module, in the first place, also. When I
first discovered the module about a year ago, I ran about a dozen
random optimization problems from my graduate level operations
research textbook from 25 years ago.
I didn't find a single one it couldn't solve in less than a few
minutes. (Mere seconds in most cases.)
Thanks!
Gregg Allen
Cerebra, Inc.