Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Data Normalization with PDL

by lin0 (Curate)
on Jul 07, 2007 at 16:22 UTC ( #625425=note: print w/replies, xml ) Need Help??


in reply to Data Normalization with PDL

One typical practice is to use the code above to normalize the training data and to use the resulting mean and standard deviation to normalize the testing data as illustrated in the snippet below:

#!/usr/bin/perl use warnings; use strict; use PDL; use PDL::NiceSlice; # ================================ # normalize_testing_patterns # $output_data = # $normalized_testing_patterns( $input_data, # $mean_of_input, # $stdev_of_input) ) # # processess $input_data so that $output_data # has 0 mean and 1 stdev # # $output_data = ( $input_data - $mean_of_input ) / $stdev_of_input # ================================ sub normalize_testing_patterns { my ( $input_data, $mean, $stdev ) = @_; my ( $number_of_dimensions, $number_of_patterns ) = $input_data->dims(); my $output_data = ( $input_data - $mean->dummy(1, $number_of_patterns) ) / $stdev->dummy(1, $number_of_patterns); return $output_data; }

Cheers,

lin0

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://625425]
help
Chatterbox?
Jar. Jar!...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (15)
As of 2017-11-21 16:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (304 votes). Check out past polls.

    Notices?