Last active
September 1, 2024 10:15
-
-
Save dacr/64965e69c9ed30b603727bb442adc667 to your computer and use it in GitHub Desktop.
Playing with smile and iris dataset / published by https://github.com/dacr/code-examples-manager #81cddd4b-a3e6-409b-b835-d42b6b653fc0/ad847c7cf72d3d9fac41cd8e23b6032a1cc766b8
This file contains hidden or 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
// summary : Playing with smile and iris dataset | |
// keywords : smile, machine-learning, iris, ai | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : 81cddd4b-a3e6-409b-b835-d42b6b653fc0 | |
// created-on : 2021-03-05T09:23:01Z | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
// --------------------- | |
//> using scala "3.4.2" | |
//> using dep "com.github.pathikrit::better-files:3.9.2" | |
//> using dep "com.github.haifengl::smile-scala:3.1.1" | |
//> using dep "org.bytedeco:javacpp-platform:1.5.10" | |
//> using dep "org.bytedeco:javacpp:1.5.10,classifier=linux-x86_64" | |
//> using dep "org.bytedeco:arpack-ng:3.9.1-1.5.10,classifier=linux-x86_64" | |
//> using dep "org.bytedeco:openblas:0.3.26-1.5.10,classifier=linux-x86_64" | |
//> using dep "org.slf4j:slf4j-nop:2.0.13" | |
//> using dep "com.lihaoyi::requests:0.9.0" | |
// --------------------- | |
import scala.language.postfixOps | |
import better.files.* | |
import smile.read | |
import smile.util.* | |
import smile.math.* | |
import smile.math.MathEx.* | |
import smile.math.distance.* | |
import smile.data.* | |
import smile.data.formula.* | |
import smile.data.measure.* | |
import smile.data.`type`.* | |
import smile.regression.* | |
import smile.stat.distribution.* | |
import smile.io.* | |
import smile.stat.Sampling | |
val inputFileName = "iris.arff" | |
val inputFile = inputFileName.toFile | |
if (inputFile.notExists) { | |
val url = "https://gist.githubusercontent.com/myui/143fa9d05bd6e7db0114/raw/500f178316b802f1cade6e3bf8dc814a96e84b1e/iris.arff" | |
for {out <- inputFile.newOutputStream.autoClosed} {requests.get(url).writeBytesTo(out)} | |
} | |
val iris = read.arff("iris.arff") | |
println(iris.summary()) | |
val model = randomForest("class".~(), iris) | |
println(model.metrics) | |
val df = iris(0) | |
println(df) | |
println(model.predict(df)) | |
println(df) | |
// TODO - to be continued... | |
println("enter to exit"); scala.io.StdIn.readLine() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment