Relative Content

Tag Archive for scikit-learn

ValueError: Input 0 of layer “sequential” is incompatible with the layer: expected shape=(None, 247, 15), found shape=(None, 15)

import pandas as pd import tensorflow as tf from sklearn.model_selection import train_test_split dataset = pd.read_csv(‘/content/survey lung cancer.csv’) x = dataset.drop(columns=[“LUNG_CANCER”]) y = dataset[“LUNG_CANCER”] y= y.replace(“YES”, 1) y= y.replace(“NO”, 0) x= x.replace(“M”, 1) x= x.replace(“F”, 0) x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2) model = tf.keras.models.Sequential() model.add(tf.keras.layers.Dense(256, input_shape=x_train.shape, activation=’sigmoid’)) model.add(tf.keras.layers.Dense(256, activation=’sigmoid’)) model.add(tf.keras.layers.Dense(1, activation=’sigmoid’)) model.compile(optimizer=’adam’, loss=’binary_crossentropy’, […]

Scaling plots to match shape

I am trying to distinguish a certain shape from a series of plots.
By doing so, I would be able to apply Hierarchical Clustering to cluster these plots into different categories based on their shape. I already wrote the code to create a distance matrix which I use for clustering.

Does SimpleImputer from sklearn.impute keeps the original feature (column) after performing imputation?

I am trying to first impute a categorical feature(embark from titanic dataset) using SimpleImputer and then do OHE encoding on it. The problem is, the imputer is creating a column of the original values that are in string. I tried setting False to copy parameter but it’s still creating a column of the original values. If I try to use this in pipeline to apply logistic regression, the string values breaks the code. How can avoid making the copy of the original values?