Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/class/learning/Cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { kmpp } from 'skmeans/kinit';
// import { kmpp } from 'skmeans/dist/node/kinit';
import floor from 'lodash/floor';
import _toNumber from 'lodash/toNumber';
import _isNaN from 'lodash/isNaN';
import LearningView from './LearningView';
import Chart from './Chart';
import DataTable from '../DataTable';
Expand Down Expand Up @@ -155,7 +156,7 @@ class Cluster {
this.#isTrained = false;
const { data, select } = this.#table;
const filtered = data.filter(
(row) => !select.flat().some((selected) => !_toNumber(row[selected]))
(row) => !select.flat().some((selected) => _isNaN(_toNumber(row[selected])))
);
const [attr] = select;

Expand Down
3 changes: 2 additions & 1 deletion src/class/learning/DecisionTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import _max from 'lodash/max';
import _sum from 'lodash/sum';
import _mean from 'lodash/mean';
import _toNumber from 'lodash/toNumber';
import _isNaN from 'lodash/isNaN';
import LearningBase from './LearningBase';
import { DecisionTreeClassifier as DTClassifier } from 'ml-cart';
import Utils from './Utils';
Expand Down Expand Up @@ -159,7 +160,7 @@ function getData(testRate = 0.2, data) {
const { select = [[0], [1]], data: table, fields } = data;
const [attr, predict] = select;
const filtered = table.filter(
(row) => !select[0].some((selected) => !_toNumber(row[selected]))
(row) => !select[0].some((selected) => _isNaN(_toNumber(row[selected])))
);
const dataArray = filtered
.map((row) => ({
Expand Down
2 changes: 1 addition & 1 deletion src/class/learning/LearningView.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const STATUS = {

export default class LearningView {
constructor({ name = 'model name', status = STATUS.NO_MODEL, value = 0} = {}) {
this.id = Entry.generateHash();
this.id = Entry.generateHash();
this.visible = true;
this.value = value;
const fontFamily = EntryStatic.fontFamily || 'NanumGothic';
Expand Down
3 changes: 2 additions & 1 deletion src/class/learning/LogisticRegression.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import _max from 'lodash/max';
import _sum from 'lodash/sum';
import _mean from 'lodash/mean';
import _toNumber from 'lodash/toNumber';
import _isNaN from 'lodash/isNaN';
import LearningBase from './LearningBase';
import Utils from './Utils';

Expand Down Expand Up @@ -184,7 +185,7 @@ function getData(validationRate, testRate, data, trainParam) {
const { select = [[0], [1]], data: table, fields } = data;
const [attr, predict] = select;
const filtered = table.filter(
(row) => !select[0].some((selected) => !_toNumber(row[selected]))
(row) => !select[0].some((selected) => _isNaN(_toNumber(row[selected])))
);
const dataArray = filtered
.map((row) => ({
Expand Down
3 changes: 2 additions & 1 deletion src/class/learning/NumberClassification.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import _floor from 'lodash/floor';
import _sum from 'lodash/sum';
import _mean from 'lodash/mean';
import _toNumber from 'lodash/toNumber';
import _isNaN from 'lodash/isNaN';
import DataTable from '../DataTable';

export const classes = [
Expand Down Expand Up @@ -334,7 +335,7 @@ function convertTableToKnnData(tableData = {}) {
const { select = [[0], [1]], data: table = [] } = tableData;
const [attr, predict] = select;
const filtered = table.filter(
(row) => !select[0].some((selected) => !_toNumber(row[selected]))
(row) => !select[0].some((selected) => _isNaN(_toNumber(row[selected])))
);
return filtered.reduce(
(accumulator, row) => {
Expand Down
3 changes: 2 additions & 1 deletion src/class/learning/Regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Chart from './Chart';
import _sum from 'lodash/sum';
import _mean from 'lodash/mean';
import _toNumber from 'lodash/toNumber';
import _isNaN from 'lodash/isNaN';
import LearningBase from './LearningBase';
import Utils from './Utils';

Expand Down Expand Up @@ -224,7 +225,7 @@ function convertToTfData(data, trainParam) {
const [attr, predict] = select;
const { epochs = 1, batchSize = 1 } = trainParam;
const filtered = table.filter(
(row) => !select.flat().some((selected) => !_toNumber(row[selected]))
(row) => !select.flat().some((selected) => _isNaN(_toNumber(row[selected])))
);
const totalDataSize = Math.ceil(filtered.length / batchSize) * epochs;
return filtered.reduce(
Expand Down
3 changes: 2 additions & 1 deletion src/class/learning/Svm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import _max from 'lodash/max';
import _sum from 'lodash/sum';
import _mean from 'lodash/mean';
import _toNumber from 'lodash/toNumber';
import _isNaN from 'lodash/isNaN';
import Utils from './Utils';
const { callApi } = require('../../util/common');
const SVM = require('libsvm-js/asm');
Expand Down Expand Up @@ -168,7 +169,7 @@ class Svm extends LearningBase {
const { select = [[0], [1]], data: table, fields } = data;
const [attr, predict] = select;
const filtered = table.filter(
(row) => !select[0].some((selected) => !_toNumber(row[selected]))
(row) => !select[0].some((selected) => _isNaN(_toNumber(row[selected])))
);
const dataArray = filtered
.map((row) => ({
Expand Down