Permalink
Browse files

Updated anomaly detection exporter examples

  • Loading branch information...
vinayvinkumar committed Nov 16, 2018
1 parent 154913f commit 75780979a9d152df39b86a090353d5a47a3c9079
Showing with 8 additions and 101 deletions.
  1. +5 −58 examples/skl/6_IsolationForest_model_to_PMML.ipynb
  2. +3 −43 examples/skl/7_OneClassSVM_Model_to_PMML.ipynb
@@ -6,45 +6,14 @@
"source": [
"# anomaly → PMML (using Nyoka) \n",
"\n",
"### Exporter: Anomaly Detection models (OneClassSVM) \n",
"### Exporter: Anomaly Detection models (Isolation Forests) \n",
"### Data Set used: iris\n",
"\n",
"### **STEPS**: \n",
"- Build the model using sklearn OneClassSVM\n",
"- Build the model using sklearn Isolation Forests\n",
"- Build PMML (Data Dictionary, Mining schema, Ouput, PMML) using Nyoka classes"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2018-07-10T06:27:56.864880Z",
"start_time": "2018-07-10T06:27:56.839880Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<style>.container { width:100% !important; }</style>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Jupyter cells: 100% width \n",
"from IPython.core.display import display, HTML\n",
"display(HTML(\"<style>.container { width:100% !important; }</style>\"))\n",
"%config NotebookApp.iopub_data_rate_limit = 7000000000000.0 \n",
"%config NotebookApp.rate_limit_window=60.0"
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -54,18 +23,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from sklearn.ensemble import IsolationForest"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2018-07-10T06:27:59.647880Z",
@@ -80,18 +38,6 @@
"\n",
" Anomaly detection model is built successfully.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\swsh\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\utils\\deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.\n",
" warnings.warn(msg, category=DeprecationWarning)\n",
"C:\\Users\\swsh\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\ensemble\\iforest.py:214: FutureWarning: default contamination parameter 0.1 will change in version 0.22 to \"auto\". This will change the predict method behavior.\n",
" FutureWarning)\n",
"C:\\Users\\swsh\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\ensemble\\iforest.py:224: FutureWarning: behaviour=\"old\" is deprecated and will be removed in version 0.22. Please use behaviour=\"new\", which makes the decision_function change to match other anomaly detection algorithm API.\n",
" FutureWarning)\n"
]
}
],
"source": [
@@ -104,6 +50,7 @@
"from sklearn import datasets\n",
"from sklearn.pipeline import Pipeline\n",
"from sklearn.preprocessing import StandardScaler, Imputer\n",
"from sklearn.ensemble import IsolationForest\n",
"\n",
"irisdata = datasets.load_iris()\n",
"iris = pd.DataFrame(irisdata.data,columns=irisdata.feature_names)\n",
@@ -133,7 +80,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2018-07-10T06:28:05.359880Z",
@@ -14,37 +14,6 @@
"- Build PMML (Data Dictionary, Mining schema, Ouput, PMML) using Nyoka classes"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2018-07-10T06:27:56.864880Z",
"start_time": "2018-07-10T06:27:56.839880Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<style>.container { width:100% !important; }</style>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Jupyter cells: 100% width \n",
"from IPython.core.display import display, HTML\n",
"display(HTML(\"<style>.container { width:100% !important; }</style>\"))\n",
"%config NotebookApp.iopub_data_rate_limit = 7000000000000.0 \n",
"%config NotebookApp.rate_limit_window=60.0"
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -54,7 +23,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2018-07-10T06:27:59.647880Z",
@@ -69,14 +38,6 @@
"\n",
" Anomaly detection model is built successfully.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\swsh\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\utils\\deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.\n",
" warnings.warn(msg, category=DeprecationWarning)\n"
]
}
],
"source": [
@@ -119,13 +80,12 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2018-07-10T06:28:05.359880Z",
"start_time": "2018-07-10T06:28:04.605880Z"
},
"collapsed": true
}
},
"outputs": [],
"source": [

0 comments on commit 7578097

Please sign in to comment.