Skip to content

Commit

Permalink
Merge pull request #437 from HyunjunA/infvisfrontendmlbackend
Browse files Browse the repository at this point in the history
test plot_tsne
  • Loading branch information
HyunjunA authored Dec 5, 2022
2 parents beb1bca + 21b0948 commit efe7055
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
34 changes: 15 additions & 19 deletions machine/learn/skl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ def plot_imp_score(tmpdir, _id, coefs, feature_names, imp_score_type):
plt.yticks(range(num_bar), feature_names[indices])
plt.ylim([-1, num_bar])
h.tight_layout()
plt.savefig(tmpdir + _id + '/imp_score_' + _id + '.png')
# plt.savefig(tmpdir + _id + '/imp_score_' + _id + '.png')
plt.close()
return top_features, indices

Expand Down Expand Up @@ -1146,6 +1146,11 @@ def plot_learning_curve(tmpdir,_id,model,features,target,cv,return_times=True):
# test_scores_mean = np.mean(test_scores, axis=1)
# test_scores_std = np.std(test_scores, axis=1)


print('train_sizes.tolist()',train_sizes.tolist())
print('train_scores', train_scores.tolist())
print('test_scores', test_scores.tolist())

learning_curve_dict = {
'train_sizes':train_sizes.tolist(),
'train_scores': train_scores.tolist(),
Expand All @@ -1170,32 +1175,22 @@ def plot_pca_2d(tmpdir,_id,features,target):

# np.random.seed(5)

# iris = datasets.load_iris()
# print(features)

X = np.array(features)
y = np.array(target)

print(set(y))
# print(set(y))





plt.cla()
pca = decomposition.PCA(n_components=2)
# pca = decomposition.PCA(n_components=2)
pca.fit(X)
X = pca.transform(X)

# plt.scatter(x,y, c = z, cmap = mcolors.ListedColormap(["black", "green"]))

# plt.show()


# version 1
# colors = np.array(["black", "green"])
# plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Set1, edgecolor='k')



# version 2
Expand All @@ -1204,13 +1199,10 @@ def plot_pca_2d(tmpdir,_id,features,target):
colors = plt.cm.Set1(np.linspace(0, 1, num_classes))

plt.scatter(X[:, 0], X[:, 1], c=y, cmap=mcolors.ListedColormap(colors))
# plot the legend where the colors are mapped to the classes

plt.legend(handles=[Patch(color=colors[i], label="class_"+str(i)) for i in range(num_classes)])

# cb = plt.colorbar()
# loc = np.arange(0,max(label),max(label)/float(len(colors)))
# cb.set_ticks(loc)
# cb.set_ticklabels(colors)




Expand All @@ -1222,6 +1214,10 @@ def plot_pca_2d(tmpdir,_id,features,target):



plt.close()




# print("X")
# print(X)
Expand Down Expand Up @@ -1493,7 +1489,7 @@ def plot_tsne(tmpdir,_id,features,target):

# plt.show()
# plt.savefig(tmpdir + _id + '/tsne_' + _id + '.png')
# plt.close()
plt.close()



Expand Down
8 changes: 6 additions & 2 deletions tests/integration/jest/runExperiment_classificaion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ describe('run experiment', () => {
it('run LogisticRegression experiment on banana', async () => {
console.log('run LogisticRegression experiment on banana')

jest.setTimeout(util.JEST_TIMEOUT)
// jest.setTimeout(util.JEST_TIMEOUT)
jest.setTimeout(util.JEST_TIMEOUT*10)
let algoName = 'LogisticRegression'
let algoParms = {
"penalty": "l1",
Expand Down Expand Up @@ -102,7 +103,8 @@ describe('run experiment', () => {
it('run decisionTree experiment with invalid parms on banana', async () => {
console.log('run decisionTree experiment with invalid parms on banana')

jest.setTimeout(util.JEST_TIMEOUT)
// jest.setTimeout(util.JEST_TIMEOUT)
jest.setTimeout(util.JEST_TIMEOUT*2)

let algoName = 'LogisticRegression'
let algoParms = {
Expand Down Expand Up @@ -130,6 +132,8 @@ describe('run experiment', () => {

algoParms.dataset = datasetId

console.log("datasetId",datasetId)

// fetch previously run experiments
var prevExperiments = await labApi.fetchExperiments()

Expand Down

0 comments on commit efe7055

Please sign in to comment.