Skip to content

Instantly share code, notes, and snippets.

@nqbao
Last active April 24, 2023 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nqbao/c894d5abf78e0a3d64d1bc08ae0e88e9 to your computer and use it in GitHub Desktop.
Save nqbao/c894d5abf78e0a3d64d1bc08ae0e88e9 to your computer and use it in GitHub Desktop.
my snippets
# remove outliner
upper = df.quantile(0.99)
cols = set(list(df)) - {"ts", "tss"}
df_clean = df
for col in cols:
df_clean = df_clean[(df_clean[col] < upper[col])]
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Create a sample data set with three variables
data = pd.DataFrame(np.random.randn(1000, 4), columns=['Variable 1', 'Variable 2', 'Variable 3', 'Variables 4'])
target_variable = np.random.randn(1000)
# Create a multi-scatter plot for all variables against the target variable
fig, axs = plt.subplots(nrows=3, ncols=2, figsize=(10, 12))
axs = axs.flatten()
for i, variable in enumerate(data.columns):
axs[i].scatter(data[variable], target_variable, alpha=0.2)
axs[i].set_xlabel(variable)
axs[i].set_ylabel('Target Variable')
plt.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment