cs 330 artificial intelligent
play

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


  1. 1 CS 330 - Artificial Intelligent - Review & Practical AI Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Fall 2019

  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.

  3. Another way for Lab 2 Matrix operation Numpy: open-source add-on module to Python that provide common mathematical and numerical routines

  4. Numpy #import numpy or #import numpy as np

  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)

  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!

  7. Scikit-Learn: Machine learning in Python http://scikit-learn.org/stable/ Connect to Simon server, and go to Python command mode

  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()))

  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()))

  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()))

  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()))

  12. Scikit-Learn: Machine learning in Python Lab 3: check Sakai assignment, explore sklearn at: https:// scikit-learn.org/stable/

Recommend


More recommend