.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples\plotly\plot_main07_parallel_v2.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_plotly_plot_main07_parallel_v2.py: 07b. Dengue features (parallel) =================================== This Python script uses the pandas and Plotly libraries to create an interactive parallel coordinates plot. This type of plot is excellent for visualizing and exploring relationships in datasets with many variables (high-dimensional data). Each vertical line represents a different variable (a column from the dataset), and each colored line that snakes across the plot represents a single data point (a row from the dataset). .. GENERATED FROM PYTHON SOURCE LINES 13-122 .. raw:: html :file: images\sphx_glr_plot_main07_parallel_v2_001.html .. rst-class:: sphx-glr-script-out Out: .. code-block:: none C:\Users\kelda\Desktop\repositories\github\python-spare-code\main\examples\plotly\plot_main07_parallel_v2.py:63: DtypeWarning: Columns (3,5,7,9,12,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,33,34,37,40,41,42,43,44,48,49,50,51,52,53,54,55,56,57,61,62,64,66,67,68,69,70,73,74,75,77,79,80,81,82,83,84,85,87,88,89,90,95,96,97,99,101,102,103,104,107,108,110,113,115,117,119,120,121,122,125,126,127,129,130,132,133,134,135,136,137,143,152,153,155,156,157,159,161,162,163,164,165,166,167,168,174,175,176,177,178,182,184,193,197,198,199,200,202,203,207,208,209,213,214,215,218,219,220,221,224,225,226,227,229,232,233,234,235,236,237,238,240,241,242,244,247,250,253,254,255,259,261,262,263,264,265,266,267,268,270,271,272,273,274,275,276,277,278,279,280,281,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,301,302,303,304,305,307,308,309,310,311,312,313,314,315,317,318,319,320,324,325,326,327,328,330,333,334,335,336,337,338,339,340,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,381,382,384,385,386,391,392,393,395,398,403,404,407,408,409,410,411,412,413,414,415,416,417,418,419,424) have mixed types. Specify dtype option on import or set low_memory=False. | .. code-block:: default :lineno-start: 14 import plotly.graph_objects as go import numpy as np import pandas as pd from pandas.api.types import is_string_dtype from pandas.api.types import is_numeric_dtype from plotly.io import show try: __file__ TERMINAL = True except: TERMINAL = False def load_gridsearch_sklearn_iris(): """This method...""" # Define datapath FILEPATH = './data/sklearn-gridsearch/ls2d-iris.csv' # Load data df = pd.read_csv(FILEPATH) # Columns columns = [ ('mean_train_spearman', 'Spearman'), ('mean_train_pearson', 'Pearson'), ('param_sae__max_epochs', 'Max Epochs'), ('param_sae__lr', 'Learning Rate'), ('mean_train_procrustes', 'Procrustes'), ('mean_train_calinski_target', 'Calinski'), ('mean_train_davies_b_target', 'Davies'), #('param_sae__module__layers', 'Layers') ] # Line line = dict(color=df.mean_train_calinski_target, colorscale='Electric', showscale=True, cmin=df.mean_train_calinski_target.min(), cmax=df.mean_train_calinski_target.max()) # Return return df, line, columns def load_raw_dengue(): """This method...""" # Define datapath FILEPATH = '../../datasets/dengue-htd-dataset/combined.csv' # Load data df = pd.read_csv(FILEPATH) # Columns columns = [ ('age', 'Age'), ('body_temperature', 'Body Temperature'), ('weight', 'Weight'), ('plt', 'Platelets'), ('haematocrit_percent', 'Haematocrit') ] # Line line = dict(color=df.haematocrit_percent, colorscale='Electric', showscale=True, cmin=df.haematocrit_percent.min(), cmax=df.haematocrit_percent.max()) # Return return df, line, columns def create_dimension(s): """This method creates the dimesions. Dimension: numeric dict(range = [32000,227900], constraintrange = [100000,150000], label = "Block Height", values = df['blockHeight']) Dimension: enumerated dict(tickvals = [0,0.5,1,2,3], ticktext = ['A','AB','B','Y','Z'], label = 'Cyclinder Material', values = df['cycMaterial'], visible = True) """ if is_numeric_dtype(s): return dict( range=[s.min(), s.max()], constraintrange=[s.min(), s.max()], label=s.name, values=s) if is_string_dtype(s): s = s.apply(str) return dict(tickvals=np.arange(s.nunique()), ticktext=sorted(s.unique()), label=s.name, values=s) # Load data df, line, columns = load_raw_dengue() #df, columns = load_gridsearch_sklearn_iris() # Show fig = go.Figure(data= go.Parcoords(line=line, dimensions=[create_dimension(df[name]) for name, label in columns] )) # Show show(fig) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 6.099 seconds) .. _sphx_glr_download__examples_plotly_plot_main07_parallel_v2.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_main07_parallel_v2.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_main07_parallel_v2.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_