This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.stats import jarque_bera | |
import numpy as np | |
# generate two sample datasets | |
data1 = np.random.normal(0, 1, size=100) | |
data2 = np.random.uniform(size=100) | |
# perform Jarque-Bera test on each dataset | |
jb_stat1, jb_p1 = jarque_bera(data1) | |
jb_stat2, jb_p2 = jarque_bera(data2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.stats import jarque_bera | |
import numpy as np | |
# generate a sample dataset | |
data = np.random.normal(0, 1, 1000) | |
# calculate the test statistic and p-value | |
jb_stat, jb_p = jarque_bera(data) | |
# print the results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.datasets import load_diabetes | |
from sklearn.impute import SimpleImputer | |
from sklearn.model_selection import train_test_split | |
from sklearn.linear_model import LinearRegression | |
from sklearn.metrics import mean_squared_error | |
import numpy as np | |
# Load the diabetes dataset | |
diabetes = load_diabetes() | |
X, y = diabetes.data, diabetes.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.experimental import enable_iterative_imputer | |
from sklearn.impute import IterativeImputer | |
from sklearn.datasets import load_diabetes | |
diabetes = load_diabetes() | |
X, y = diabetes.data, diabetes.target | |
# Introduce some missing values in X | |
missing_mask = np.random.rand(*X.shape) < 0.1 | |
X_missing = X.copy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.impute import KNNImputer | |
from sklearn.datasets import load_diabetes | |
diabetes = load_diabetes() | |
X, y = diabetes.data, diabetes.target | |
# Introduce some missing values in X | |
missing_mask = np.random.rand(*X.shape) < 0.1 | |
X_missing = X.copy() | |
X_missing[missing_mask] = np.nan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.impute import KNNImputer | |
from sklearn.datasets import load_diabetes | |
diabetes = load_diabetes() | |
X, y = diabetes.data, diabetes.target | |
# Introduce some missing values in X | |
missing_mask = np.random.rand(*X.shape) < 0.1 | |
X_missing = X.copy() | |
X_missing[missing_mask] = np.nan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.datasets import load_diabetes | |
diabetes = load_diabetes() | |
X, y = diabetes.data, diabetes.target | |
X_imputed = X.copy() | |
for i in range(X.shape[1]): | |
missing_mask = np.isnan(X[:, i]) | |
if np.any(missing_mask): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.datasets import load_diabetes | |
diabetes = load_diabetes() | |
X, y = diabetes.data, diabetes.target | |
X_imputed = X.copy() | |
for i in range(X.shape[1]): | |
missing_mask = np.isnan(X[:, i]) | |
if np.any(missing_mask): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
# Sample data | |
data = {'value': [1, 2, None, 4, 5, None, 7]} | |
df = pd.DataFrame(data) | |
# Replace with Maximum Value | |
df['max_fill'] = df['value'].fillna(df['value'].max()) | |
# Replace with Minimum Value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
# Sample data | |
data = {'value': [1, 2, None, 4, 5, None, 7]} | |
df = pd.DataFrame(data) | |
# Forward Fill | |
df['forward_fill'] = df['value'].fillna(method='ffill') | |
# Backward Fill |
NewerOlder