Commit 2e01ef69 authored by Adam Monsen's avatar Adam Monsen

allow easy choosing action(s) to run

parent 36897fcd
......@@ -14,15 +14,13 @@ from sklearn.naive_bayes import GaussianNB
from sklearn.svm import SVC
# print library versions
def printVersions():
import sys, scipy, numpy, matplotlib, sklearn
print('Python: {}'.format(sys.version))
print('scipy: {}'.format(scipy.__version__))
print('numpy: {}'.format(numpy.__version__))
print('matplotlib: {}'.format(matplotlib.__version__))
print('pandas: {}'.format(pandas.__version__))
print('sklearn: {}'.format(sklearn.__version__))
printVersions()
import sys, scipy, numpy, matplotlib, sklearn
print('Python: {}'.format(sys.version))
print('scipy: {}'.format(scipy.__version__))
print('numpy: {}'.format(numpy.__version__))
print('matplotlib: {}'.format(matplotlib.__version__))
print('pandas: {}'.format(pandas.__version__))
print('sklearn: {}'.format(sklearn.__version__))
# Load dataset
url = "./iris.data"
......@@ -30,28 +28,35 @@ names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class']
dataset = pandas.read_csv(url, names=names)
# shape (rows/instances and columns/attributes)
#print(dataset.shape)
def dataShape():
print(dataset.shape)
# head (dump data for 1st n rows)
#print(dataset.head(10))
def firstNrows(n):
print(dataset.head(n))
# quick stats for dataset
print(dataset.describe())
def quickStats():
print(dataset.describe())
# class distribution
#print(dataset.groupby('class').size())
def classDistribution():
print(dataset.groupby('class').size())
# box and whisker plots
#dataset.plot(kind='box', subplots=True, layout=(2,2), sharex=False, sharey=False)
#plt.show()
def boxAndWhiskerPlots():
dataset.plot(kind='box', subplots=True, layout=(2,2), sharex=False, sharey=False)
plt.show()
# histograms
#dataset.hist()
#plt.show()
def histograms():
dataset.hist()
plt.show()
# scatter plot matrix
#scatter_matrix(dataset)
#plt.show()
def scatterPlotMatrix():
scatter_matrix(dataset)
plt.show()
# Split-out validation dataset
array = dataset.values
......@@ -88,17 +93,29 @@ for name, model in models:
print(msg)
# Compare Algorithms
fig = plt.figure()
fig.suptitle('Algorithm Comparison')
ax = fig.add_subplot(111)
plt.boxplot(results)
ax.set_xticklabels(names)
#plt.show()
def compareAlgorithms():
fig = plt.figure()
fig.suptitle('Algorithm Comparison')
ax = fig.add_subplot(111)
plt.boxplot(results)
ax.set_xticklabels(names)
plt.show()
# Make predictions on validation dataset
knn = KNeighborsClassifier()
knn.fit(X_train, Y_train)
predictions = knn.predict(X_validation)
print(accuracy_score(Y_validation, predictions))
print(confusion_matrix(Y_validation, predictions))
print(classification_report(Y_validation, predictions))
def makePredictions():
knn = KNeighborsClassifier()
knn.fit(X_train, Y_train)
predictions = knn.predict(X_validation)
print(accuracy_score(Y_validation, predictions))
print(confusion_matrix(Y_validation, predictions))
print(classification_report(Y_validation, predictions))
#dataShape()
#firstNrows(10)
#quickStats()
#classDistribution()
#boxAndWhiskerPlots()
#histograms()
scatterPlotMatrix()
#compareAlgorithms()
#makePredictions()
#!/bin/bash
set -o errexit
# exit with error if anything returns nonzero exit status
# (disable to make sure final xhost setting cleanup occurs)
#set -o errexit
set -o nounset
set -o pipefail
# start interactive shell and mount current dir for instant local edits
echo ">>> test with 'python /live/hello.py' <<<"
set -o xtrace
# allow use of host X11 display
xhost +
XSOCK=/tmp/.X11-unix
# run non-interactive
#docker run -it --rm -v $XSOCK:$XSOCK --name ml-tutorial ml-tutorial
# start interactive shell and mount current dir for instant local edits
echo "test with 'python /live/hello.py'"
docker run -it --rm -v $XSOCK:$XSOCK -v "$(pwd):/live" --name ml-tutorial ml-tutorial /bin/bash
# lock back down X11 access
xhost -
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment