Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

classification returns irrelevant results in else conditions #42

Closed
serengil opened this issue Dec 25, 2023 · 1 comment
Closed

classification returns irrelevant results in else conditions #42

serengil opened this issue Dec 25, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@serengil
Copy link
Owner

For the configuration

config = {
        "algorithm": "ID3",
        # "enableRandomForest": True,
        # "num_of_trees": 3,
    }

I am getting the following tree for car.data dataset.

def findDecision(obj): #obj[0]: buying, obj[1]: maint, obj[2]: doors, obj[3]: persons, obj[4]: lug_boot, obj[5]: safety
	# {"feature": "safety", "instances": 1728, "metric_value": 1.2057, "depth": 1}
	if obj[5] == 'low':
		return 'unacc'
	elif obj[5] == 'med':
		# {"feature": "persons", "instances": 576, "metric_value": 1.2152, "depth": 2}
		if obj[3] == '2':
			return 'unacc'
		elif obj[3] == '4':
			# {"feature": "buying", "instances": 192, "metric_value": 1.3543, "depth": 3}
			if obj[0] == 'vhigh':
				# {"feature": "maint", "instances": 48, "metric_value": 0.8113, "depth": 4}
				if obj[1] == 'vhigh':
					return 'unacc'
				elif obj[1] == 'high':
					return 'unacc'
				elif obj[1] == 'med':
					# {"feature": "lug_boot", "instances": 12, "metric_value": 1.0, "depth": 5}
					if obj[4] == 'small':
						return 'unacc'
					elif obj[4] == 'med':
						return 'unacc'
					elif obj[4] == 'big':
						return 'acc'
					else: return '4'
				elif obj[1] == 'low':
					# {"feature": "lug_boot", "instances": 12, "metric_value": 1.0, "depth": 5}
					if obj[4] == 'small':
						return 'unacc'
					elif obj[4] == 'med':
						return 'unacc'
					elif obj[4] == 'big':
						return 'acc'
					else: return '4'
				else: return '6'

As seen, results should be nominal but in else conditions it is returning numbers somehow.

@serengil serengil added the bug Something isn't working label Dec 25, 2023
@serengil
Copy link
Owner Author

Resolved with PR - #43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant