Skip to content

Commit

Permalink
Merge pull request #3 from chris-krokus/ML_Models
Browse files Browse the repository at this point in the history
Ml models
  • Loading branch information
UncelSoogar authored Sep 14, 2020
2 parents 573172f + d82338e commit f2d6728
Show file tree
Hide file tree
Showing 77 changed files with 12,383 additions and 0 deletions.
2,390 changes: 2,390 additions & 0 deletions Notebooks/.ipynb_checkpoints/cat_ml-checkpoint.ipynb

Large diffs are not rendered by default.

3,111 changes: 3,111 additions & 0 deletions Notebooks/.ipynb_checkpoints/dog_ml-checkpoint.ipynb

Large diffs are not rendered by default.

280 changes: 280 additions & 0 deletions Notebooks/.ipynb_checkpoints/model_testing-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"import pickle\n",
"import pandas as pd\n",
"from sklearn.ensemble import GradientBoostingClassifier\n",
"from sklearn.preprocessing import StandardScaler\n",
"pd.set_option('display.max_columns', None)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Read in cat model\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"#Import cat scaler\n",
"filename = '../App/Models/cat_scaler.sav'\n",
"infile = open(filename,'rb')\n",
"cat_scaler = pickle.load(infile)\n",
"infile.close()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"#Import cat scaler\n",
"filename = '../App/Models/cat_model.sav'\n",
"infile = open(filename,'rb')\n",
"cat_model = pickle.load(infile)\n",
"infile.close()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"GradientBoostingClassifier(criterion='friedman_mse', init=None,\n",
" learning_rate=0.1, loss='deviance', max_depth=3,\n",
" max_features=None, max_leaf_nodes=None,\n",
" min_impurity_decrease=0.0, min_impurity_split=None,\n",
" min_samples_leaf=1, min_samples_split=2,\n",
" min_weight_fraction_leaf=0.0, n_estimators=100,\n",
" n_iter_no_change=None, presort='auto',\n",
" random_state=None, subsample=1.0, tol=0.0001,\n",
" validation_fraction=0.1, verbose=0,\n",
" warm_start=False)\n"
]
}
],
"source": [
"#Cat cols\n",
"Index(['Length of Stay(days)', 'Animal Breed_DOMESTIC LH',\n",
" 'Animal Breed_DOMESTIC MH', 'Animal Breed_DOMESTIC SH',\n",
" 'Animal Origin_FIELD', 'Animal Origin_OVER THE COUNTER',\n",
" 'Chip Status_CHIP', 'Chip Status_NO CHIP', 'Chip Status_UNABLE TO SCAN',\n",
" 'Intake Condition_CONTAGIOUS', 'Intake Condition_HEALTHY',\n",
" 'Intake Condition_MANAGEABLE NON-CONTAGIOUS',\n",
" 'Intake Condition_REHABILITABLE NON-CONTAGIOUS',\n",
" 'Intake Condition_UNTREATABLE NON-CONTAGIOUS'],"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"#Conjure a cat\n",
"a_cat = [[1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0]]"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"#Scale the cat\n",
"a_cat = cat_scaler.transform(a_cat)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0.09168482, 0.60837809, 0.00141407, 0.29852302]])"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cat_model.predict_proba(a_cat)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1])"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cat_model.predict(a_cat)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Repeat for dog model"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"#Import dog scaler\n",
"filename = '../App/Models/dog_scaler.sav'\n",
"infile = open(filename,'rb')\n",
"dog_scaler = pickle.load(infile)\n",
"infile.close()"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"#Import dog scaler\n",
"filename = '../App/Models/dog_model.sav'\n",
"infile = open(filename,'rb')\n",
"dog_model = pickle.load(infile)\n",
"infile.close()"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"#Conjure a dog\n",
"a_corgi = [[1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0]]\n",
"a_pug = [[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0]]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Dog cols\n",
"Index(['Length of Stay(days)', 'Animal Breed_CHIHUAHUA', 'Animal Breed_CORGI',\n",
" 'Animal Breed_HOUND', 'Animal Breed_OTHER', 'Animal Breed_PIT BULL',\n",
" 'Animal Breed_PUG', 'Animal Breed_RETRIEVER', 'Animal Breed_SHEPHERD',\n",
" 'Animal Breed_TERRIER', 'Animal Origin_FIELD',\n",
" 'Animal Origin_OVER THE COUNTER', 'Chip Status_CHIP',\n",
" 'Chip Status_NO CHIP', 'Chip Status_UNABLE TO SCAN',\n",
" 'Intake Condition_CONTAGIOUS', 'Intake Condition_HEALTHY',\n",
" 'Intake Condition_MANAGEABLE NON-CONTAGIOUS',\n",
" 'Intake Condition_REHABILITABLE NON-CONTAGIOUS',\n",
" 'Intake Condition_UNTREATABLE NON-CONTAGIOUS'],\n",
" dtype='object')"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"#Scale the dogs\n",
"a_corgi = dog_scaler.transform(a_corgi)\n",
"a_pug = dog_scaler.transform(a_pug)"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0.47655399, 0.04513255, 0.22901109, 0.24930237]])"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dog_model.predict_proba(a_corgi)"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0.37818874, 0.02501556, 0.3313329 , 0.2654628 ]])"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dog_model.predict_proba(a_pug)"
]
}
],
"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": 2
}
Loading

0 comments on commit f2d6728

Please sign in to comment.