Created
June 1, 2015 02:22
-
-
Save jgoad/aa1db1c23014537c9538 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 56, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd\n", | |
"from sklearn import svm\n", | |
"import random" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 232, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"0.818330605565\n" | |
] | |
} | |
], | |
"source": [ | |
"# import climate control log\n", | |
"data = pd.read_csv('climate_control_log.csv')\n", | |
"\n", | |
"#randomize order and reindex\n", | |
"index = random.sample(range(0, len(data)), len(data))\n", | |
"data = data.ix[index]\n", | |
"data.index = np.arange(0,len(data))\n", | |
"\n", | |
"#set up features and classes\n", | |
"#features = data[['temp','hum','outside_temp','outside_hum','temp_set_point','hum_set_point']]\n", | |
"#features = data[['temp_set_point']]\n", | |
"features = pd.DataFrame(np.ones(len(data)))\n", | |
"\n", | |
"features = features.values\n", | |
"\n", | |
"classification = data.state.values\n", | |
"\n", | |
"#slice out training set\n", | |
"training_features = features[:len(features)/2]\n", | |
"training_classification = classification[:len(classification)/2]\n", | |
"\n", | |
"#initialize classifier algo\n", | |
"clf = svm.SVC()\n", | |
"clf.fit(training_features,training_classification) \n", | |
"\n", | |
"#test algo\n", | |
"test = clf.predict(features[len(features)/2:]) == classification[len(classification)/2:]\n", | |
"print(sum(test)/len(test))\n", | |
"del clf" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": 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.4.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment