Created
March 14, 2015 04:37
-
-
Save lateefj/f47a25bff8be4ce94892 to your computer and use it in GitHub Desktop.
Dataset conversion attemp.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nimborg/py/low_level | |
import nimborg/py/high_level | |
type | |
Digits = object of RootObj | |
data: seq[seq[int]] | |
target: seq[int] | |
let ds = pyImport("sklearn.datasets") | |
proc digits(): Digits = | |
let pydigits = ds.load_digits() | |
var | |
data: seq[seq[int]] | |
target: seq[int] | |
newSeq(target, len(pydigits.target)) | |
for i in 0..len(pydigits.target): | |
target[i] = toInt(pydigits.target[i]) | |
echo("Ok var declared correctly: ", len(pydigits.data)) | |
newSeq(data, len(pydigits.data)) | |
echo("New sequence creationg successful") | |
for i in 0..len(pydigits.data): | |
var s: seq[int] | |
newSeq(s, (len(pydigits.digits[i]))) | |
for j in 0..len(pydigits.data[i]): | |
s.add(toInt(pydigits.data[i][j])) | |
data.add(s) | |
return Digits(data:data, target: target) | |
let d = digits() | |
echo("Target is") | |
echo(d.target) | |
echo("data is ") | |
#echo(d.data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment