Haplo Prediction
predict haplogroups
|
Definitions for a Weka J48 and PART classifiers. More...
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <inttypes.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/valid.h>
#include <jwsc/base/error.h>
#include <jwsc/base/file_io.h>
#include <jwsc/vector/vector.h>
#include <jwsc/matrix/matrix.h>
#include "xml.h"
#include "haplo_groups.h"
#include "weka.h"
Go to the source code of this file.
Functions | |
static Error * | read_weka_model_labels (char **labels_str_out, const char *labels_fname) |
Reads a list of Weka model labels. | |
Error * | train_weka_j48_model (const Vector_u32 *labels, const Matrix_i32 *markers, const char *labels_fname, const char *model_fname, const char *weka_jar_fname) |
Trains a Weka J48 model and writes it to a file. | |
Error * | train_weka_part_model (const Vector_u32 *labels, const Matrix_i32 *markers, const char *labels_fname, const char *model_fname, const char *weka_jar_fname) |
Trains a Weka PART model and writes it to a file. | |
Error * | predict_labels_with_weka_j48_model (Vector_u32 **labels_out, Vector_d **confs_out, const Matrix_i32 *markers, const char *labels_fname, const char *model_fname, const char *weka_jar_fname) |
Predicts the labels for a set of marker samples using Weka's J48 classifier. | |
Error * | predict_labels_with_weka_part_model (Vector_u32 **labels_out, Vector_d **confs_out, const Matrix_i32 *markers, const char *labels_fname, const char *model_fname, const char *weka_jar_fname) |
Predicts the labels for a set of marker samples using Weka's PART classifier. | |
static Error * | read_weka_xml_doc (xmlDoc **xml_doc_out, const char *xml_fname, const char *dtd_fname) |
Reads and and optionally validates an XML document. | |
static Error * | create_weka_model_tree_from_xml_node (Weka_model_tree **tree_out, const Weka_model_tree *parent, uint32_t parent_label, xmlNode *xml_node, const char *model_dirname) |
Allocates and initializes a model tree from an xml node. | |
static Error * | create_model_training_data (Vector_u32 **train_labels_out, Matrix_i32 **train_markers_out, const Vector_u32 *data_labels, const Matrix_i32 *data_markers, const Vector_u32 *model_labels, Vector_u32 *const *model_altlabels) |
Creates a set of training data as a model-specific labeled subset of a larger data set. | |
static Error * | train_weka_j48_model_node (Weka_model_node *node, const Vector_u32 *labels, const Matrix_i32 *markers, const char *weka_jar_fname) |
Trains a model in the tree using node-specific data. | |
static Error * | train_weka_part_model_node (Weka_model_node *node, const Vector_u32 *labels, const Matrix_i32 *markers, const char *weka_jar_fname) |
Trains a model in the tree using node-specific data. | |
Error * | train_weka_j48_model_tree (Weka_model_tree **tree_out, const Vector_u32 *labels, const Matrix_i32 *markers, const char *tree_xml_fname, const char *tree_dtd_fname, const char *model_dirname, const char *weka_jar_fname) |
Trains a Weka J48 model tree . | |
Error * | train_weka_part_model_tree (Weka_model_tree **tree_out, const Vector_u32 *labels, const Matrix_i32 *markers, const char *tree_xml_fname, const char *tree_dtd_fname, const char *model_dirname, const char *weka_jar_fname) |
Trains a Weka PART model tree . | |
static Error * | recursively_predict_j48_labels_in_model_tree (Vector_u32 **labels_out, Vector_d **confs_in_out, const Weka_model_tree *tree, const Matrix_i32 *markers, const char *weka_jar_fname) |
Recursively predicts a label from a model tree. | |
static Error * | recursively_predict_part_labels_in_model_tree (Vector_u32 **labels_out, Vector_d **confs_in_out, const Weka_model_tree *tree, const Matrix_i32 *markers, const char *weka_jar_fname) |
Recursively predicts a label from a model tree. | |
Error * | predict_labels_with_weka_j48_model_tree (Vector_u32 **labels_out, Vector_d **confs_out, const Matrix_i32 *markers, const Weka_model_tree *tree, const char *weka_jar_fname) |
Predicts the labels for a set of marker samples using a Weka J48 model tree. | |
Error * | predict_labels_with_weka_part_model_tree (Vector_u32 **labels_out, Vector_d **confs_out, const Matrix_i32 *markers, const Weka_model_tree *tree, const char *weka_jar_fname) |
Predicts the labels for a set of marker samples using a Weka PART model tree. | |
Error * | read_weka_model_tree (Weka_model_tree **tree_out, const char *tree_xml_fname, const char *tree_dtd_fname, const char *model_dirname) |
Reads a Weka model tree. | |
void | free_weka_model_tree (Weka_model_tree *tree) |
Frees a Weka model tree. |
Definitions for a Weka J48 and PART classifiers.
Definition in file weka.c.
static Error* read_weka_model_labels | ( | char ** | labels_str_out, |
const char * | labels_fname | ||
) | [static] |
Error* train_weka_j48_model | ( | const Vector_u32 * | labels, |
const Matrix_i32 * | markers, | ||
const char * | labels_fname, | ||
const char * | model_fname, | ||
const char * | weka_jar_fname | ||
) |
Trains a Weka J48 model and writes it to a file.
labels | Labels for training, with ith element as corresponding to the ith sample in markers. |
markers | Markers for training, with ith row as a sample corresponding to the ith label in labels. |
labels_fname | File name containing labels for groups in the model. |
model_fname | File name containing the model. |
weka_jar_fname | Weka java archive file. |
Error* train_weka_part_model | ( | const Vector_u32 * | labels, |
const Matrix_i32 * | markers, | ||
const char * | labels_fname, | ||
const char * | model_fname, | ||
const char * | weka_jar_fname | ||
) |
Trains a Weka PART model and writes it to a file.
labels | Labels for training, with ith element as corresponding to the ith sample in markers. |
markers | Markers for training, with ith row as a sample corresponding to the ith label in labels. |
labels_fname | File name containing labels for groups in the model. |
model_fname | File name containing the model. |
weka_jar_fname | Weka java archive file. |
Error* predict_labels_with_weka_j48_model | ( | Vector_u32 ** | labels_out, |
Vector_d ** | confs_out, | ||
const Matrix_i32 * | markers, | ||
const char * | labels_fname, | ||
const char * | model_fname, | ||
const char * | weka_jar_fname | ||
) |
Predicts the labels for a set of marker samples using Weka's J48 classifier.
labels_out | Result parameter. |
confs_out | Result parameter. |
markers | Marker data to predict. |
labels_fname | File name containing labels used by the model. |
model_fname | File name containing the model. |
weka_jar_fname | Weka java archive file. |
Error* predict_labels_with_weka_part_model | ( | Vector_u32 ** | labels_out, |
Vector_d ** | confs_out, | ||
const Matrix_i32 * | markers, | ||
const char * | labels_fname, | ||
const char * | model_fname, | ||
const char * | weka_jar_fname | ||
) |
Predicts the labels for a set of marker samples using Weka's PART classifier.
labels_out | Result parameter. |
confs_out | Result parameter. |
markers | Marker data to predict. |
labels_fname | File name containing labels used by the model. |
model_fname | File name containing the model. |
weka_jar_fname | Weka java archive file. |
static Error* create_weka_model_tree_from_xml_node | ( | Weka_model_tree ** | tree_out, |
const Weka_model_tree * | parent, | ||
uint32_t | parent_label, | ||
xmlNode * | xml_node, | ||
const char * | model_dirname | ||
) | [static] |
static Error* create_model_training_data | ( | Vector_u32 ** | train_labels_out, |
Matrix_i32 ** | train_markers_out, | ||
const Vector_u32 * | data_labels, | ||
const Matrix_i32 * | data_markers, | ||
const Vector_u32 * | model_labels, | ||
Vector_u32 *const * | model_altlabels | ||
) | [static] |
static Error* train_weka_j48_model_node | ( | Weka_model_node * | node, |
const Vector_u32 * | labels, | ||
const Matrix_i32 * | markers, | ||
const char * | weka_jar_fname | ||
) | [static] |
static Error* train_weka_part_model_node | ( | Weka_model_node * | node, |
const Vector_u32 * | labels, | ||
const Matrix_i32 * | markers, | ||
const char * | weka_jar_fname | ||
) | [static] |
Error* train_weka_j48_model_tree | ( | Weka_model_tree ** | tree_out, |
const Vector_u32 * | labels, | ||
const Matrix_i32 * | markers, | ||
const char * | tree_xml_fname, | ||
const char * | tree_dtd_fname, | ||
const char * | model_dirname, | ||
const char * | weka_jar_fname | ||
) |
Trains a Weka J48 model tree .
tree_out | Result parameter. |
labels | Sample group labels. |
markers | Sample marker values. |
tree_xml_fname | XML file containing the model tree information. |
tree_dtd_fname | DTD file for validating the XML file, can be NULL. |
model_dirname | Model directory location. |
weka_jar_fname | Weka java archive file. |
Error* train_weka_part_model_tree | ( | Weka_model_tree ** | tree_out, |
const Vector_u32 * | labels, | ||
const Matrix_i32 * | markers, | ||
const char * | tree_xml_fname, | ||
const char * | tree_dtd_fname, | ||
const char * | model_dirname, | ||
const char * | weka_jar_fname | ||
) |
Trains a Weka PART model tree .
tree_out | Result parameter. |
labels | Sample group labels. |
markers | Sample marker values. |
tree_xml_fname | XML file containing the model tree information. |
tree_dtd_fname | DTD file for validating the XML file, can be NULL. |
model_dirname | Model directory location. |
weka_jar_fname | Weka java archive file. |
static Error* recursively_predict_j48_labels_in_model_tree | ( | Vector_u32 ** | labels_out, |
Vector_d ** | confs_in_out, | ||
const Weka_model_tree * | tree, | ||
const Matrix_i32 * | markers, | ||
const char * | weka_jar_fname | ||
) | [static] |
static Error* recursively_predict_part_labels_in_model_tree | ( | Vector_u32 ** | labels_out, |
Vector_d ** | confs_in_out, | ||
const Weka_model_tree * | tree, | ||
const Matrix_i32 * | markers, | ||
const char * | weka_jar_fname | ||
) | [static] |
Error* predict_labels_with_weka_j48_model_tree | ( | Vector_u32 ** | labels_out, |
Vector_d ** | confs_out, | ||
const Matrix_i32 * | markers, | ||
const Weka_model_tree * | tree, | ||
const char * | weka_jar_fname | ||
) |
Predicts the labels for a set of marker samples using a Weka J48 model tree.
labels_out | Result parameter. If *labels_out is NULL, it is allocated; otherwise its space is re-used. |
confs_out | Result parameter. If *confs_out is NULL, it is allocated; otherwise its space is re-used. |
markers | Marker data to predict. Each row is a sample for prediction, corresponding to an element in the result parameters. |
tree | Trained model tree to use for predicting. |
weka_jar_fname | Weka java archive file. |
Error* predict_labels_with_weka_part_model_tree | ( | Vector_u32 ** | labels_out, |
Vector_d ** | confs_out, | ||
const Matrix_i32 * | markers, | ||
const Weka_model_tree * | tree, | ||
const char * | weka_jar_fname | ||
) |
Predicts the labels for a set of marker samples using a Weka PART model tree.
labels_out | Result parameter. If *labels_out is NULL, it is allocated; otherwise its space is re-used. |
confs_out | Result parameter. If *confs_out is NULL, it is allocated; otherwise its space is re-used. |
markers | Marker data to predict. Each row is a sample for prediction, corresponding to an element in the result parameters. |
tree | Trained model tree to use for predicting. |
weka_jar_fname | Weka java archive file. |
Error* read_weka_model_tree | ( | Weka_model_tree ** | tree_out, |
const char * | tree_xml_fname, | ||
const char * | tree_dtd_fname, | ||
const char * | model_dirname | ||
) |
void free_weka_model_tree | ( | Weka_model_tree * | tree | ) |