Commit aadc4d27 authored by lucas_miranda's avatar lucas_miranda
Browse files

Added notebook for dataset and model evaluation

parent cbbf9380
Pipeline #97696 passed with stages
in 17 minutes and 6 seconds
%% Cell type:code id: tags:
``` python
%load_ext autoreload
%autoreload 2
import os
os.chdir(os.path.dirname("../"))
```
%% Cell type:markdown id: tags:
### Latent space sampling
# deepOF data exploration
%% Cell type:markdown id: tags:
Given a dataset and a trained model, this notebook allows the user to sample from the latent space distributions and generate video clips showcasing the results
Given a dataset, this notebook allows the user to
* Load and process the dataset using deepof.data
* Visualize data quality with interactive plots
* Visualize training instances as multi-timepoint scatter plots with interactive configurations
* Visualize training instances as video clips with interactive configurations
%% Cell type:code id: tags:
``` python
import os
os.chdir(os.path.dirname("../"))
import warnings
warnings.filterwarnings("ignore")
```
%% Cell type:code id: tags:
``` python
import cv2
import deepof.data
import deepof.models
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import deepof.utils
import numpy as np
import pandas as pd
import re
import seaborn as sns
from sklearn.preprocessing import StandardScaler, MinMaxScaler
import tensorflow as tf
import tqdm.notebook as tqdm
from datetime import datetime
from sklearn.manifold import TSNE
from sklearn.decomposition import PCA
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
import umap
from ipywidgets import interact
from IPython import display
from matplotlib.animation import FuncAnimation
import matplotlib.pyplot as plt
import seaborn as sns
```
%% Cell type:markdown id: tags:
### 1. Define and run project
%% Cell type:code id: tags:
``` python
path = os.path.join("..", "..", "Desktop", "deepoftesttemp")
trained_network = os.path.join("..", "..", "Desktop")
```
%% Cell type:code id: tags:
``` python
%%time
# Use deepof to load a project
proj = deepof.data.project(
path=path,
smooth_alpha=0.99,
exclude_bodyparts=["Tail_1", "Tail_2", "Tail_tip", "Tail_base"],
path="../../Desktop/deepoftesttemp/",
arena_dims=[380],
)
```
%% Output
CPU times: user 394 ms, sys: 34.1 ms, total: 428 ms
Wall time: 351 ms
%% Cell type:code id: tags:
``` python
%%time
proj = proj.run(verbose=True)
print(proj)
arena_detection="rule-based",
interpolate_outliers=True,
).run()
```
%% Output
Loading trajectories...
Smoothing trajectories...
Interpolating outliers...
Iterative imputation of ocluded bodyparts...
Computing distances...
Computing angles...
Done!
deepof analysis of 2 videos
CPU times: user 2.89 s, sys: 196 ms, total: 3.09 s
Wall time: 887 ms
%% Cell type:markdown id: tags:
### 2. Inspect dataset quality
%% Cell type:code id: tags:
``` python
all_quality = pd.concat([tab for tab in proj.get_quality().values()])
```
%% Cell type:code id: tags:
``` python
all_quality.boxplot(rot=45)
plt.ylim(0.99985, 1.00001)
plt.show()
```
%% Output