Update notebooks

This commit is contained in:
Florent Guiotte 2018-09-21 15:51:04 +02:00
parent e84027a043
commit 04ea5bdf6c
4 changed files with 113 additions and 16 deletions

View File

@ -17,12 +17,6 @@
"from sklearn import metrics\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"\n",
"# Triskele\n",
"import sys\n",
"from pathlib import Path\n",
"triskele_path = Path('../triskele/python')\n",
"sys.path.append(str(triskele_path.resolve()))\n",
"import triskele\n",
"\n",
"figsize = np.array((16, 9))"
@ -41,9 +35,9 @@
"metadata": {},
"outputs": [],
"source": [
"df_dfc_lbl = pd.read_csv('../labels.csv')\n",
"df_meta_idx = pd.read_csv('../metaclass_indexes.csv')\n",
"df_meta_lbl = pd.read_csv('../metaclass_labels.csv')\n",
"df_dfc_lbl = pd.read_csv('../../minigrida/Data/ground_truth/labels.csv')\n",
"df_meta_idx = pd.read_csv('../../minigrida/Data/ground_truth/jurse_meta_idx.csv')\n",
"df_meta_lbl = pd.read_csv('../../minigrida/Data/ground_truth/jurse_meta_lbl.csv')\n",
"\n",
"df_dfc_lbl.merge(df_meta_idx).merge(df_meta_lbl)"
]
@ -71,7 +65,7 @@
"outputs": [],
"source": [
"gt = triskele.read('../Data/ground_truth/2018_IEEE_GRSS_DFC_GT_TR.tif')\n",
"pred = triskele.read('../Res/tmppred_8_10pleaf_3cv.tif')"
"pred = triskele.read('../../minigrida/Enrichment/Results/tellus_fourhth_95bfcf.tif')"
]
},
{
@ -111,7 +105,7 @@
"fig, (ax_gt, ax_pred) = plt.subplots(2, figsize=figsize * 2)\n",
"ax_gt.imshow(meta_idx[gt])\n",
"ax_gt.set_title('Ground Truth')\n",
"ax_pred.imshow(meta_idx[pred])\n",
"ax_pred.imshow(pred)\n",
"ax_pred.set_title('Prediction')\n",
"plt.show()"
]
@ -212,17 +206,32 @@
"outputs": [],
"source": [
"f = np.nonzero(pred)\n",
"m_pred_s = meta_idx[pred_s]\n",
"m_pred_s = pred_s\n",
"m_gt_s = meta_idx[gt_s]\n",
"\n",
"ct = pd.crosstab(m_gt_s, m_pred_s,\n",
" rownames=['Prediction'], colnames=['Reference'],\n",
" margins=True, margins_name='Total',\n",
" normalize=False # all, index, columns\n",
" normalize=False # all, index, columns, False\n",
" )\n",
"ct"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lbl = df_meta_lbl['metaclass_label'][ct.columns[:-1]].tolist()\n",
"lbl.append('Total')\n",
"ct.columns = lbl\n",
"ct.columns.name = 'Reference'\n",
"ct.index = lbl\n",
"ct.index.name = 'Reference'\n",
"ct"
]
},
{
"cell_type": "markdown",
"metadata": {},
@ -273,6 +282,13 @@
"metrics.precision_recall_fscore_support(m_gt_s, m_pred_s)\n",
"print(metrics.classification_report(m_gt_s, m_pred_s))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {

View File

@ -160,7 +160,7 @@
"metadata": {},
"outputs": [],
"source": [
"count = 5\n",
"count = 4\n",
"\n",
"step = int(gt.shape[0] / count)\n",
"\n",

View File

@ -53,7 +53,12 @@
"metadata": {},
"outputs": [],
"source": [
"raster = ra.rasterize_cache('intensity', C1, 1., 'nearest', False, cache_dir='../Res/enrichment_rasters')"
"raster = ra.rasterize_cache('num_returns', C1, .5, 'nearest', False, cache_dir='../Res/enrichment_rasters')\n",
"\n",
"plt.figure(figsize=figsize)\n",
"plt.imshow(raster, origin='upper')\n",
"plt.show()\n",
"plt.imsave('../Res/raster_validation.png', raster)"
]
},
{

View File

@ -29,7 +29,7 @@
"metadata": {},
"outputs": [],
"source": [
"n = 5; d = 0"
"n = 1; d = 0"
]
},
{
@ -173,6 +173,82 @@
"\n",
"t_dsp.run()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Split cross val"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"d = 0\n",
"s = 2\n",
"n = 3\n",
"\n",
"\n",
"step = int(descriptors.shape[d] / n)\n",
"size = descriptors.shape[d]\n",
"cfilter = (np.arange(size) - step * s) % size < step\n",
"\n",
"test_filter = np.zeros_like(descriptors[:,:,0], dtype=np.bool)\n",
"view = np.moveaxis(test_filter, d, 0)\n",
"view[cfilter] = True\n",
"\n",
"plt.imshow(test_filter)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"descriptors[test_filter].shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"descriptors.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"f = np.zeros_like(test_filter, dtype=np.bool)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"test_filter |= f\n",
"test_filter"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"test_filter"
]
}
],
"metadata": {