Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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?
[choroba]: Can you steal the code from pm-cb-g?
[Tanktalus]: maybe next week at the earliest. :P
[Tux]: Don't you ♥ Unicode :)
[Tanktalus]: Tux: usually, yes. :P

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2017-09-25 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (291 votes). Check out past polls.

    Notices?