Practicing Machine Learning Interview Questions in Python
Lisa Stuart
Data Scientist
# t-sne with loan data
from sklearn.manifold import TSNE
import seaborn as sns
loans = pd.read_csv('loans_dataset.csv')
# Feature matrix
X = loans.drop('Loan Status', axis=1)
tsne = TSNE(n_components=2, verbose=1, perplexity=40)
tsne_results = tsne.fit_transform(X)
loans['t-SNE-PC-one'] = tsne_results[:,0]
loans['t-SNE-PC-two'] = tsne_results[:,1]
# t-sne viz
plt.figure(figsize=(16,10))
sns.scatterplot(
x="t-SNE-PC-one", y="t-SNE-PC-two",
hue="Loan Status",
palette=sns.color_palette(["grey","blue"]),
data=loans,
legend="full",
alpha=0.3
)
Practicing Machine Learning Interview Questions in Python