Files
yola/zaoYun/master/.ipynb_checkpoints/14items-checkpoint.ipynb
T
coco 85d885e008 a
2026-07-03 16:29:47 +08:00

696 lines
24 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd \n",
"import seaborn as sns\n",
"from IPython.display import display\n",
"import matplotlib.pyplot as plt\n",
"from mpl_toolkits.mplot3d import Axes3D\n",
"import sklearn\n",
"%matplotlib inline\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"load data successful !!!!!\n"
]
}
],
"source": [
"try :\n",
" #PH值 - done\n",
" #data = pd.read_csv(\"data-ph.csv\")\n",
" #微蛋白 - done\n",
" #data = pd.read_csv(\"data-mau.csv\") \n",
" #蛋白质 - done\n",
" #data = pd.read_csv(\"data-pro.csv\") \n",
" #亚硝酸盐 - done\n",
" #data = pd.read_csv(\"data-nit.csv\") \n",
" \n",
" #肌酐\n",
" #data = pd.read_csv(\"data-cre.csv\") \n",
" #葡萄糖\n",
" #data = pd.read_csv(\"data-glu.csv\") \n",
" \n",
"\n",
" #通体 数据不正确\n",
" data = pd.read_csv(\"mix-mau-data.csv\") \n",
" #data = pd.read_excel(\"data-ket.xlsx\") \n",
"\n",
" #比重\n",
" #data = pd.read_csv(\"data-sg.csv\") \n",
" #抗坏血酸\n",
" #data = pd.read_csv(\"data-vc.csv\") \n",
" \n",
" #白细胞 - done\n",
" #data = pd.read_csv(\"data-wbc.csv\") \n",
" #尿胆原 - done\n",
" #data = pd.read_csv(\"data-uro.csv\") \n",
" #尿钙 -- done\n",
" #data1 = pd.read_csv(\"data-uca.csv\")\n",
" #data = pd.read_csv(\"data-uca2.csv\")\n",
" #data = data1.append(data2);\n",
" #胆红素 - done\n",
" #data = pd.read_csv(\"data-bil.csv\") \n",
" #潜血 - done\n",
" #data = pd.read_csv(\"data-bld.csv\") \n",
"\n",
" \n",
" \n",
" print (\"load data successful !!!!!\")\n",
"except :\n",
" print (\"load data error !!!!!!!!!!\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>h</th>\n",
" <th>s</th>\n",
" <th>v</th>\n",
" <th>l</th>\n",
" <th>a</th>\n",
" <th>b</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>count</th>\n",
" <td>19693.000000</td>\n",
" <td>19693.000000</td>\n",
" <td>19693.000000</td>\n",
" <td>19693.000000</td>\n",
" <td>19693.000000</td>\n",
" <td>19693.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mean</th>\n",
" <td>54.418880</td>\n",
" <td>81.691667</td>\n",
" <td>163.198548</td>\n",
" <td>142.412786</td>\n",
" <td>141.673285</td>\n",
" <td>139.583608</td>\n",
" </tr>\n",
" <tr>\n",
" <th>std</th>\n",
" <td>65.001826</td>\n",
" <td>46.115913</td>\n",
" <td>23.094477</td>\n",
" <td>41.231902</td>\n",
" <td>15.399092</td>\n",
" <td>4.050424</td>\n",
" </tr>\n",
" <tr>\n",
" <th>min</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>76.000000</td>\n",
" <td>46.000000</td>\n",
" <td>118.000000</td>\n",
" <td>121.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25%</th>\n",
" <td>5.000000</td>\n",
" <td>35.000000</td>\n",
" <td>146.000000</td>\n",
" <td>106.000000</td>\n",
" <td>126.000000</td>\n",
" <td>136.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50%</th>\n",
" <td>26.000000</td>\n",
" <td>79.000000</td>\n",
" <td>161.000000</td>\n",
" <td>135.000000</td>\n",
" <td>145.000000</td>\n",
" <td>140.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75%</th>\n",
" <td>63.000000</td>\n",
" <td>119.000000</td>\n",
" <td>182.000000</td>\n",
" <td>182.000000</td>\n",
" <td>156.000000</td>\n",
" <td>143.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>max</th>\n",
" <td>179.000000</td>\n",
" <td>176.000000</td>\n",
" <td>234.000000</td>\n",
" <td>232.000000</td>\n",
" <td>168.000000</td>\n",
" <td>149.000000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" h s v l a \\\n",
"count 19693.000000 19693.000000 19693.000000 19693.000000 19693.000000 \n",
"mean 54.418880 81.691667 163.198548 142.412786 141.673285 \n",
"std 65.001826 46.115913 23.094477 41.231902 15.399092 \n",
"min 0.000000 0.000000 76.000000 46.000000 118.000000 \n",
"25% 5.000000 35.000000 146.000000 106.000000 126.000000 \n",
"50% 26.000000 79.000000 161.000000 135.000000 145.000000 \n",
"75% 63.000000 119.000000 182.000000 182.000000 156.000000 \n",
"max 179.000000 176.000000 234.000000 232.000000 168.000000 \n",
"\n",
" b \n",
"count 19693.000000 \n",
"mean 139.583608 \n",
"std 4.050424 \n",
"min 121.000000 \n",
"25% 136.000000 \n",
"50% 140.000000 \n",
"75% 143.000000 \n",
"max 149.000000 "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"train_labels = data[\"index\"]\n",
"train_features = data.drop(\"index\",axis=1)\n",
"\n",
"train_features.describe()\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"D:\\Anaconda3\\lib\\site-packages\\sklearn\\cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.\n",
" \"This module will be removed in 0.20.\", DeprecationWarning)\n"
]
}
],
"source": [
"#from sklearn.model_selection import KFold\n",
"from sklearn.ensemble import RandomForestClassifier\n",
"from sklearn.metrics import accuracy_score\n",
"from sklearn.svm import SVC\n",
"from sklearn.metrics import f1_score\n",
"from sklearn.metrics import precision_score\n",
"from sklearn.metrics import recall_score\n",
"\n",
"\n",
"from sklearn.ensemble import ExtraTreesClassifier\n",
"from sklearn.ensemble import AdaBoostClassifier\n",
"\n",
"from sklearn.cross_validation import train_test_split\n",
"X_train ,X_test,y_train,y_test = train_test_split(train_features,train_labels,test_size = 0.4, random_state = 0)\n",
"#X_train ,X_test,y_train,y_test = train_test_split(train_features,train_labels,test_size = 0.2, random_state = 20)\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-----------classification_report----\n",
"\n",
" precision recall f1-score support\n",
"\n",
" 0 1.00 1.00 1.00 3478\n",
" 1 0.99 0.99 0.99 1391\n",
" 2 0.99 0.99 0.99 1594\n",
" 3 0.99 0.99 0.99 1415\n",
"\n",
"avg / total 1.00 1.00 1.00 7878\n",
"\n",
"-----------confusion_matrix---------\n",
"\n",
"[[3478 0 0 0]\n",
" [ 0 1382 9 0]\n",
" [ 0 10 1574 10]\n",
" [ 0 0 8 1407]]\n",
"------------------------------------\n",
"\n",
"Accuracy of prediction: 0.617\n",
"-----------------------------------\n",
"\n",
"DecisionTree accuracy score: 0.9953033764914953\n",
"f1 score: 0.9953033764914953\n",
"precision_score: 0.9953033764914953\n",
"recall_score: 0.9953033764914953\n"
]
}
],
"source": [
"from sklearn.tree import DecisionTreeClassifier\n",
"from sklearn.metrics import classification_report,confusion_matrix\n",
"\n",
"dtree = DecisionTreeClassifier(criterion='gini',max_depth=None)\n",
"dtree.fit(X_train,y_train)\n",
"predictions = dtree.predict(X_test)\n",
"\n",
"print(\"-----------classification_report----\\n\")\n",
"print(classification_report(y_test,predictions))\n",
"print(\"-----------confusion_matrix---------\\n\")\n",
"cm=confusion_matrix(y_test,predictions)\n",
"print(cm)\n",
"print(\"------------------------------------\\n\")\n",
"print (\"Accuracy of prediction:\",round((cm[0,0]+cm[1,1])/cm.sum(),3))\n",
"print(\"-----------------------------------\\n\")\n",
"print (\"DecisionTree accuracy score:\" , accuracy_score(y_test,predictions))\n",
"print (\"f1 score:\" , f1_score(y_test,predictions,average='micro'))\n",
"print (\"precision_score:\" , precision_score(y_test,predictions,average='micro'))\n",
"print (\"recall_score:\" , recall_score(y_test,predictions,average='micro'))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" precision recall f1-score support\n",
"\n",
" 0 1.00 1.00 1.00 3478\n",
" 1 0.99 0.99 0.99 1391\n",
" 2 0.99 0.99 0.99 1594\n",
" 3 0.99 0.99 0.99 1415\n",
"\n",
"avg / total 1.00 1.00 1.00 7878\n",
"\n",
"[[3478 0 0 0]\n",
" [ 0 1381 10 0]\n",
" [ 0 8 1581 5]\n",
" [ 0 0 7 1408]]\n",
"---------------------------------\n",
"\n",
"Accuracy of prediction: 0.617\n",
"RandomForest accuracy score: 0.9961919268849961\n",
"---------------------------------\n",
"\n",
"f1 score: 0.9961919268849961\n",
"precision_score: 0.9961919268849961\n",
"recall_score: 0.9961919268849961\n"
]
}
],
"source": [
"from sklearn.ensemble import RandomForestClassifier\n",
"from sklearn.metrics import classification_report\n",
"\n",
"rfc = RandomForestClassifier(n_estimators=600)\n",
"rfc.fit(X_train, y_train)\n",
"rfc_pred = rfc.predict(X_test)\n",
"cr = classification_report(y_test,predictions)\n",
"print(cr)\n",
"cm = confusion_matrix(y_test,rfc_pred)\n",
"print(cm)\n",
"\n",
"print(\"---------------------------------\\n\")\n",
"print (\"Accuracy of prediction:\",round((cm[0,0]+cm[1,1])/cm.sum(),3))\n",
"print (\"RandomForest accuracy score:\" , accuracy_score(y_test,rfc_pred))\n",
"print(\"---------------------------------\\n\")\n",
"print (\"f1 score:\" , f1_score(y_test,rfc_pred,average='micro'))\n",
"print (\"precision_score:\" , precision_score(y_test,rfc_pred,average='micro'))\n",
"print (\"recall_score:\" , recall_score(y_test,rfc_pred,average='micro'))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"KFold(n_splits=5, random_state=None, shuffle=False)\n",
"TRAIN: [ 3939 3940 3941 ... 19690 19691 19692] TEST: [ 0 1 2 ... 3936 3937 3938]\n",
"svm linear accuracy score: 0.9182533637979182\n",
"f1 score: 0.9182533637979181\n",
"precision_score: 0.9182533637979182\n",
"recall_score: 0.9182533637979182\n",
"runing time: 0:00:02.546188\n",
"\n",
"\n",
"\n",
"TRAIN: [ 0 1 2 ... 19690 19691 19692] TEST: [3939 3940 3941 ... 7875 7876 7877]\n",
"svm linear accuracy score: 0.968012185833968\n",
"f1 score: 0.968012185833968\n",
"precision_score: 0.968012185833968\n",
"recall_score: 0.968012185833968\n",
"runing time: 0:00:02.914205\n",
"\n",
"\n",
"\n",
"TRAIN: [ 0 1 2 ... 19690 19691 19692] TEST: [ 7878 7879 7880 ... 11814 11815 11816]\n",
"svm linear accuracy score: 0.6384869256156385\n",
"f1 score: 0.6384869256156385\n",
"precision_score: 0.6384869256156385\n",
"recall_score: 0.6384869256156385\n",
"runing time: 0:00:02.365734\n",
"\n",
"\n",
"\n",
"TRAIN: [ 0 1 2 ... 19690 19691 19692] TEST: [11817 11818 11819 ... 15752 15753 15754]\n",
"svm linear accuracy score: 0.9850177755205688\n",
"f1 score: 0.9850177755205688\n",
"precision_score: 0.9850177755205688\n",
"recall_score: 0.9850177755205688\n",
"runing time: 0:00:02.819487\n",
"\n",
"\n",
"\n",
"TRAIN: [ 0 1 2 ... 15752 15753 15754] TEST: [15755 15756 15757 ... 19690 19691 19692]\n",
"svm linear accuracy score: 1.0\n",
"f1 score: 1.0\n",
"precision_score: 1.0\n",
"recall_score: 1.0\n",
"runing time: 0:00:03.159911\n",
"\n",
"\n",
"\n"
]
}
],
"source": [
"from sklearn.model_selection import KFold\n",
"\n",
"X = train_features.values\n",
"y = train_labels.values\n",
"\n",
"kf = KFold(n_splits=5)\n",
"kf.get_n_splits(X)\n",
"\n",
"print(kf) \n",
"\n",
"for train_index, test_index in kf.split(X):\n",
" print(\"TRAIN:\", train_index, \"TEST:\", test_index)\n",
" X_train, X_test = X[train_index], X[test_index]\n",
" y_train, y_test = y[train_index], y[test_index]\n",
" \n",
" \n",
" from datetime import datetime\n",
" trarining_start_time = datetime.now()\n",
"\n",
" rfc = RandomForestClassifier(n_estimators=600)\n",
" rfc.fit(X_train, y_train)\n",
" rfc_pred = rfc.predict(X_test) \n",
" print (\"svm linear accuracy score:\" , accuracy_score(y_test,rfc_pred))\n",
" print (\"f1 score:\" , f1_score(y_test,rfc_pred,average='micro'))\n",
" print (\"precision_score:\" , precision_score(y_test,rfc_pred,average='micro'))\n",
" print (\"recall_score:\" , recall_score(y_test,rfc_pred,average='micro'))\n",
"\n",
" training_stop_time = datetime.now()\n",
"\n",
" print (\"runing time:\",(training_stop_time - trarining_start_time))\n",
" print(\"\\n\\n\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"KFold(n_splits=5, random_state=None, shuffle=False)\n",
"TRAIN: [ 3939 3940 3941 ... 19690 19691 19692] TEST: [ 0 1 2 ... 3936 3937 3938]\n",
"svm linear accuracy score: 0.9301853262249302\n",
"f1 score: 0.9301853262249302\n",
"precision_score: 0.9301853262249302\n",
"recall_score: 0.9301853262249302\n",
"runing time: 0:00:00.397934\n",
"\n",
"\n",
"\n",
"TRAIN: [ 0 1 2 ... 19690 19691 19692] TEST: [3939 3940 3941 ... 7875 7876 7877]\n",
"svm linear accuracy score: 0.9692815435389693\n",
"f1 score: 0.9692815435389693\n",
"precision_score: 0.9692815435389693\n",
"recall_score: 0.9692815435389693\n",
"runing time: 0:00:00.981406\n",
"\n",
"\n",
"\n",
"TRAIN: [ 0 1 2 ... 19690 19691 19692] TEST: [ 7878 7879 7880 ... 11814 11815 11816]\n",
"svm linear accuracy score: 0.6521959888296522\n",
"f1 score: 0.6521959888296522\n",
"precision_score: 0.6521959888296522\n",
"recall_score: 0.6521959888296522\n",
"runing time: 0:00:00.405946\n",
"\n",
"\n",
"\n",
"TRAIN: [ 0 1 2 ... 19690 19691 19692] TEST: [11817 11818 11819 ... 15752 15753 15754]\n",
"svm linear accuracy score: 0.9951752158456069\n",
"f1 score: 0.9951752158456069\n",
"precision_score: 0.9951752158456069\n",
"recall_score: 0.9951752158456069\n",
"runing time: 0:00:01.247622\n",
"\n",
"\n",
"\n",
"TRAIN: [ 0 1 2 ... 15752 15753 15754] TEST: [15755 15756 15757 ... 19690 19691 19692]\n",
"svm linear accuracy score: 1.0\n",
"f1 score: 1.0\n",
"precision_score: 1.0\n",
"recall_score: 1.0\n",
"runing time: 0:00:02.044532\n",
"\n",
"\n",
"\n"
]
}
],
"source": [
"from sklearn.model_selection import KFold\n",
"\n",
"X = train_features.values\n",
"y = train_labels.values\n",
"\n",
"kf = KFold(n_splits=5)\n",
"kf.get_n_splits(X)\n",
"\n",
"print(kf) \n",
"\n",
"for train_index, test_index in kf.split(X):\n",
" print(\"TRAIN:\", train_index, \"TEST:\", test_index)\n",
" X_train, X_test = X[train_index], X[test_index]\n",
" y_train, y_test = y[train_index], y[test_index]\n",
" \n",
" \n",
" from datetime import datetime\n",
" trarining_start_time = datetime.now()\n",
"\n",
" clf_svm_linear = SVC(kernel='linear', gamma=0.02, C=1)\n",
" clf_svm_linear = clf_svm_linear.fit(X_train, y_train)\n",
" #print(clf_svm_linear.predict(X_test))\n",
" pred = clf_svm_linear.predict(X_test)\n",
" print (\"svm linear accuracy score:\" , accuracy_score(y_test,pred))\n",
" print (\"f1 score:\" , f1_score(y_test,pred,average='micro'))\n",
" print (\"precision_score:\" , precision_score(y_test,pred,average='micro'))\n",
" print (\"recall_score:\" , recall_score(y_test,pred,average='micro'))\n",
"\n",
" training_stop_time = datetime.now()\n",
"\n",
" print (\"runing time:\",(training_stop_time - trarining_start_time))\n",
" print(\"\\n\\n\")"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"svm linear accuracy score: 0.9894643310484894\n",
"f1 score: 0.9894643310484894\n",
"precision_score: 0.9894643310484894\n",
"recall_score: 0.9894643310484894\n",
"runing clf_svm_linear time: 0:00:00.708116\n"
]
}
],
"source": [
"from datetime import datetime\n",
"trarining_start_time = datetime.now()\n",
"\n",
"X_train ,X_test,y_train,y_test = train_test_split(train_features,train_labels,test_size = 0.4, random_state = 0)\n",
"\n",
"#clf_svm_linear = SVC(kernel = 'linear',gamma=0.00001,C=0.01)\n",
"clf_svm_linear = SVC(kernel = 'linear',gamma=0.02,C=1)\n",
"clf_svm_linear = clf_svm_linear.fit(X_train, y_train)\n",
"pred = clf_svm_linear.predict(X_test)\n",
"#print (\"svm linear accuracy score:\" , accuracy_score(y_test,pred))\n",
"#print (\"f1 score:\" , f1_score(y_test,pred,average='micro'))\n",
"#print (\"precision_score:\" , precision_score(y_test,pred,average=None))\n",
"#print (\"recall_score :\" , recall_score(y_test,pred,average=None))\n",
"print (\"svm linear accuracy score:\" , accuracy_score(y_test,pred))\n",
"print (\"f1 score:\" , f1_score(y_test,pred,average='micro'))\n",
"print (\"precision_score:\" , precision_score(y_test,pred,average='micro'))\n",
"print (\"recall_score:\" , recall_score(y_test,pred,average='micro'))\n",
"\n",
"training_stop_time = datetime.now()\n",
"print (\"runing clf_svm_linear time:\",(training_stop_time - trarining_start_time))"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'sklearn_porter'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-10-74e6bf229c70>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0msklearn_porter\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mPorter\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mporter_clf_svm_liner_14items\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mPorter\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mclf_svm_linear\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlanguage\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'c'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mexport\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;31m#print(porter_clf_svm_liner_ph)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'sklearn_porter'"
]
}
],
"source": [
"from sklearn_porter import Porter\n",
"\n",
"porter_clf_svm_liner_14items = Porter(clf_svm_linear, language='c').export()\n",
"\n",
"#print(porter_clf_svm_liner_ph)\n",
"f = open(\"new14modal/svm_bil.c\",'wb')\n",
"f.write(porter_clf_svm_liner_14items.encode())\n",
"f.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from sklearn_porter import Porter\n",
"\n",
"porter_clf_svm_liner_14items = Porter(clf_svm_linear, language='js').export()\n",
"\n",
"#print(porter_clf_svm_linear)\n",
"f = open(\"new14modal/svm_bil.js\",'wb')\n",
"#f = open(\"clf_svm_linear_125100_low_feature_data.txt\",'wb')\n",
"f.write(porter_clf_svm_liner_14items.encode())\n",
"f.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from sklearn_porter import Porter\n",
"\n",
"porter_clf_svm_liner_14items = Porter(rfc, language='c').export()\n",
"\n",
"#print(porter_clf_svm_liner_ph)\n",
"f = open(\"new14modal/rfc_bil.c\",'wb')\n",
"f.write(porter_clf_svm_liner_14items.encode())\n",
"f.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from sklearn_porter import Porter\n",
"\n",
"porter_clf_svm_liner_14items = Porter(rfc, language='js').export()\n",
"\n",
"#print(porter_clf_svm_linear)\n",
"f = open(\"new14modal/rfc_bil.js\",'wb')\n",
"#f = open(\"clf_svm_linear_125100_low_feature_data.txt\",'wb')\n",
"f.write(porter_clf_svm_liner_14items.encode())\n",
"f.close()"
]
}
],
"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.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}