⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 combiner.c

📁 使用具有增量学习的监控式学习方法。包括几个不同的分类算法。
💻 C
字号:
/* Copyright (C) 2002, 2003  Mikael Ylikoski * See the accompanying file "README" for the full copyright notice *//** * Combination classifier. * * Takes classification results from other classifiers and combines them. * Currently the combination rule is hard-coded as '2[0],1,0' or * something similar. * * How it might work in the future: * Combiner is a doc_classifier that makes the calls to the other classifiers. * The rules are given as options. * * [classifier] * classifier	Combiner		# Combination classifier * type		combination		# * result	rank			# Result type score * * # Classify according to first reply than from than c1 * options	reply, from, c1 * # Classify according to first top classification of reply than top * # classification of from than classification of c0 * options	reply[0], from[0], c0 * # Mix results of c0 and c1 according to score * options	c0 & c1 * * Operations: *   normalization: *c0		(only for score) *   mixing: c0 & c1		(take average for each class) *   subresult: c0[0] *   sequence: c0, c1 * * @author  Mikael Ylikoski * @date    2002-2003 */#include <stdio.h>#include <string.h>#include "combiner.h"#include "utility.h"/** * Combiner. */struct combiner_ {    char *str;		/**< Combiner rule */};/** * Create a new combiner. */combiner *combiner_new (char *str) {    combiner *cb;    cb = my_malloc (sizeof(combiner));    cb->str = str;    return cb;}/** * Move class in ranking. */static int *move_in_rank (int *ranklist, int no, int pos) {    int i;    /* find current position */    for (i = 0; ranklist[i] != -1; i++)	if (ranklist[i] == no)	    break;    if (ranklist[i] == -1) {	ranklist = my_realloc (ranklist, (i + 2) * sizeof(int));	memmove (&ranklist[pos + 1], &ranklist[pos], (i - pos + 1) * sizeof(int));	ranklist[pos] = no;    } else if (i > pos) {	memmove (&ranklist[pos + 1], &ranklist[pos], (i - pos) * sizeof(int));	ranklist[pos] = no;    } else if (i < pos) {	memmove (&ranklist[i + 1], &ranklist[i], (pos - i) * sizeof(int));	ranklist[pos] = no;    }    return ranklist;}/** * Combine results. */int *combiner_combine_rank (combiner *co, combi_results *cr) {    int i;    int *r;    if (cr->nor < 1)	return NULL;    /* Copy first results */    for (i = 0; cr->res[0][i] != -1; i++)	;    if (i < 1)	return NULL;    i++;    r = my_malloc (sizeof(int) * i);    memcpy (r, cr->res[0], i * sizeof(int));    /*    if (cr->nor >= 2)	// from classifier	for (i = 0; cr->res[1][i] != -1; i++)	    r = move_in_rank (r, cr->res[1][i], i);    */    if (cr->nor >= 3)	// reply classifier	if (cr->res[2][0] != -1)	    r = move_in_rank (r, cr->res[2][0], 0);    /*    if (1 && cr->nor >= 4)	// activity classifier	for (i = nob - 2; i >= 0; i--)	    if (td->a_list[i] < 1)		move_in_rank (ranklist, nob, i, i + 1);    */    return r;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -