{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Machine Learing For Oracle Professionals" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Latest: 6-Jan-2020 v1b" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Congratuations on entering our learning environment!" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x=\"hello new world once again\"\n", "print(x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load all the libraries needed for this notebook." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np # To do array and math stuff\n", "import pandas as pd # To do dataframe and math stuff\n", "import matplotlib # To do plots\n", "from matplotlib import pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are many ways to load data into our workspace.\n", "First, read a CSV file directly from a URL." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "url = \"http://filebank.orapub.com/DataSets/ml-setup-demo-data.csv\"\n", "features = pd.read_csv(url, nrows=0).columns.tolist() # read the first row, which contains the column/feature names\n", "features = [x.strip(' ') for x in features] # remove leading/trailing spaces\n", "print(features) # display the data columns/features\n", "dfraw = pd.read_csv(url, names=features, skiprows=1) # read CSV contents from the URL, into the dataframe, dfraw" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For now, let's just print the structure, the column headings and a few rows." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dfraw.shape # (rows, columns)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dfraw.columns # show all dataframe columns/features" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dfraw.head() # display the first few dataframe rows" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's save the dfraw dataframe to your desktop as a CSV file." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Modify the below path to point to your desktop" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "export_csv = dfraw.to_csv ('/Users/cshallah/Desktop/testdata.csv', index=None, header=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's check to see if the file is on your Desktop, by re-reading the CSV file into a new dataframe, mydf." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mydf = pd.read_csv('/Users/cshallah/Desktop/testdata.csv')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mydf.head(4)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load some of the ML libraries needed for OraPub's Machine Learning classes." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os # To access your local OS\n", "import pickle # file IO\n", "\n", "from sklearn import preprocessing\n", "from sklearn.model_selection import train_test_split\n", "from datetime import datetime, timedelta \n", "from sklearn.preprocessing import LabelBinarizer\n", "from sklearn.preprocessing import OneHotEncoder\n", "from sklearn.metrics import accuracy_score\n", "from sklearn.metrics import classification_report\n", "from matplotlib import pyplot as plt\n", "from sklearn.model_selection import cross_val_score\n", "from sklearn.metrics import confusion_matrix\n", "from sklearn.model_selection import GridSearchCV\n", "from sklearn.dummy import DummyClassifier\n", "from sklearn.ensemble import RandomForestClassifier\n", "from sklearn.datasets import make_classification # needed with RandomForestClassifier\n", "from sklearn.linear_model import LogisticRegression\n", "from sklearn import tree\n", "from sklearn.discriminant_analysis import LinearDiscriminantAnalysis\n", "from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis\n", "from sklearn.neighbors import KNeighborsClassifier\n", "from sklearn.naive_bayes import GaussianNB\n", "from sklearn.tree import DecisionTreeClassifier\n", "from sklearn.svm import SVC, LinearSVC\n", "from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier, GradientBoostingClassifier\n", "from sklearn.neural_network import MLPClassifier\n", "\n", "print(\"Done.\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 4 }