"""
#Newly Developed System for Acetamiprid Residue Screening in the Lettuce Samples Based on a #Bioelectric Cell Biosensor

Authors:
Apostolou, T.; Loizou, K.; Hadjilouka, A.; Inglezakis, A.; Kintzios, S. Newly Developed System for Acetamiprid Residue Screening in the Lettuce Samples Based on a Bioelectric Cell Biosensor. Biosensors 2020, 10, 8. Biosensors 2020, 10(2), 8; https://doi.org/10.3390/bios10020008

Population growth and increased production demands on fruit and vegetables have driven agricultural production to new heights. Nevertheless, agriculture remains one of the least optimized industries, with laboratory tests that take days to provide a clear result on the chemical level of produce. To address this problem, the authors developed a tailor-made solution for the industry that can allow multiple field tests on key pesticides, based on a bioelectric cell biosensor and the measurement of the cell membrane potential changes, according to the principle of the Bioelectric Recognition Assay (BERA).https://www.mdpi.com/2079-6374/10/2/8
"""
"""
![](https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcRVhK7sYVHEOjcj9f3KlUEltIXMssSc0b_SMA&usqp=CAU)prezi.com
"""
"""
#Listeria

Listeria is a genus of bacteria that acts as an intracellular parasite in mammals. Until 1992, 10 species were known, each containing two subspecies. By 2019, 20 species had been identified. The genus received its current name, after the British pioneer of sterile surgery Joseph Lister, in 1940. Listeria species are Gram-positive, rod-shaped, and facultatively anaerobic, and do not produce endospores. The major human pathogen in the genus Listeria is L. monocytogenes. It is usually the causative agent of the relatively rare bacterial disease listeriosis, an infection caused by eating food contaminated with the bacteria.https://en.wikipedia.org/wiki/Listeria
"""
"""
#A bacteriophage endolysin-based electrochemical impedance biosensor for the rapid detection of Listeria cells

Authors: Mona Tolba,   Minhaz Uddin Ahmed,   Chaker Tlili,   Fritz Eichenseher,   Martin J. Loessner  and  Mohammed Zourob

![](https://pubs.rsc.org/en/Image/Get?imageInfo.ImageType=GA&imageInfo.ImageIdentifier.ManuscriptID=C2AN35988J&imageInfo.ImageIdentifier.Year=2012)https://pubs.rsc.org/en/content/articlelanding/2012/an/c2an35988j#!divAbstract
"""
# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load

import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import plotly.express as px
import seaborn as sns
import plotly.graph_objects as go
import plotly.offline as py
import matplotlib.pyplot as plt
import warnings
from pandas_profiling import ProfileReport 
from pycaret.regression import *

# Input data files are available in the read-only "../input/" directory
# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory

import os
for dirname, _, filenames in os.walk('/kaggle/input'):
    for filename in filenames:
        print(os.path.join(dirname, filename))

# You can write up to 5GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using "Save & Run All" 
# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session
df = pd.read_csv('../input/carbonelectrodesmilkbiosensors/iMicroq carbon magenta 8x/Listeria/G19 104 (magenta carbon)_1018.csv', encoding='ISO-8859-2')
df.head()
from colorama import Fore, Style

def count(string: str, color=Fore.RED):
    """
    Saves some work 
    """
    print(color+string+Style.RESET_ALL)
def statistics(dataframe, column):
    count(f"The Average value in {column} is: {dataframe[column].mean():.2f}", Fore.RED)
    count(f"The Maximum value in {column} is: {dataframe[column].max()}", Fore.BLUE)
    count(f"The Minimum value in {column} is: {dataframe[column].min()}", Fore.YELLOW)
    count(f"The 25th Quantile of {column} is: {dataframe[column].quantile(0.25)}", Fore.GREEN)
    count(f"The 50th Quantile of {column} is: {dataframe[column].quantile(0.50)}", Fore.CYAN)
    count(f"The 75th Quantile of {column} is: {dataframe[column].quantile(0.75)}", Fore.MAGENTA)
