CS 330 - Artificial Intelligent - Review & Practical AI - - PowerPoint PPT Presentation

cs 330 artificial intelligent
SMART_READER_LITE
LIVE PREVIEW

CS 330 - Artificial Intelligent - Review & Practical AI - - PowerPoint PPT Presentation

1 CS 330 - Artificial Intelligent - Review & Practical AI Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Fall 2019 Announcement Review on decision tree homework Reading materials posted on course


slide-1
SLIDE 1

CS 330 - Artificial Intelligent

  • Review & Practical AI

Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Fall 2019 1

slide-2
SLIDE 2

Announcement

  • Review on decision tree homework
  • Reading materials posted on course website (Information

gain, Naive Bayesian and Decision Tree example)

  • Quiz #3 on next Tuesday. Go over study guide.
  • Literature review (bring your laptop for adding comments)

and generate group order.

slide-3
SLIDE 3

Another way for Lab 2 Matrix operation

Numpy: open-source add-on module to Python that provide common mathematical and numerical routines

slide-4
SLIDE 4

Numpy

#import numpy

  • r

#import numpy as np

slide-5
SLIDE 5

Numpy

# a = np.array([1, 4, 5, 8], float) # type(a) Try : a[:2] Try : a[3] Try : a[0] = 5 # a = np.array([[1, 2, 3], [4, 5, 6]], float) Try: a[0,0] Try: a[-1:, -2:] Try: a.shape Try: len(a)

slide-6
SLIDE 6

Numpy

# a.tolist() or list(a) # b = a.flatten() # b.reshape(3,2) Some operations like: # a+a # a*a # np.dot(a,b) # np.sqrt(a) # a.min() or a.max(), a.mean() More reading materials on course website!

slide-7
SLIDE 7

Scikit-Learn: Machine learning in Python

http://scikit-learn.org/stable/ Connect to Simon server, and go to Python command mode

slide-8
SLIDE 8

Scikit-Learn: Machine learning in Python

  • 1. Naive Bayes Example

from sklearn import datasets iris = datasets.load_iris() from sklearn.naive_bayes import GaussianNB gnb = GaussianNB() y_pred = gnb.fit(iris.data, iris.target).predict(iris.data) print("Number of mislabeled points out of a total %d points : %d" % (iris.data.shape[0],(iris.target != y_pred).sum()))

slide-9
SLIDE 9

Scikit-Learn: Machine learning in Python

  • 2. Decision Tree Example

from sklearn.datasets import load_iris from sklearn import tree iris = load_iris() clf = tree.DecisionTreeClassifier() clf = clf.fit(iris.data, iris.target) y_pred = clf.predict(iris.data) print("Number of mislabeled points out of a total %d points : %d" % (iris.data.shape[0],(iris.target != y_pred).sum()))

slide-10
SLIDE 10

Scikit-Learn: Machine learning in Python

  • 3. Logistic Regression Example

from sklearn.datasets import load_iris from sklearn.linear_model import LogisticRegression iris = load_iris() clf = LogisticRegression(random_state=0, solver='lbfgs', multi_class='multinomial').fit(iris.data, iris.target) y_pred = clf.predict(iris.data) print("Number of mislabeled points out of a total %d points : %d" % (iris.data.shape[0],(iris.target != y_pred).sum()))

slide-11
SLIDE 11

Scikit-Learn: Machine learning in Python

  • 4. Linear Regression Example

from sklearn.datasets import load_iris from sklearn.linear_model import LinearRegression iris = load_iris() clf = LinearRegression().fit(iris.data, iris.target) y_pred = clf.predict(iris.data) print("Number of mislabeled points out of a total %d points : %d" % (iris.data.shape[0],(iris.target != y_pred).sum()))

slide-12
SLIDE 12

Scikit-Learn: Machine learning in Python

Lab 3: check Sakai assignment, explore sklearn at: https:// scikit-learn.org/stable/