forked from renebidart/breakHis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rene bidart
committed
Nov 21, 2017
1 parent
78af396
commit 5d904ec
Showing
36 changed files
with
858 additions
and
499 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
**/.pyc | ||
**/.ipynb_checkpoints | ||
.ipynb_checkpoints | ||
**/.DS_Store | ||
**/.DS_Store? | ||
**/.h5 | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Try CNN with input as 7x7, and then visualize these . filters. Make sure to scale it to 1-255" | ||
] | ||
} | ||
], | ||
"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.5.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Cross Validation for models on VGG features \n", | ||
"* Using the folds defined in http://ieeexplore.ieee.org.proxy.lib.uwaterloo.ca/stamp/stamp.jsp?arnumber=7312934\n", | ||
"* For binary and and 8 class\n", | ||
"* Using best hyperparameters found in VGG_features_hyperparameter search\n", | ||
"* Training is done using the full training set, with no validation set.\n", | ||
"* This was re-run on a newly created dataset compared to the hyperparameter search, because it got overly high accuracy for fold 1." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"The autoreload extension is already loaded. To reload it, use:\n", | ||
" %reload_ext autoreload\n", | ||
"/home/rbbidart/breakHis/src\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import os\n", | ||
"import sys\n", | ||
"import glob\n", | ||
"import random\n", | ||
"import numpy as np\n", | ||
"import pandas as pd\n", | ||
"from PIL import Image\n", | ||
"import matplotlib.pyplot as plt \n", | ||
"from matplotlib.pyplot import imshow\n", | ||
"from IPython.display import display, HTML\n", | ||
"from sklearn.metrics import accuracy_score\n", | ||
"% matplotlib inline\n", | ||
"\n", | ||
"\n", | ||
"# Import modules every time you run code imported using %aimport\n", | ||
"%load_ext autoreload\n", | ||
"%autoreload 1\n", | ||
"\n", | ||
"# Add the src directory for functions\n", | ||
"src_dir = os.path.join(os.path.dirname(os.path.dirname(os.getcwd())), 'src')\n", | ||
"print(src_dir)\n", | ||
"sys.path.append(src_dir)\n", | ||
"\n", | ||
"# import my functions:\n", | ||
"%aimport models\n", | ||
"from models import*\n", | ||
"%aimport functions\n", | ||
"from functions import*\n", | ||
"\n", | ||
"# Base Directory where data is stored\n", | ||
"base_data_dir = '/home/rbbidart/project/rbbidart/breakHis/'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Logistic Regression\n", | ||
"* Binary C=.1\n", | ||
"* 8-class C=1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Fold 0\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from sklearn.linear_model import LogisticRegression\n", | ||
"\n", | ||
"model_2 = LogisticRegression(C=.1)\n", | ||
"model_8 = LogisticRegression(C=1)\n", | ||
"cv_features(model_2, model_8, base_data_dir)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Random Forest\n", | ||
"* Binary 160, 3\n", | ||
"* 8-class 160, 3" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Fold 0\n", | ||
"Fold 1\n", | ||
"Fold 2\n", | ||
"Fold 3\n", | ||
"Fold 4\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from sklearn.ensemble import RandomForestClassifier\n", | ||
"\n", | ||
"model_2 = RandomForestClassifier(n_estimators=160, min_samples_split=3)\n", | ||
"model_8 = RandomForestClassifier(n_estimators=160, min_samples_split=3)\n", | ||
"cv_features(model_2, model_8, base_data_dir)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## XGBoost\n", | ||
"* Binary: n_estimators=200\tmax_depth=8\tlearning_rate=0.3\treg_lambda=2\n", | ||
"* 8-class: n_estimators=250 max_depth=9 learning_rate=0.3\treg_lambda=2 (guess)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from xgboost import XGBClassifier\n", | ||
"\n", | ||
"model_2 = XGBClassifier(n_estimators=200, max_depth=8, learning_rate=0.3, reg_lambda=2)\n", | ||
"model_8 = XGBClassifier(n_estimators=200, max_depth=8, learning_rate=0.3, reg_lambda=2)\n", | ||
"cv_features(model_2, model_8, base_data_dir)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## KNN\n", | ||
"* 9 neighbours" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from sklearn.neighbors import KNeighborsClassifier\n", | ||
"\n", | ||
"model_2 = KNeighborsClassifier(n_neighbors=9)\n", | ||
"model_8 = KNeighborsClassifier(n_neighbors=9)\n", | ||
"cv_features(model_2, model_8, base_data_dir)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"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.5.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.