0

I am trying to run T-distributed Stochastic Neighbor Embedding (t-SNE) in Jupyter but always facing a issue with

ValueError: could not convert string to float: '<Null>'

Code: enter image description here

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.manifold import TSNE
from sklearn.preprocessing import StandardScaler

# Reading the data using pandas 
df = pd.read_csv("E:\\Field data\Output\\Pixel values7.csv")
 
# print first five rows of df
print(df.head(9))
# save the labels into a variable l.
l = df['label']
 
# Drop the label feature and store the pixel data in d.
d = df.drop("label", axis = 1)

I got error after this line
# Data-preprocessing: Standardizing the data
from sklearn.preprocessing import StandardScaler
standardized_data = StandardScaler().fit_transform(df)
print(standardized_data.shape)

# TSNE
# Picking the top 1000 points as TSNE
# takes a lot of time for 15K points
data_1000 = standardized_data[0:1000, :]
labels_1000 = labels[0:1000]
 
model = TSNE(n_components = 2, random_state = 0)
# configuring the parameters
# the number of components = 2
# default perplexity = 30
# default learning rate = 200
# default Maximum number of iterations
# for the optimization = 1000
 
tsne_data = model.fit_transform(data_1000)
 
# creating a new data frame which
# help us in plotting the result data
tsne_data = np.vstack((tsne_data.T, labels_1000)).T
tsne_df = pd.DataFrame(data = tsne_data,
     columns =("Dim_1", "Dim_2", "label"))
 
# Plotting the result of tsne
sn.FacetGrid(tsne_df, hue ="label", size = 6).map(
       plt.scatter, 'Dim_1', 'Dim_2').add_legend()
 
plt.show()

I got this link from somewhere, I am not expert in python. I request you to kindly help me out.

I am trying to run this program for my data but always getting a error


ValueError: could not convert string to float: '<Null>'

If there is any other code for T-distributed Stochastic Neighbor Embedding (t-SNE). Please let me know.

My data look like this

0 Answers0