🌐 AI搜索 & 代理 主页
Skip to content

Commit 3251738

Browse files
committed
feat: remove data loading logic in favor of using dfd.readCSV(url)
1 parent 05c9d9a commit 3251738

File tree

5 files changed

+8
-142
lines changed

5 files changed

+8
-142
lines changed

package-lock.json

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"@tensorflow/tfjs-node": "3.13.0",
5050
"lodash": "^4.17.21",
5151
"mathjs": "^10.0.0",
52-
"node-fetch": "2.6.0",
5352
"seedrandom": "^3.0.5",
5453
"simple-statistics": "^7.7.0"
5554
},

src/datasets/datasets.test.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/datasets/datasets.ts

Lines changed: 7 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,9 @@
1-
import fetch from 'node-fetch'
2-
31
export const dataUrls = {
4-
loadBoston: 'http://scikitjs.org/data/boston.csv'
5-
}
6-
7-
/**
8-
* Loads the Boston housing dataset (regression). Samples 506, features 13.
9-
* @example
10-
* ```typescript
11-
import { loadBoston } from 'scikitjs'
12-
13-
let Array2D = await loadBoston()
14-
console.log(Array2D[0]) // Headers ['CRIM', 'ZN', ..., 'LSTAT', 'target']
15-
console.log(Array2D.slice(1)) // All the actual data
16-
```
17-
*/
18-
19-
export async function loadBoston(): Promise<Array<Array<number>>> {
20-
let text = (await fetch(dataUrls.loadBoston)
21-
.then((el) => el.text())
22-
.catch((el) => {
23-
console.error(`Fetch failed to get url ${dataUrls.loadBoston}`)
24-
console.error(el)
25-
})) as string
26-
let Array2D = text
27-
.split('\n')
28-
.map((el) => el.split(',').map((singleNumb) => Number(singleNumb)))
29-
Array2D.pop() // There is a newline that ends the file and no data after
30-
return Array2D
31-
}
32-
33-
/**
34-
* Loads the Iris dataset (classification).
35-
* This is a very easy multi-class classification dataset. Samples 150, Classes 3, Features 4.
36-
* @example
37-
* ```typescript
38-
import { loadIris } from 'scikitjs'
39-
40-
let df = await loadIris()
41-
df.print()
42-
```
43-
*/
44-
export function loadIris(): string {
45-
return 'http://scikitjs.org/data/iris.csv'
46-
}
47-
48-
/**
49-
* Loads the Wine dataset (classification).
50-
* This is a very easy multi-class classification dataset. Samples 178, Classes 3, Features 13.
51-
* @example
52-
* ```typescript
53-
import { loadWine } from 'scikitjs'
54-
55-
let df = await loadWine()
56-
df.print()
57-
```
58-
*/
59-
60-
export function loadWine(): string {
61-
return 'http://scikitjs.org/data/wine.csv'
62-
}
63-
64-
/**
65-
* Loads the Diabetes dataset (regression).
66-
* Samples 442, Features 10.
67-
* @example
68-
* ```typescript
69-
import { loadDiabetes } from 'scikitjs'
70-
71-
let df = await loadDiabetes()
72-
df.print()
73-
```
74-
*/
75-
76-
export function loadDiabetes(): string {
77-
return 'http://scikitjs.org/data/diabetes.csv'
78-
}
79-
80-
/**
81-
* Loads the Breast Cancer Wisconsin dataset (classification).
82-
* Samples 569, Features 30.
83-
* @example
84-
* ```typescript
85-
import { loadBreastCancer } from 'scikitjs'
86-
87-
let df = await loadBreastCancer()
88-
df.print()
89-
```
90-
*/
91-
92-
export function loadBreastCancer(): string {
93-
return 'http://scikitjs.org/data/breast_cancer.csv'
94-
}
95-
96-
/**
97-
* Loads the Digit dataset (classification).
98-
* Samples 1797, Features 64. Each sample is an 8x8 image
99-
* @example
100-
* ```typescript
101-
import { loadDigits } from 'scikitjs'
102-
103-
let df = await loadDigits()
104-
df.print()
105-
```
106-
*/
107-
export function loadDigits(): string {
108-
return 'http://scikitjs.org/data/digits.csv'
109-
}
110-
111-
/**
112-
* Loads the California housing dataset (regression).
113-
*
114-
* Samples 20640, Features 8.
115-
*/
116-
117-
export function fetchCaliforniaHousing(): string {
118-
return 'http://scikitjs.org/data/california_housing.csv'
2+
loadBoston: 'http://scikitjs.org/data/boston.csv',
3+
loadIris: 'http://scikitjs.org/data/iris.csv',
4+
loadWine: 'http://scikitjs.org/data/wine.csv',
5+
loadDiabetes: 'http://scikitjs.org/data/diabetes.csv',
6+
loadBreastCancer: 'http://scikitjs.org/data/breast_cancer.csv',
7+
loadDigits: 'http://scikitjs.org/data/digits.csv',
8+
fetchCaliforniaHousing: 'http://scikitjs.org/data/california_housing.csv'
1199
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export {
5858
export { RobustScaler, RobustScalerParams } from './preprocessing/robustScaler'
5959
export { KMeans, KMeansParams } from './cluster/kmeans'
6060
export { Scikit1D, Scikit2D, ScikitVecOrMatrix } from './types'
61-
export * as datasets from './datasets/datasets'
61+
export { dataUrls } from './datasets/datasets'
6262
export {
6363
makeVotingRegressor,
6464
VotingRegressor,

0 commit comments

Comments
 (0)