# Print Offset Column Statistics
statistics(df, '0.0442')
# Let's plot the 0.0442 column too
plt.style.use("classic")
sns.distplot(df['0.0442'], color='blue')
plt.title(f"0.0442 Distribution [\u03BC : {df['0.0442'].mean():.2f} conditions | \u03C3 : {df['0.0442'].std():.2f} conditions]")
plt.xlabel("0.0442")
plt.ylabel("Count")
plt.show()
# Print Offset Column Statistics
statistics(df, '-0.0197')
# Let's plot the 0.0442 column too
plt.style.use("classic")
sns.distplot(df['-0.0197'], color='red')
plt.title(f"-0.0197 Distribution [\u03BC : {df['-0.0197'].mean():.2f} conditions | \u03C3 : {df['-0.0197'].std():.2f} conditions]")
plt.xlabel("-0.0197")
plt.ylabel("Count")
plt.show()
corr = df.corr()
corr.style.background_gradient(cmap = 'coolwarm')
import matplotlib.gridspec as gridspec
from scipy.stats import skew
from sklearn.preprocessing import RobustScaler,MinMaxScaler
from scipy import stats
import matplotlib.style as style
style.use('seaborn-colorblind')
def plotting_3_chart(df, feature): 
    ## Creating a customized chart. and giving in figsize and everything. 
    fig = plt.figure(constrained_layout=True, figsize=(10,6))
    ## crea,ting a grid of 3 cols and 3 rows. 
    grid = gridspec.GridSpec(ncols=3, nrows=3, figure=fig)
    #gs = fig3.add_gridspec(3, 3)

    ## Customizing the histogram grid. 
    ax1 = fig.add_subplot(grid[0, :2])
    ## Set the title. 
    ax1.set_title('Histogram')
    ## plot the histogram. 
    sns.distplot(df.loc[:,feature], norm_hist=True, ax = ax1)

    # customizing the QQ_plot. 
    ax2 = fig.add_subplot(grid[1, :2])
    ## Set the title. 
    ax2.set_title('QQ_plot')
    ## Plotting the QQ_Plot. 
    stats.probplot(df.loc[:,feature], plot = ax2)

    ## Customizing the Box Plot. 
    ax3 = fig.add_subplot(grid[:, 2])
    ## Set title. 
    ax3.set_title('Box Plot')
    ## Plotting the box plot. 
    sns.boxplot(df.loc[:,feature], orient='v', ax = ax3 );
 

print('Skewness: '+ str(df['0.0393'].skew())) 
print("Kurtosis: " + str(df['0.0393'].kurt()))
plotting_3_chart(df, '0.0393')
#Code from Gabriel Preda
#plt.style.use('dark_background')
def plot_count(feature, title, df, size=1):
    f, ax = plt.subplots(1,1, figsize=(4*size,4))
    total = float(len(df))
    g = sns.countplot(df[feature], order = df[feature].value_counts().index[:20], palette='Blues')
    g.set_title("Number and percentage of {}".format(title))
    if(size > 2):
        plt.xticks(rotation=90, size=8)
    for p in ax.patches:
        height = p.get_height()
        ax.text(p.get_x()+p.get_width()/2.,
                height + 3,
                '{:1.2f}%'.format(100*height/total),
                ha="center") 
    plt.show()
plot_count("0.0393", "0.0393", df,4)
"""
#AutoViz: A New Tool for Automated Visualization, Written on December 28th, 2019 by Dan Roth.

It is not hard to see how helpful automated visualization can be. Within moments, the library is capable of generating highly informational plots and provides many pathways of potential expansion for a data scientist's modeling or analysis pipeline. AutoViz is meant to be integrated within a systematic iterative process. Exploratory data analysis (EDA) can be effectively initiated with AutoViz; features can be selected based on the tool's analysis and then the data can be repeatedly processed for automatic visualization. Once strong visualizations are generated, a data scientist can now jump into modeling or communicating the data with a well informed analysis. It is surprising that automated visualization options are so sparse given its many conceivable uses as an objective and practical tool, but AutoViz thankfully fulfills this role to great effect. Now let's get some visualizations going!https://danrothdatascience.github.io/datascience/autoviz.html
"""
!pip install autoviz

from autoviz.AutoViz_Class import AutoViz_Class
AV = AutoViz_Class()
df = AV.AutoViz(filename="",sep=',', depVar='0.0442', dfte=df, header=0, verbose=2, 
                 lowess=False, chart_format='svg', max_rows_analyzed=150000, max_cols_analyzed=30)
"""
#Reference
 https://github.com/DanRothDataScience/autoviz_test/blob/master/AutoViz_test.ipynb
https://www.kaggle.com/nareshbhat/data-visualization-in-just-a-single-line-of-
"""
#Code by Olga Belitskaya https://www.kaggle.com/olgabelitskaya/sequential-data/comments
from IPython.display import display,HTML
c1,c2,f1,f2,fs1,fs2=\
'#2B3A67','#42a7f5','Akronim','Smokum',30,15
def dhtml(string,fontcolor=c1,font=f1,fontsize=fs1):
    display(HTML("""<style>
    @import 'https://fonts.googleapis.com/css?family="""\
    +font+"""&effect=3d-float';</style>
    <h1 class='font-effect-3d-float' style='font-family:"""+\
    font+"""; color:"""+fontcolor+"""; font-size:"""+\
    str(fontsize)+"""px;'>%s</h1>"""%string))
    
    
dhtml('Programming is more than an important practical art. It is also a gigantic undertaking in the foundations of knowledge, Grace Hopper quote' )