Skip to content

Commit

Permalink
added 12 liner
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishna Chaitanya S. Balaga authored and Krishna Chaitanya S. Balaga committed Jun 24, 2017
1 parent 76f9a53 commit af49e0d
Show file tree
Hide file tree
Showing 6 changed files with 1,149 additions and 46 deletions.
291 changes: 291 additions & 0 deletions .ipynb_checkpoints/classification simple-checkpoint.ipynb

Large diffs are not rendered by default.

142 changes: 142 additions & 0 deletions .ipynb_checkpoints/classification-12Liner-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"!pip install scikit-learn==0.18"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"import pandas\n",
"from sklearn.neighbors import KNeighborsClassifier"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"url = \"https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data\"\n",
"names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class']\n",
"dataset = pandas.read_csv(url, names=names)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"array = dataset.values\n",
"X = array[:,0:4]\n",
"Y = array[:,4]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [
{
"data": {
"text/plain": [
"KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',\n",
" metric_params=None, n_jobs=1, n_neighbors=5, p=2,\n",
" weights='uniform')"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"knn = KNeighborsClassifier()\n",
"knn.fit(X, Y)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Iris-versicolor']\n"
]
}
],
"source": [
"predictions = knn.predict([[6.4,3.2,4.5,1.5]])\n",
"print(predictions)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"deletable": true,
"editable": true
},
"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.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading

0 comments on commit af49e0d

Please sign in to comment.