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 | |
from sklearn.linear_model import LinearRegression | |
from sklearn.model_selection import train_test_split | |
# Load data | |
url = 'https://gist.githubusercontent.com/ZeccaLehn/4e06d2575eb9589dbe8c365d61cb056c/raw/898a40b035f7c951579041aecbfb2149331fa9f6/mtcars.csv' | |
data = pd.read_csv(url, index_col=0) | |
print(data.head(5)) | |
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.tree import DecisionTreeClassifier | |
from sklearn.datasets import load_iris | |
from sklearn.model_selection import train_test_split | |
# Load data | |
iris = load_iris() | |
X = iris.data | |
y = iris.target | |
# Split data into training and testing sets |
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
# Load data | |
data <- iris | |
# Split data into training and testing sets | |
set.seed(123) | |
index <- sample(1:nrow(data), 0.8 * nrow(data)) | |
train <- data[index,] | |
test <- data[-index,] | |
# Build ANN model |
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
# Load data | |
data <- mtcars | |
# Build linear regression model | |
fit <- lm(mpg ~ wt + hp, data = data) | |
# Summarize the model | |
summary(fit) |
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
library(rpart) | |
# Load data | |
data <- iris | |
# Build decision tree | |
fit <- rpart(Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, data = data, method = "class") | |
# Plot the decision tree | |
library(rpart.plot) |
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
# Load data | |
import pandas as pd | |
data = pd.read_csv("data.csv") | |
# Run logistic regression analysis | |
from sklearn.linear_model import LogisticRegression | |
X = data[['age', 'income']] | |
y = data['default'] | |
clf = LogisticRegression(random_state=0).fit(X, y) |
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
library(tidyverse) | |
# Load data | |
data <- mtcars | |
# Run linear regression analysis | |
fit <- lm(mpg ~ wt, data = data) | |
# Provide ChatGPT with the summary of the model | |
summary_model <- summary(fit) |
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 | |
import scipy.stats as stats | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
import statsmodels.api as sm | |
from sklearn.datasets import load_iris | |
from bioinfokit.analys import stat | |
from statsmodels.formula.api import ols |
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 scipy.stats as stats | |
import numpy as np | |
## One sample t | |
data=[13, 14, 13, 12, 14, 15, 16, 13, 14, 12] | |
x=stats.ttest_1samp(a=data, popmean=15) | |
print(x) | |
# Two sample t |
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
# Binomial test in Python | |
from scipy.stats import binom_test | |
# Six-sided die flipped 24 times and lands on three exactly 6 times | |
x = binom_test(x=6, n=24, p=1/6, alternative='greater') | |
print(x) | |
# Flip coin 30 times and it lands on heads exactly 19 times | |
y = binom_test(x=19, n=30, p=1/2, alternative='greater') |