Skip to content
Snippets Groups Projects
Commit b7ddc99b authored by Baptiste Bauvin's avatar Baptiste Bauvin
Browse files

Starting to integrate example ids

parent de459cd2
Branches
Tags
No related merge requests found
......@@ -16,7 +16,7 @@ from . import monoview_utils
from .analyze_result import execute
# Import own modules
from .. import monoview_classifiers
from ..utils.dataset import get_value, extract_subset, Dataset
from ..utils.dataset import extract_subset, Dataset
from ..utils import hyper_parameter_search
# Author-Info
......
......@@ -11,7 +11,6 @@ from .multiview_utils import MultiviewResult
from . import analyze_results
from .. import multiview_classifiers
from ..utils import hyper_parameter_search
from ..utils.dataset import get_shape
# Author-Info
__author__ = "Baptiste Bauvin"
......
......@@ -383,7 +383,8 @@ def iterCmap(statsIter):
def publish2Dplot(data, classifiers_names, nbClassifiers, nbExamples, nbCopies,
fileName, minSize=10,
width_denominator=2.0, height_denominator=20.0, stats_iter=1):
width_denominator=2.0, height_denominator=20.0, stats_iter=1,
use_plotly=False, example_ids=None):
r"""Used to generate a 2D plot of the errors.
Parameters
......@@ -431,6 +432,20 @@ def publish2Dplot(data, classifiers_names, nbClassifiers, nbExamples, nbCopies,
fig.savefig(fileName + "error_analysis_2D.png", bbox_inches="tight", transparent=True)
plt.close()
### The following part is used to generate an interactive graph.
if use_plotly:
import plotly
fig = plotly.graph_objs.go.Figure(data=plotly.graph_objs.go.Heatmap(
x=classifiers_names,
y=example_ids,
z=data,
colorscale="Greys",
))
fig.update_layout(
xaxis={"showgrid": False, "showticklabels": False, "ticks": ''},
yaxis={"showgrid": False, "showticklabels": False, "ticks": ''})
plotly.offline.plot(fig, filename='essai.html', auto_open=False)
del fig
def publishErrorsBarPlot(error_on_examples, nbClassifiers, nbExamples, fileName):
......
......@@ -424,10 +424,6 @@ class Dataset():
return selected_label_names
def datasets_already_exist(pathF, name, nbCores):
"""Used to check if it's necessary to copy datasets"""
allDatasetExist = True
......@@ -437,51 +433,6 @@ def datasets_already_exist(pathF, name, nbCores):
pathF + name + str(coreIndex) + ".hdf5")
return allDatasetExist
# def get_v(dataset, view_index, used_indices=None):
# # """Used to extract a view as a numpy array or a sparse mat from the HDF5 dataset"""
# # if used_indices is None:
# # used_indices = range(dataset.get("Metadata").attrs["datasetLength"])
# # if type(used_indices) is int:
# # return dataset.get("View" + str(view_index))[used_indices, :]
# # else:
# # used_indices = np.array(used_indices)
# # sorted_indices = np.argsort(used_indices)
# # used_indices = used_indices[sorted_indices]
# #
# # if not dataset.get("View" + str(view_index)).attrs["sparse"]:
# # return dataset.get("View" + str(view_index))[used_indices, :][
# # np.argsort(sorted_indices), :]
# # else:
# # sparse_mat = sparse.csr_matrix(
# # (dataset.get("View" + str(view_index)).get("data").value,
# # dataset.get("View" + str(view_index)).get("indices").value,
# # dataset.get("View" + str(view_index)).get("indptr").value),
# # shape=dataset.get("View" + str(view_index)).attrs["shape"])[
# # used_indices, :][
# # np.argsort(sorted_indices), :]
# #
# # return sparse_mat
def get_shape(dataset, view_index):
"""Used to get the dataset shape even if it's sparse"""
if not dataset.get("View" + str(view_index)).attrs["sparse"]:
return dataset.get("View" + str(view_index)).shape
else:
return dataset.get("View" + str(view_index)).attrs["shape"]
def get_value(dataset):
"""Used to get the value of a view in the HDF5 dataset even if it sparse"""
if not dataset.attrs["sparse"]:
return dataset[()]
else:
sparse_mat = sparse.csr_matrix((dataset.get("data")[()],
dataset.get("indices")[()],
dataset.get("indptr")[()]),
shape=dataset.attrs["shape"])
return sparse_mat
def extract_subset(matrix, used_indices):
"""Used to extract a subset of a matrix even if it's sparse"""
......@@ -590,10 +541,3 @@ def input_(timeout=15):
return sys.stdin.readline().strip()
else:
return "y"
def get_monoview_shared(path, name, view_name, labels_names, classification_indices):
"""ATM is not used with shared memory, but soon :)"""
hdf5_dataset_file = h5py.File(path + name + ".hdf5", "w")
X = hdf5_dataset_file.get(view_name)[()]
y = hdf5_dataset_file.get("Labels")[()]
return X, y
......@@ -4,10 +4,8 @@ import logging
import h5py
import numpy as np
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.utils.validation import check_array
from ..utils.dataset import Dataset, copy_hdf5
from ..utils.dataset import Dataset
# Author-Info
__author__ = "Baptiste Bauvin"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment