forked from RodolfoFerro/streamlit-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iris.py
33 lines (25 loc) · 902 Bytes
/
iris.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# ==============================================================
# Author: Rodolfo Ferro
# Twitter: @rodo_ferro
#
# ABOUT COPYING OR USING PARTIAL INFORMATION:
# This script has been originally created by Rodolfo Ferro.
# Any explicit usage of this script or its contents is granted
# according to the license provided and its conditions.
# ==============================================================
# -*- coding: utf-8 -*-
from sklearn.datasets import load_iris
from sklearn import tree
def decision_tree(verbose=False):
"""Basic Decision Tree Classifier for Iris problem.
Based on: http://scikit-learn.org/stable/modules/tree.html
"""
# Load dataset:
iris = load_iris()
# Build and train classifier:
clf = tree.DecisionTreeClassifier()
clf = clf.fit(iris.data, iris.target)
# Visualize model:
if verbose:
tree.plot_tree(clf)
return clf