import pandas as pd
import numpy as np
import sklearn
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.metrics import precision_score
from sklearn.metrics import recall_score
from sklearn.metrics import f1_score
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
from sklearn.decomposition import PCA
from sklearn.tree import DecisionTreeClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC
from sklearn.linear_model import LinearRegression
from sklearn.tree import DecisionTreeRegressor
from sklearn.neighbors import KNeighborsRegressor
from sklearn.ensemble import RandomForestRegressor
from sklearn.cluster import KMeans
from mlxtend.frequent_patterns import apriori
from mlxtend.frequent_patterns import association_rules
import matplotlib.pyplot as plt
import seaborn as sns
import scipy
import scipy.stats as stats
import statsmodels
import statsmodels.formula.api as smf
import statsmodels.api as sm
import statsmodels.stats.api as sms
import mlxtend
from mlxtend.frequent_patterns import apriori
from mlxtend.frequent_patterns import association_rules
from mlxtend.preprocessing import TransactionEncoder
from scipy.stats import ttest_1samp
from scipy.stats import ttest_ind
from scipy.stats import ttest_rel
from scipy.stats import chi2_contingency
from scipy.stats import chisquare
from scipy.stats import pearsonr
from scipy.stats import spearmanr
from scipy.stats import kendalltau
from scipy.stats import spearmanr
from scipy.stats import shapiro
from scipy.stats import normaltest
from scipy.stats import kstest
from scipy.stats import mannwhitneyu
import pkgutil
import inspect
def get_object_type(obj):
if inspect.ismodule(obj):
return "module"
elif inspect.isclass(obj):
return "class"
elif inspect.isfunction(obj):
return "function"
elif inspect.ismethod(obj):
return "method"
else:
return "unknown"
def list_all_classes(module):
return [(name, get_object_type(obj)) for name, obj in inspect.getmembers(module) if inspect.isclass(obj) and not name.startswith("_")]
def list_all_functions(module):
return [(name, get_object_type(obj)) for name, obj in inspect.getmembers(module) if inspect.isfunction(obj) and not name.startswith("_")]
def list_all_modules(module):
return [(name, get_object_type(obj)) for name, obj in inspect.getmembers(module) if inspect.ismodule(obj) and not name.startswith("_")]
def list_all(module):
return [(name, get_object_type(obj)) for name, obj in inspect.getmembers(module) if not name.startswith("_")]
def hypothesis_test(p_value, alpha=0.05):
if (p_value <= alpha):
print(f"p_value = {p_value} <= {alpha}, null hypothesis is rejected.")
else:
print(f"p_value = {p_value} > {alpha}, null hypothesis is accepted.")
def predict(y_test, y_pred, score_func, **kwargs):
print(f"{score_func.__name__} = {score_func(y_test, y_pred, **kwargs)}")