Esempio n. 1
0
// Find adjacent intervals with smallest $\chi^2$
IntervalList::iterator find_min_chi_chi()
{
	// Compute $\chi^2$ value for each adjacent interval,
	//  keeping track of minimum value
	IntervalList::iterator lit = g_intervals.begin(),
		lend = g_intervals.end();
	IntervalList::iterator next = lit, min_lit = lend;

	float min_chisquared = 1e6;
	bool first = true;

	for ( ; lit != lend; ++lit) {
        next = lit;
		++next;

		if (next == lend) break;

		float chisquared = compute_chisquared(*lit, *next);

		// Debug
		print_interval_set(*lit);
		cout << "\\chi^2 = " << chisquared << endl;

		if (first || chisquared < min_chisquared) {
			min_lit = lit;
			min_chisquared = chisquared;
		}

		first = false;
	}

	cout << "min_chisquared = " << min_chisquared << endl;

    return min_lit;
}
Esempio n. 2
0
void print_interval_summary(ostream& os, int dimIndex)
{
	IntervalList::iterator lit = g_intervals.begin(),
		lend = g_intervals.end();
	IntervalList::iterator next = lit;

	vector<DataType> split_points;

	os << "\n" "Feature " << (dimIndex+1) << ":" << endl;
	os << "Ranges: ";

	for ( ; lit != lend; ++lit) {
        next = lit;
		++next;

		pair<DataType, DataType> range, next_range;
		range = get_range(*lit, dimIndex);

		if (next != lend) {
            next_range = get_range(*next, dimIndex);

			float average = (range.second + next_range.first) * 0.5f;
			split_points.push_back(average);
		}

		os << "[" << range.first << ", " << range.second << "] ";
	}

	os << endl;

	os << "Split points: ";
	copy(split_points.begin(), split_points.end(),
		ostream_iterator<DataType>(os, ", "));
	os << endl;
}
Esempio n. 3
0
// Debugging -- print all intervals
void print_all_intervals()
{
	IntervalList::iterator lit = g_intervals.begin(),
		lend = g_intervals.end();

	cout << "[intervals]" << endl;

	for ( ; lit != lend; ++lit) {
		IntervalSet& indices = *lit;
		print_interval_set(indices);
	}
}