-
-
03 Jan 2020 00:03:56 UTC
- Distribution: MLPerl
- Module version: 0.101000
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (24 / 8 / 3)
- Kwalitee
Bus factor: 1- % Coverage
- License: perl_5
- Perl: v5.10.0
- Activity
24 month- Tools
- Download (1.01MB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- CPAN::Meta
- ExtUtils::MakeMaker
- PPI
- RPerl
- Test::Exception
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
- NAME
- DESCRIPTION
- SYNOPSIS, KNN 2D BRUTE FORCE
- SYNOPSIS, KNN 2D BRUTE FORCE, EXECUTE
- SYNOPSIS, KNN 2D BRUTE FORCE, COMPILE & EXECUTE
- SEE ALSO
- AUTHOR
NAME
MLPerl
Machine Learning in Perl, Using the RPerl Optimizing Compiler
DESCRIPTION
MLPerl is a collection of algorithms and data structures used for building machine learning applications in Perl. For general info:
SYNOPSIS, KNN 2D BRUTE FORCE
Filename script/demo/k_nearest_neighbors_2D.pl:
#!/usr/bin/env perl # MLPerl, K Nearest Neighbors 2D, Demo Driver # Load training points, find K nearest neighbors to classify test points use RPerl; use strict; use warnings; our $VERSION = 0.007_000; use MLPerl::PythonShims qw(concatenate for_range); use MLPerl::Classifier::KNeighbors; # read external data my string $file_name = $ARGV[0]; open my filehandleref $FILE_HANDLE, '<', $file_name or die 'ERROR EMLKNN2D10: Cannot open file ' . q{'} . $file_name . q{'} . ' for reading, ' . $OS_ERROR . ', dying' . "\n"; read $FILE_HANDLE, my string $file_lines, -s $FILE_HANDLE; close $FILE_HANDLE or die 'ERROR EMLKNN2D11: Cannot close file ' . q{'} . $file_name . q{'} . ' after reading, ' . $OS_ERROR . ', dying' . "\n"; # initialize local variables to hold external data my number_arrayref_arrayref $train_data_A = undef; my number_arrayref_arrayref $train_data_B = undef; my number_arrayref_arrayref $test_data = undef; # load external data eval($file_lines); # format train data, concatenate all train data arrays my number_arrayref_arrayref $train_data = concatenate($train_data_A, $train_data_B); # generate train data classifications my string_arrayref $train_classifications = concatenate(for_range('0', (scalar @{$train_data_A})), for_range('1', (scalar @{$train_data_B}))); # create KNN classifier my integer $k = 3; my object $knn = MLPerl::Classifier::KNeighbors->new(); $knn->set_n_neighbors($k); $knn->set_metric('euclidean'); # fit KNN classifier to training data $knn->fit($train_data, $train_classifications); # generate and display KNN classifier's predictions my string_arrayref $tests_classifications = $knn->predict($test_data); foreach my string $test_classifications (@{$tests_classifications}) { print $test_classifications, "\n"; }
SYNOPSIS, KNN 2D BRUTE FORCE, EXECUTE
$ ./script/demo/k_nearest_neighbors_2D.pl ./script/demo/k_nearest_neighbors_2D_data_25_25_50.pl
SYNOPSIS, KNN 2D BRUTE FORCE, COMPILE & EXECUTE
$ export RPERL_DEBUG=1 && export RPERL_VERBOSE=1 $ rperl -V lib/MLPerl/Classifier/KNeighbors.pm $ ./script/demo/k_nearest_neighbors_2D.pl ./script/demo/k_nearest_neighbors_2D_data_25_25_50.pl
SEE ALSO
AUTHOR
William N. Braswell, Jr.
Module Install Instructions
To install MLPerl, copy and paste the appropriate command in to your terminal.
cpanm MLPerl
perl -MCPAN -e shell install MLPerl
For more information on module installation, please visit the detailed CPAN module installation guide.