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
install.packages("rpart") | |
install.packages("dplyr") | |
library(rpart) | |
library(dplyr) | |
data(mtcars) | |
d.tree = rpart(formula = mtcars$cyl ~ mtcars$mpg, data = mtcars) | |
rpart.plot::rpart.plot(d.tree) |
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
data(mtcars) | |
normed.sample <- quantileNormalise(mtcars.sample) | |
tmp_data <- kMeansBin(normed.sample) |
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
install.packages("classInt") | |
library(classInt) | |
data <- c(0, 5, 10, 15, 15, 20, 25, 25, 30) | |
x <- class_interval(dataset, 5, style = 'quantile') | |
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
install.packages("classInt") | |
library(classInt) | |
data <- c(0, 5, 10, 15, 15, 20, 25, 25, 30) | |
x <- class_interval(data,5, style = 'equal') |
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.model_selection import train_test_split | |
from feature_engine.discretisers import DecisionTreeDiscretiser | |
treeDisc = DecisionTreeDiscretiser(cv=20, scoring='accuracy',variables=['a', 'b'],regression=False,param_grid={'max_depth': [1,2,3],'min_samples_leaf':[20,4]}) |
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.preprocessing import KBinsDiscretizer | |
discrete_data = KBinsDiscretizer(n_bins=10, encode='ordinal', strategy='kmeans') |
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.preprocessing import KBinsDiscretizer | |
from feature_engine.discretisers import EqualFrequencyDiscretiser | |
discrete_data = EqualFrequencyDiscretiser(q=20, variables = ['a', 'b']) |
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.preprocessing import KBinsDiscretizer | |
from feature_engine.discretisers import EqualWidthDiscretiser | |
#distretization | |
discrete_data = KBinsDiscretizer(n_bins=20, encode='ordinal', strategy='uniform') |
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
install.package("mice") #install mice | |
install.package("lattice")#install lattice | |
library("mice") #load mice | |
library("lattice") #load lattice | |
micedata <- mice(mtcars[, !names(mtcars) %in% "cyl"], method="rf") # perform mice imputation, based on random forests. | |
miceOutput <- complete(micedata) # generate the completed data. | |
#Check for NAs | |
anyNA(miceOutput) |
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
install.package("DMwR") #install package | |
library(DMwR) #load package | |
#Knn imputation | |
knnOutput <- knnImputation(mtcars[, !names(mtcars) %in% "cyl"]) # perform knn imputation. | |
#check for NAs | |
anyNA(knnOutput) |