Bored of Jupyter? Let’s Explore Marimo!

Sanjjushri Varshini R
featurepreneur
Published in
3 min readJun 21, 2024

Set up Marimo and Create your Data Science Project!

Marimo is a cutting-edge Python notebook designed to enhance your data science workflow with advanced features and seamless integration. Experience efficient data visualization, machine learning, and interactive coding all in one place!

Installation

pip install marimo==0.6.19

Lauch Marimo:

Launch and then create a notebook:

marimo edit

Create or Edit a Single

marimo edit your_notebook.py

Markdown:

import marimo as mo
mo.md("# Write your text here!")

Perform the Following data analytics so that you can explore the features of Marimo:

# Import Libraries
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, classification_report, confusion_matrix
# Load Dataset
iris = sns.load_dataset('iris')

# Display the Data
iris.head()
# Visualize the dataset
sns.pairplot(iris_df, hue='species', markers=["o", "s", "D"])
plt.suptitle('Pairplot of Iris Features', y=1.02)
plt.show()
# Correlation Heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(iris.corr(), annot=True, cmap='coolwarm')
plt.show()
# Data Preparation
X = iris.drop('species', axis=1)
y = iris['species']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
# Train Logistic Regression Model
model = LogisticRegression(max_iter=200)
model.fit(X_train, y_train)
# Make Predictions
y_pred = model.predict(X_test)
# Evaluate the model
accuracy = accuracy_score(y_test, y_pred)
print(f'Accuracy: {accuracy:.2f}')
print('Classification Report:')
print(classification_report(y_test, y_pred))
# Model Evaluation
accuracy = accuracy_score(y_test, y_pred)
report = classification_report(y_test, y_pred)
conf_matrix = confusion_matrix(y_test, y_pred)

print(f"Accuracy: {accuracy}")
print(f"Classification Report:\n{report}")
print(f"Confusion Matrix:\n{conf_matrix}")
# Confusion Matrix Visualization
plt.figure(figsize=(8, 6))
sns.heatmap(conf_matrix, annot=True, fmt='d', cmap='Blues', xticklabels=iris['species'].unique(), yticklabels=iris['species'].unique())
plt.xlabel('Predicted')
plt.ylabel('Actual')
plt.title('Confusion Matrix')
plt.show()

Sidebar Features:

Now open the side bar and explore marimo’s feature:

  1. Files:

2. Variables used in Marimo’s notebook will be displayed with the declared cell number and used by cell number

3. Datasources used will be displayed here with the chart and important values of the data

4. Dependencies can be viewed in Mini Map, Vertical Tree, Horizontal Tree

5. Outline: All the markdown will be viewed here

6. Documentation: In the documentation section you can hover on the library used, to view the documentation of it.

7. Logs: All the stdout and stderr logs will appear here.

8. Snippets:

If you liked Marimo’s features, you definitely need to try it out.

GitHub: https://github.com/Sanjjushri/marimo-tutorial

--

--