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 | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from sklearn.datasets import load_iris | |
#Converting the data from an array to a data frame | |
X = pd.DataFrame(load_iris()["data"]).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.preprocessing import FunctionTransformer, ColumnTransformer | |
log_transform = FunctionTransformer(lambda x: np.log(x)) | |
ct = ColumnTransformer(transformers=[['log_transform',log_transform,list(range(len(X.columns)))]],remainder='passthrough') | |
log_X = ct.fit_transform(X).copy() | |
log_X = pd.DataFrame(log_X,columns=[0,1,2,3]).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
import pandas as pd | |
from sklearn.datasets import load_iris | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
data = pd.DataFrame(load_iris()["data"],columns=load_iris()['feature_names']) | |
data["species"] = load_iris()["target"] | |
data.head() |
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 | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
# LOADING DIABETES DATA (INPUT FEATURES) AND STORING IT IN A DATA FRAME | |
data = pd.DataFrame(load_diabetes()["data"],columns=load_diabetes()["feature_names"]) | |
#ADDING TARGET VARIABLE TO THE DATA FRAME | |
data["target"] = load_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.datasets import load_wine | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
data = pd.DataFrame(load_wine()["data"],columns=load_wine()["feature_names"]) | |
data.head() |
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 numpy as np | |
from sklearn.datasets import make_classification | |
from sklearn.model_selection import train_test_split, StratifiedKFold, StratifiedShuffleSplit, KFold | |
make_class = make_classification(n_samples=500,n_features=3,n_redundant=0,n_informative=2,n_classes=3,n_clusters_per_class=1,random_state=11) | |
data = pd.DataFrame(make_class[0],columns=range(make_class[0].shape[1])) | |
data['target'] = make_class[1] | |
data.head() |
NewerOlder