Created
November 2, 2023 07:36
-
-
Save 0x61nas/356221436af9f7f474ad18a2bc166a19 to your computer and use it in GitHub Desktop.
linfa-test.ipynb
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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"gpuType": "T4", | |
"authorship_tag": "ABX9TyMsmpnshvLoFVw6Y7F6N1yi", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
}, | |
"accelerator": "GPU" | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/0x61nas/356221436af9f7f474ad18a2bc166a19/linfa-test.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"id": "NpQCEF_IZLbu", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"outputId": "12058821-4ddf-4445-f971-7a1ffe250e9e" | |
}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Cloning into 'linfa'...\n", | |
"remote: Enumerating objects: 375, done.\u001b[K\n", | |
"remote: Counting objects: 100% (375/375), done.\u001b[K\n", | |
"remote: Compressing objects: 100% (343/343), done.\u001b[K\n", | |
"remote: Total 375 (delta 41), reused 171 (delta 16), pack-reused 0\u001b[K\n", | |
"Receiving objects: 100% (375/375), 547.34 KiB | 5.21 MiB/s, done.\n", | |
"Resolving deltas: 100% (41/41), done.\n" | |
] | |
} | |
], | |
"source": [ | |
"!git clone --depth=1 https://github.com/rust-ml/linfa.git" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [], | |
"metadata": { | |
"id": "ofm1lJPZ4W0i" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"!curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --quiet -y --default-toolchain stable" | |
], | |
"metadata": { | |
"id": "Bw11Jab0c1BL", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"outputId": "08382186-9714-498a-9631-b136f845ba84" | |
}, | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"\u001b[1minfo:\u001b[0m downloading installer\n", | |
"\u001b[1minfo: \u001b[mprofile set to 'default'\n", | |
"\u001b[1minfo: \u001b[mdefault host triple is x86_64-unknown-linux-gnu\n", | |
"\u001b[1minfo: \u001b[msyncing channel updates for 'stable-x86_64-unknown-linux-gnu'\n", | |
"\u001b[1minfo: \u001b[mlatest update on 2023-10-05, rust version 1.73.0 (cc66ad468 2023-10-03)\n", | |
"\u001b[1minfo: \u001b[mdownloading component 'cargo'\n", | |
"\u001b[1minfo: \u001b[mdownloading component 'clippy'\n", | |
"\u001b[1minfo: \u001b[mdownloading component 'rust-docs'\n", | |
"\u001b[1minfo: \u001b[mdownloading component 'rust-std'\n", | |
"\u001b[1minfo: \u001b[mdownloading component 'rustc'\n", | |
"\u001b[1minfo: \u001b[mdownloading component 'rustfmt'\n", | |
"\u001b[1minfo: \u001b[minstalling component 'cargo'\n", | |
"\u001b[1minfo: \u001b[minstalling component 'clippy'\n", | |
"\u001b[1minfo: \u001b[minstalling component 'rust-docs'\n", | |
"\u001b[1minfo: \u001b[minstalling component 'rust-std'\n", | |
"\u001b[1minfo: \u001b[minstalling component 'rustc'\n", | |
"\u001b[1minfo: \u001b[minstalling component 'rustfmt'\n", | |
"\u001b[1minfo: \u001b[mdefault toolchain set to 'stable-x86_64-unknown-linux-gnu'\n", | |
"\n", | |
" \u001b[1m\u001b[32mstable-x86_64-unknown-linux-gnu installed\u001b[m - rustc 1.73.0 (cc66ad468 2023-10-03)\n", | |
"\n", | |
"\u001b[1m\n", | |
"Rust is installed now. Great!\n", | |
"\u001b[m\n", | |
"To get started you may need to restart your current shell.\n", | |
"This would reload your \u001b[1mPATH\u001b[m environment variable to include\n", | |
"Cargo's bin directory ($HOME/.cargo/bin).\n", | |
"\n", | |
"To configure your current shell, run:\n", | |
"source \"$HOME/.cargo/env\"\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"!source \"$HOME/.cargo/env\" && RUST_BACKTRACE=full cargo r --example=winequality -r --target-dir $HOME/cargo-target --manifest-path \"/content/linfa/algorithms/linfa-svm/Cargo.toml\"" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"outputId": "bab77ae0-99b1-4e55-90b1-a59904993774", | |
"id": "3NQ18BT85hbU" | |
}, | |
"execution_count": 4, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Updating\u001b[0m crates.io index\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloading\u001b[0m crates ...\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m cfg-if v1.0.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m unicode-ident v1.0.12\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m miniz_oxide v0.7.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m serde v1.0.190\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m ppv-lite86 v0.2.17\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m crc32fast v1.3.2\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m rand_distr v0.4.3\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m csv v1.3.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m ndarray-rand v0.14.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m order-stat v0.1.3\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m approx v0.4.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m num-traits v0.2.17\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m kdtree v0.6.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m hashbrown v0.12.3\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m sprs v0.11.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m csv-core v0.1.11\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m rand_xoshiro v0.6.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m matrixmultiply v0.3.8\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m proc-macro2 v1.0.69\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m autocfg v1.1.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m rand v0.8.5\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m quote v1.0.33\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m flate2 v1.0.28\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m noisy_float v0.2.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m memchr v2.6.4\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m ndarray-stats v0.5.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m itoa v1.0.9\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m rawpointer v0.2.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m thiserror-impl v1.0.50\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m libc v0.2.149\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m rand_chacha v0.3.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m indexmap v1.9.3\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m ryu v1.0.15\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m adler v1.0.2\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m num-integer v0.1.45\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m rand_core v0.6.4\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m thiserror v1.0.50\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m libm v0.2.8\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m smallvec v1.11.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m itertools v0.10.5\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m syn v2.0.38\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m either v1.9.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m num-complex v0.4.4\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m getrandom v0.2.10\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m ndarray v0.15.6\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Downloaded\u001b[0m ndarray-csv v0.5.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m autocfg v1.1.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m libm v0.2.8\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m num-traits v0.2.17\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m cfg-if v1.0.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m libc v0.2.149\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m matrixmultiply v0.3.8\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m num-integer v0.1.45\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m proc-macro2 v1.0.69\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m getrandom v0.2.10\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m rand_core v0.6.4\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m rawpointer v0.2.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m num-complex v0.4.4\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m approx v0.4.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m unicode-ident v1.0.12\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m ppv-lite86 v0.2.17\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m rand_chacha v0.3.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m ndarray v0.15.6\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m quote v1.0.33\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m rand v0.8.5\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m syn v2.0.38\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m thiserror v1.0.50\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m either v1.9.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m indexmap v1.9.3\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m smallvec v1.11.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m thiserror-impl v1.0.50\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m linfa v0.7.0 (/content/linfa)\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m sprs v0.11.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m serde v1.0.190\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m hashbrown v0.12.3\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m itertools v0.10.5\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m noisy_float v0.2.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m memchr v2.6.4\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m crc32fast v1.3.2\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m ndarray-stats v0.5.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m csv-core v0.1.11\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m kdtree v0.6.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m adler v1.0.2\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m itoa v1.0.9\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m order-stat v0.1.3\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m ryu v1.0.15\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m linfa-nn v0.7.0 (/content/linfa/algorithms/linfa-nn)\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m miniz_oxide v0.7.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m csv v1.3.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m rand_distr v0.4.3\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m ndarray-rand v0.14.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m ndarray-csv v0.5.1\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m flate2 v1.0.28\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m linfa-kernel v0.7.0 (/content/linfa/algorithms/linfa-kernel)\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m linfa-svm v0.7.0 (/content/linfa/algorithms/linfa-svm)\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m linfa-datasets v0.7.0 (/content/linfa/datasets)\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Compiling\u001b[0m rand_xoshiro v0.6.0\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Finished\u001b[0m release [optimized] target(s) in 50.86s\n", | |
"\u001b[0m\u001b[0m\u001b[1m\u001b[32m Running\u001b[0m `/root/cargo-target/release/examples/winequality`\n", | |
"Fit SVM classifier with #1440 training points\n", | |
"Exited after 565275 iterations with obj = -494921.4390541657 and 322 support vectors\n", | |
"\n", | |
"classes | bad | good \n", | |
"bad | 129 | 13 \n", | |
"good | 8 | 9 \n", | |
"\n", | |
"accuracy 0.8679245, MCC 0.3918634\n" | |
] | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment