Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add distance interface factory. Port Euclidean meta example to new API.
- Loading branch information
Showing
5 changed files
with
18 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
CSVFile f_feats_a("../../data/fm_train_real.dat") | ||
CSVFile f_feats_b("../../data/fm_test_real.dat") | ||
File f_features_a = csv_file("../../data/fm_train_real.dat") | ||
File f_features_b = csv_file("../../data/fm_test_real.dat") | ||
|
||
#![create_features] | ||
RealFeatures features_a(f_feats_a) | ||
RealFeatures features_b(f_feats_b) | ||
Features features_a = features(f_features_a) | ||
Features features_b = features(f_features_b) | ||
#![create_features] | ||
|
||
#![create_instance] | ||
EuclideanDistance distance(features_a, features_a) | ||
Distance d = distance("EuclideanDistance", lhs=features_a, rhs=features_a) | ||
#![create_instance] | ||
|
||
#![extract_distance] | ||
RealMatrix distance_matrix_aa = distance.get_distance_matrix() | ||
RealMatrix distance_matrix_aa = d.get_distance_matrix() | ||
#![extract_distance] | ||
|
||
#![refresh_distance] | ||
distance.init(features_a, features_b) | ||
d.init(features_a, features_b) | ||
#![refresh_distance] | ||
|
||
#![extract_sq_distance] | ||
distance.set_disable_sqrt(True) | ||
RealMatrix distance_matrix_ab = distance.get_distance_matrix() | ||
d.put("disable_sqrt", True) | ||
RealMatrix sq_distance_matrix_ab = d.get_distance_matrix() | ||
#![extract_sq_distance] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters