view release on metacpan or search on metacpan
lib/Acme/Urinal.pm view on Meta::CPAN
use Acme::Urinal;
my $urinals = Acme::Urinal->new(8);
say $urinal->pick_one; # prints 1
say $urinal->pick_one; # prints 3
say $urinal->pick_one; # prints 5
say $urinal->pick_one; # prints 7
say $urinal->pick_one; # prints 2
say $urinal->pick_one; # prints 4
say $urinal->pick_one; # prints 6
say $urinal->pick_one; # prints 0
say $urinal->pick_one; # prints nothing, triggers an uninit warning
$urinal->leave(3);
$urinal->leave(4);
say $urinal->pick_one; # prints 4
$urinal->leave(2);
$urinal->leave(1);
say $urinal->pick_one; # prints 1
=head1 DESCRIPTION
When men use a bathroom with multiple urinals. The way the urinal to use is
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Acme/W.pm view on Meta::CPAN
s/([^\$\w\d])vec([^\w\d])/$1WwwWW$2/g;
s/([^\$\w\d])use([^\w\d])/$1WwwWw$2/g;
s/([^\$\w\d])tie([^\w\d])/$1WwwwW$2/g;
s/([^\$\w\d])sub([^\w\d])/$1Wwwww$2/g;
s/([^\$\w\d])sin([^\w\d])/$1wWWWW$2/g;
s/([^\$\w\d])say([^\w\d])/$1wWWWw$2/g;
s/([^\$\w\d])ref([^\w\d])/$1wWWwW$2/g;
s/([^\$\w\d])pos([^\w\d])/$1wWWww$2/g;
s/([^\$\w\d])pop([^\w\d])/$1wWwWW$2/g;
s/([^\$\w\d])our([^\w\d])/$1wWwWw$2/g;
s/([^\$\w\d])ord([^\w\d])/$1wWwwW$2/g;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Acme/Want5000trillion.pm view on Meta::CPAN
=head1 SYNOPSIS
use Acme::Want5000trillion;
my $want = Acme::Want5000trillion->new;
print $want->say(); #5000å
忬²ãã!
print $want->say('en'); #I want 5000 trillion yen!
print $want->say('aa'); # print AA
=head1 DESCRIPTION
Acme::Want5000trillion is Japanese twitter famous words.
I want 5000 trillion yen.
view all matches for this distribution
view release on metacpan or search on metacpan
examples/weather.pl view on Meta::CPAN
return "$temperature $unit";
}
local $^F = 1;
my $temperature=what? (i mean outside);
say "The temperature is $temperature";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Acme/YAPC/Okinawa/Bus.pm view on Meta::CPAN
Acme::YAPC::Okinawa::Bus - It's Tweet shere
=head1 SYNOPSIS
use Acme::YAPC::Okinawa::Bus;
say Acme::YAPC::Okinawa::Bus::time();
say Acme::YAPC::Okinawa::Bus::place();
=head1 DESCRIPTION
Acme::YAPC::Okinawa::Bus is YAPC::Okinawa bus time.
view all matches for this distribution
view release on metacpan or search on metacpan
Acme::use::strict::with::pride version 0.04
===========================================
Enforce bondage and discipline on very naughty modules.
Some people say that use strict is gay;
Others think that it's cool.
This module lets you use strict with pride.
INSTALLATION
view all matches for this distribution
view release on metacpan or search on metacpan
examples/Class.pl view on Meta::CPAN
my $class = Acpi::Class->new;
my $classes = $class->g_classes;
my $number = @$classes;
say "In your system there is/are $number classes";
foreach (@$classes) { print " $_";}
print "\n";
say "-" x 50 . "\n The devices in class thermal are:";
$class->class('thermal');
my $elements = $class->g_devices;
foreach (@$elements) { print "$_ "; }
print "\n";
# All values of the devices in the class 'thermal'
$class->class('thermal');
say "-" x 50 ;
$class->p_class_values;
# All values of the device 'cooling_device0'
$class->device('cooling_device0');
say "-" x 50 ;
$class->p_device_values;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Acrux/DBI.pm view on Meta::CPAN
my $tx = $dbi->transaction;
$dbi->query( ... );
$dbi->query( ... );
$tx->commit;
};
say $@ if $@;
=head2 url
my $url = $dbi->url;
$dbi = $dbi->url('sqlite:///tmp/test.db?sqlite_unicode=1');
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Acrux/Config.pm view on Meta::CPAN
use Acrux::Config;
my $config = Acrux::Config->new(
file => '/etc/myapp.conf',
);
say $config->get('foo');
=head1 DESCRIPTION
The module works with the configuration using L<Config::General>
lib/Acrux/Config.pm view on Meta::CPAN
Returns error string if occurred any errors while creating the object or reading the configuration file
=head2 first
say $config->first('/foo'); # ['first', 'second', 'third']
# first
Returns an first value of found values from configuration
=head2 get
say $config->get('/datadir');
Returns configuration value by path
=head2 hash, object
lib/Acrux/Config.pm view on Meta::CPAN
Returns an hash of found values from configuration
=head2 latest
say $config->latest('/foo'); # ['first', 'second', 'third']
# third
Returns an latest value of found values from configuration
=head2 load
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Action/Retry.pm view on Meta::CPAN
strategy => { Fibonacci => { multiplicator => 2000,
initial_term_index => 3,
max_retries_number => 5,
}
},
on_failure_code => sub { say "Given up retrying" },
);
$action->run();
# functional way
retry { ...}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Activator/DB.pm view on Meta::CPAN
=head1 USAGE
This module can be used either pseudo-OO or static on multiple
databases. I say pseudo-OO, because you don't call new: this module
auto-vivicates a singleton object whenever you connect for the first
time.
=over
view all matches for this distribution
view release on metacpan or search on metacpan
lib/ActiveRecord/Simple.pm view on Meta::CPAN
$code_string .= "return \$_[0]->{$method_name};\n }\n";
}
eval "package $class;\n $code_string" if $code_string;
say $@ if $@;
}
sub _guess {
my ($what_key, $class) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
ex/ai-bot.pl view on Meta::CPAN
my ($self) = @_;
my $server = MCP::Server->new(name => 'bert-tools', version => '1.0');
$server->tool(
name => 'stay_silent',
description => 'Choose not to respond to the current messages. Use this when the conversation does not involve you, is not interesting, or nobody is talking to you. It is perfectly fine to say nothing.',
input_schema => {
type => 'object',
properties => {
reason => { type => 'string', description => 'Brief internal reason for staying silent (not shown to anyone)' },
},
ex/ai-bot.pl view on Meta::CPAN
HOW TO RESPOND (when you actually should):
- Write plain text. Your messages appear in the channel as-is.
- To address someone, write their nick followed by a colon: Getty: hey there
- Input uses <nick> format but your output is always plain text with nick: format.
- You can address different people on different lines.
- Or say something to the whole channel without any prefix.
- Each newline becomes a separate IRC message with a small delay between them.
- Keep it SHORT. One or two lines is usually enough. This is chat, not a blog.
- NEVER narrate your tool usage in the chat. Tools work silently in the background.
Don't write things like "*save_note: ...*" or "Let me look that up..." â just do it.
ex/ai-bot.pl view on Meta::CPAN
my $idle_mins = int($idle_secs / 60);
$self->info("Idle ping after ${idle_mins}m");
# Ping first channel only (idle is a global concept)
my $channel = $self->_default_channel;
$self->_buffer_message($channel, 'system',
"No activity for $idle_mins minutes. You can say something if you want, or stay_silent.");
}
POE::Kernel->delay( _idle_check => $IDLE_PING );
};
event irc_public => sub {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Adapter/Async/OrderedList.pm view on Meta::CPAN
=over 4
=item * count - resolves with the number of items. If this isn't possible, an estimate may be acceptable.
say "items: " . $adapter->count->get
=item * get - accepts a list of indices
$adapter->get(
items => [1,2,3],
view all matches for this distribution
view release on metacpan or search on metacpan
=head2 ado_home
Returns an instance of L<Mojo::Home> pointing to the base directory where
L<Ado> is installed.
~$ ado eval 'say app->ado_home'
/home/berov/opt/public_dev/Ado
=head2 CODENAME
Returns the current C<CODENAME>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Advanced/Config/Date.pm view on Meta::CPAN
(3) DDMMYYYY - European
The I<$order> argument helps deal with ambiguities in the date. Its a comma
separated list of numbers specifying to order to try out. Ex: 3,2,1 means
try out the European date format 1st, then the American date format 2nd, and
finally the ISO format 3rd. You could also just say I<$order> is B<3> and
only accept European dates.
It assumes its using the correct format when the date looks valid. It does this
by validating the B<MM> is between 1 and 12 and that the B<DD> is between 1 and
31. (Using the correct max for that month). And then assumes the year is
lib/Advanced/Config/Date.pm view on Meta::CPAN
(3) DDMMYY - European
The I<$order> argument helps deal with ambiguities in the date. Its a comma
separated list of numbers specifying to order to try out. Ex: 2,3,1 means
try out the American date format 1st, then the European date format 2nd, and
finally the ISO format 3rd. You could also just say I<$order> is B<2> and
only accept European dates.
So if you use the wrong order, more than likely you'll get the wrong date!
It assumes its using the correct format when the date looks valid. It does this
view all matches for this distribution
view release on metacpan or search on metacpan
builder/Affix/Builder.pm view on Meta::CPAN
exit $method->($self);
}
method Build_PL() {
die "Pure perl Affix? Ha! You wish.\n" if $pureperl;
say sprintf 'Creating new Build script for %s %s', $meta->name, $meta->version;
$self->write_file( 'Build', sprintf <<'', $^X, __PACKAGE__, __PACKAGE__ );
#!%s
use lib 'builder';
use %s;
%s->new( @ARGV && $ARGV[0] =~ /\A\w+\z/ ? ( action => shift @ARGV ) : (),
view all matches for this distribution
view release on metacpan or search on metacpan
examples/dcalc.pl view on Meta::CPAN
# first, set up the arguments:
my (%args, %hosts);
while (my $arg = shift @ARGV) {
if ($arg =~ /.+\:\d+/) {
# safe to say it's an ip address
if ($args{Return}) { $hosts{$arg} = ''; }
else { $args{Return} = $arg; }
} elsif ($arg =~ /-v/i) {
$args{'verbose'} = 1;
} elsif ($arg =~ /-t/i) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Aion/Fs.pm view on Meta::CPAN
=item * L<File::Wildcard::Find> â C<findbegin($dir); push @paths, $f while $f = findnext()> or C<findbegin($dir); @paths = findall()>.
=item * L<File::Util> â C<< File::Util-E<gt>new-E<gt>list_dir($dir, qw/ --pattern=\.txt$ --files-only --recurse /) >>.
=item * L<Mojo::File> â C<< say for path($path)-E<gt>list_tree({hidden =E<gt> 1, dir =E<gt> 1})-E<gt>each >>.
=item * L<Path::Find> â C<@paths = path_find( $dir, "*.png" )>. For complex queries, use I<matchable>: C<< my $sub = matchable( sub { my( $entry, $directory, $fullname, $depth ) = @_; $depth E<lt>= 3 } >>.
=item * L<Path::Extended::Dir> â C<< @paths = Path::Extended::Dir-E<gt>new($dir)-E<gt>find('*.txt') >>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Akado/Account.pm view on Meta::CPAN
=head2 get_balance
It will return number. The number is the sum of money that is left on the
user account. The currencty is RUB (Russian rouble).
say $aa->get_balance(); # will print '749.82', or something like this
If the object hasn't accessed the Akado account site
L<https://office.akado.ru/> since the object was created, the method will
access site, get data from it and store it in the object. The object will
access Akado site only once, after saving data in the object all methods use
lib/Akado/Account.pm view on Meta::CPAN
=head2 get_next_month_payment
It will return number. The number is the sum of money that the user will have
to pay for the next month. The currencty is RUB (Russian rouble).
say $aa->get_next_month_payment();
If the object hasn't accessed the Akado account site
L<https://office.akado.ru/> since the object was created, the method will
access site, get data from it and store it in the object. The object will
access Akado site only once, after saving data in the object all methods use
view all matches for this distribution
view release on metacpan or search on metacpan
bin/analogize.pl view on Meta::CPAN
training_set => $train,
# print the result of each classification at the time it is provided
end_test_hook => sub {
my ($batch, $test_item, $result) = @_;
++$count if $result->result eq 'correct';
say $test_item->comment . ":\t" . $result->result . "\n";
for (@print_methods) {
if($_ eq 'gang_detailed'){
say ${ $result->gang_summary(1) };
}else{
say ${ $result->$_ };
}
}
}
);
$batch->classify_all($test);
say "$count out of " . $test->size . " correct";
return;
}
sub _validate_args {
my %args = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/AdaBoost.pm view on Meta::CPAN
$learner->train(num_iterations => 1_000);
# Now you have a boost-ed classifier (Algorithm::AdaBoost::Classifier).
my $classifier = $learner->final_classifier;
given ($classifier->classify([...])) {
when ($_ > 0) { say 'The data belongs to class 1.' }
when ($_ < 0) { say 'The data belongs to class 2.' }
default { warn 'The data cannot be classified.' }
}
=head1 DESCRIPTION
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/BIT/XS.pm view on Meta::CPAN
use Algorithm::BIT::XS;
my $bit = Algorithm::BIT::XS->new(100);
$bit->update(1, 5); # bit[1] += 5
$bit->update(3, 6); # bit[3] += 6
say 'bit[1..2] == ', $bit->query(2); # 5
say 'bit[1..3] == ', $bit->query(3); # 11
say 'bit[1..20] == ', $bit->query(20); # 11
$bit->update(3, 10); # bit[3] += 10
say 'bit[1..3] == ', $bit->query(3); # 21
say 'bit[3] == ', $bit->get(3); # 16
$bit->set(3, 10); # bit[3] = 10
say 'bit[3] == ', $bit->get(3); # 10
$bit->clear;
say 'bit[1..100] == ', $bit->query(100); # 0
$bit->set(100, 5);
say 'bit[1..100] == ', $bit->query(100); # 5
=head1 DESCRIPTION
A binary indexed tree is a data structure similar to an array of integers.
The two main operations are updating an element and calculating a
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/BitVector.pm view on Meta::CPAN
=head3 divide_into_two()
=over 4
($bv1, $bv2) = $bv->divide_into_two(); # say $bv = 0000000000101101
print "$bv1\n"; # 00000000
print "$bv2\n"; # 00101101
Divides an even sized bitvector into two bitvectors, each of size half of the
bitvector on which this method is invoked. Throws an exception when invoked on a
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Bitonic/Sort.pm view on Meta::CPAN
=cut
sub bitonic_sort {
my $up = shift;
say '#### Sort: '.Dumper(@_) if DEBUG;
return @_ if int @_ <= 1;
my $single_bit = shift @_ if @_ % 2;
$single_bit //= 'NA';
say Dumper $single_bit if DEBUG;
my @num = @_;
my @first = bitonic_sort( 1, @num[0..(@num /2 -1)] );
my @second = bitonic_sort( 0, @num[(@num /2)..(@num -1)] );
return _bitonic_merge( $up, $single_bit, @first, @second );
}
sub _bitonic_merge {
my $up = shift;
say '#### Merge: '.Dumper(@_) if DEBUG;
my $single_bit = shift;
say Dumper $single_bit if DEBUG;
# assume input @num is bitonic, and sorted list is returned
return @_ if int @_ == 1;
my $single_bit_2 = shift @_ if @_ % 2;
lib/Algorithm/Bitonic/Sort.pm view on Meta::CPAN
@num = (@first, @second);
@num = _some_sorting_algorithm( $up, $single_bit, @first, @second ) if $single_bit ne 'NA';
@num = _some_sorting_algorithm( $up, $single_bit_2, @first, @second ) if $single_bit_2 ne 'NA';
say "#####\n# Merge Result\n#####\n".Dumper(@num) if DEBUG;
return (@num);
}
sub _bitonic_compare {
my $up = shift;
say '#### Compare: '.Dumper(@_) if DEBUG;
my @num = @_;
my $dist = int @num /2;
#~
for my $i (0..$dist-1) {
say "i=$i, dist=$dist, $num[$i] > $num[$i+$dist]) == $up" if DEBUG;
if ( ($num[$i] > $num[$i+$dist]) == $up ) {
say "Swapping....." if DEBUG;
($num[$i], $num[$i+$dist]) = ($num[$i+$dist], $num[$i]); #swap
}
}
#~ for my $i (0..(int @$first)) {
#~ if ( ($first->[$i] > $second->[$i]) == $up ) {
#~ ($first->[$i], $second->[$i]) = ($second->[$i], $first->[$i]); #swap
#~ }
#~ }
say 'Compared result:'.Dumper(@num) if DEBUG;
return @num;
#~ return ($first, $second);
}
lib/Algorithm/Bitonic/Sort.pm view on Meta::CPAN
my $up = shift;
my $single_bit = shift;
my @num = @_;
my @num_new;
say "_SOME_SORTING_ALGORITHM: INPUT: ".Dumper(@num) if DEBUG;
while (my $curr = shift @num) {
say "_SOME_SORTING_ALGORITHM: for: ".Dumper($curr, $single_bit, @num) if DEBUG;
if ($up and $single_bit < $curr) {
push @num_new, $single_bit;
push @num_new, $curr;
say "Return earlier, up is ".($up or '0').':'.Dumper(@num_new, @num) if DEBUG;
return (@num_new, @num);
} elsif ($single_bit > $curr and not $up) {
push @num_new, $single_bit;
push @num_new, $curr;
say "Return earlier, up is ".($up or '0').':'.Dumper(@num_new, @num) if DEBUG;
return (@num_new, @num)
} else {
push @num_new, $curr;
}
}
push @num_new, $single_bit;
say "Return normal, ".Dumper(@num_new, @num) if DEBUG;
return @num_new;
}
=head1 AUTHOR
view all matches for this distribution
view release on metacpan or search on metacpan
t/test.data view on Meta::CPAN
`` `` O
If IN O
you PRP B
could MD O
say VB O
their PRP$ B
business NN I
in IN O
the DT B
U.S. NNP I
t/test.data view on Meta::CPAN
, , O
friends NNS B
from IN O
the DT B
period NN I
say VBP O
. . O
`` `` O
He PRP B
had VBD O
t/test.data view on Meta::CPAN
or CC I
1967 CD I
, , O
intelligence NN B
officials NNS I
say VBP O
. . O
His PRP$ B
commanding NN I
officer NN I
t/test.data view on Meta::CPAN
Jewelers NNP I
Inc. NNP I
to TO O
management NN B
, , O
say VBP O
executives NNS B
familiar JJ O
with IN O
the DT B
talks NNS I
t/test.data view on Meta::CPAN
chain NN I
following VBG O
the DT B
buy-out NN I
, , O
say VBP O
those DT B
familiar NN O
with IN O
the DT B
situation NN I
t/test.data view on Meta::CPAN
Instead RB O
, , O
network NN B
officials NNS I
say VBP O
, , O
it PRP B
may MD O
`` `` O
counterprogram VB O
t/test.data view on Meta::CPAN
and CC O
Capital NNP B
Cities\/ABC NNP I
Inc. NNP I
, , O
say VBP O
there EX B
are VBP O
no DT B
plans NNS I
to TO O
t/test.data view on Meta::CPAN
'' '' O
I PRP B
did VBD O
n't RB O
say VB O
this DT B
, , O
and CC O
I PRP B
'm VBP O
t/test.data view on Meta::CPAN
the DT B
hearings NNS I
, , O
except VB O
to TO O
say VB O
, , O
`` `` O
We PRP B
will MD O
be VB O
t/test.data view on Meta::CPAN
nine CD B
; : O
No DT B
wonder NN I
I PRP I
say VBP O
, , O
`` `` O
I PRP B
drink VBP O
to TO O
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/DBSCAN.pm view on Meta::CPAN
my $i = 0;
unshift(@{$self->{id_list}}, $starting_point_id) if (defined $starting_point_id);
foreach my $id (@{$self->{id_list}}) {
my $point = $self->{dataset}->{$id};
say "$i";
$i++;
next if ($point->{visited});
$point->{visited} = 1;
$self->_one_more_point_visited();
my $neighborPts = $self->GetRegion($point);
#say Dumper($neighborPts);
if (scalar(@$neighborPts) < $self->{min_points}) {
$point->{cluster_id} = -1;
}
else {
lib/Algorithm/DBSCAN.pm view on Meta::CPAN
my $neighborPtsOfClusterMember = $self->GetRegion($p);
if (scalar(@$neighborPtsOfClusterMember) >= $self->{min_points}) {
map { $cluster_points{$_}++ } @$neighborPtsOfClusterMember;
say "Cluster [$self->{current_cluster}] has now [".scalar(keys %cluster_points)."] members, added region of point:[$p->{point_id}]";
$cluster_expanded = 1;
last;
}
}
lib/Algorithm/DBSCAN.pm view on Meta::CPAN
foreach my $point (@{$self->{dataset}}) {
push(@{$clusters{$point->{cluster_id}}}, $point->{point_id});
}
foreach my $cluster_id (sort keys %clusters) {
say "CLUSTER: $cluster_id";
foreach my $point_id (sort @{$clusters{$cluster_id}}) {
my $min_distance = 1000000000000;
my $closest_point_id;
foreach my $distance_point_id (sort @{$clusters{$cluster_id}}) {
if ($distance_point_id ne $point_id) {
lib/Algorithm/DBSCAN.pm view on Meta::CPAN
$closest_point_id = $distance_point_id;
}
}
}
say "\t$point_id : (closest point: $closest_point_id, distance: $min_distance)";
}
}
}
=head2 PrintClustersShort
lib/Algorithm/DBSCAN.pm view on Meta::CPAN
my $point = $self->{dataset}->{$id};
push(@{$clusters{$point->{cluster_id}}}, $point->{point_id});
}
foreach my $cluster_id (sort keys %clusters) {
say "CLUSTER: $cluster_id, [".scalar(@{$clusters{$cluster_id}})."] points";
my $nb = 0;
foreach my $point_id (sort @{$clusters{$cluster_id}}) {
$nb++;
say "\t$point_id";
last if ($nb >= 100);
}
}
}
lib/Algorithm/DBSCAN.pm view on Meta::CPAN
$self->{nb_visited_points}++;
$self->{start_time} = time() unless ($self->{start_time});
my $eta = time() + ((time() - $self->{start_time})/$self->{nb_visited_points})*(500000);
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($eta);
say "ETA:".sprintf("%04d-%02d-%02d %02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$min,$sec);
say "nb visited:".$self->{nb_visited_points};
}
=head1 AUTHOR
Michal TOMA, C<< <mtoma at cpan.org> >>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/DecisionTree.pm view on Meta::CPAN
# Next you construct a decision tree for your training data by calling:
$root_node = $dt->construct_decision_tree_classifier();
# where $root_node is an instance of the DTNode class that is also defined in the
# module file. Now you are ready to classify a new data record. Let's say that
# your data record looks like:
my @test_sample = qw / g2=4.2
grade=2.3
gleason=4
lib/Algorithm/DecisionTree.pm view on Meta::CPAN
If you are new to the concept of a decision tree, their practical utility is best
understood with an example that only involves symbolic features. However, as
mentioned earlier, versions of the module higher than 2.0 allow you to use both
symbolic and numeric features.
Consider the following scenario: Let's say you are running a small investment company
that employs a team of stockbrokers who make buy/sell decisions for the customers of
your company. Assume that your company has asked the traders to make each investment
decision on the basis of the following four criteria:
price_to_earnings_ratio (P_to_E)
lib/Algorithm/DecisionTree.pm view on Meta::CPAN
the C<DecisionTree> we constructed earlier, but on the C<DTNode> instance returned by
the call to C<construct_decision_tree_classifier()>.
=item B<classify($root_node, \@test_sample):>
Let's say you want to classify the following data record:
my @test_sample = qw / g2=4.2
grade=2.3
gleason=4
eet=1.7
lib/Algorithm/DecisionTree.pm view on Meta::CPAN
where, as the name implies, the parameter C<how_many_bags> controls how many bags
(and, therefore, how many decision trees) will be constructed from your training
dataset; and where the parameter C<bag_overlap_fraction> controls the degree of
overlap between the bags. To understand what exactly is achieved by setting the
parameter C<bag_overlap_fraction> to 0.2 in the above example, let's say that the
non-overlapping partitioning of the training data between the bags results in 100
training samples per bag. With bag_overlap_fraction set to 0.2, additional 20 samples
drawn randomly from the other bags will be added to the data in each bag.
=back
lib/Algorithm/DecisionTree.pm view on Meta::CPAN
=item B<prediction_for_single_data_point( $root_node, $test_sample ):>
You call this method after you have constructed a regression tree if you want to
calculate the prediction for one sample. The parameter C<$root_node> is what is
returned by the call C<construct_regression_tree()>. The formatting of the argument
bound to the C<$test_sample> parameter is important. To elaborate, let's say you are
using two variables named C<$xvar1> and C<$xvar2> as your predictor variables. In
this case, the C<$test_sample> parameter will be bound to a list that will look like
['xvar1 = 23.4', 'xvar2 = 12.9']
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Diff/Callback.pm view on Meta::CPAN
use Algorithm::Diff::Callback 'diff_arrays';
diff_arrays(
\@old_family_members,
\@new_family_members,
added => sub { say 'Happy to hear about ', shift },
deleted => sub { say 'Sorry to hear about ', shift },
);
Or using hashes:
use Algorithm::Diff::Callback 'diff_hashes';
diff_hashes(
\%old_details,
\%new_details,
added => sub { say 'Gained ', shift },
deleted => sub { say 'Lost ', shift },
changed => sub {
my ( $key, $before, $after ) = @_;
say "$key changed from $before to $after";
},
);
=head1 DESCRIPTION
lib/Algorithm/Diff/Callback.pm view on Meta::CPAN
diff_arrays(
\@old, \@new,
added => sub {
my $value = shift;
say "$value was added to the array";
}
);
=item * deleted
diff_arrays(
\@old, \@new,
deleted => sub {
my $value = shift;
say "$value was deleted from the array";
}
);
=back
lib/Algorithm/Diff/Callback.pm view on Meta::CPAN
diff_hashes(
\%old, \%new,
added => sub {
my ( $key, $value ) = @_;
say "$key ($value) was added to the hash";
}
);
=item * deleted
diff_hashes(
\%old, \%new,
deleted => sub {
my ( $key, $value ) = @_;
say "$key ($value) was deleted from the hash";
}
);
=item * changed
diff_hashes(
\%old, \%new,
changed => sub {
my ( $key, $before, $after ) = @_;
say "$key in the hash was changed from $before to $after";
}
);
=back
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Test/Builder.pm view on Meta::CPAN
}
sub _is_qr {
my $regex = shift;
# is_regexp() checks for regexes in a robust manner, say if they're
# blessed.
return re::is_regexp($regex) if defined &re::is_regexp;
return ref $regex eq 'Regexp';
}
view all matches for this distribution