Convert Figma logo to code with AI

haifengl logosmile

Statistical Machine Intelligence & Learning Engine

6,373
1,146
6,373
0

Top Related Projects

scikit-learn: machine learning in Python

43,242

Apache Spark - A unified analytics engine for large-scale data processing

7,494

H2O is an Open Source, Distributed, Fast & Scalable Machine Learning Platform: Deep Learning, Gradient Boosting (GBM) & XGBoost, Random Forest, Generalized Linear Modeling (GLM with Elastic Net), K-Means, PCA, Generalized Additive Models (GAM), RuleFit, Support Vector Machine (SVM), Stacked Ensembles, Automatic Machine Learning (AutoML), etc.

28,479

Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow

18,470

A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks.

5,638

mlpack: a fast, header-only C++ machine learning library

Quick Overview

SMILE (Statistical Machine Intelligence and Learning Engine) is a comprehensive machine learning and data mining library written in Java and Scala. It provides a wide range of algorithms for classification, regression, clustering, association rule mining, feature selection, and more. SMILE aims to be efficient, scalable, and easy to use for both researchers and practitioners.

Pros

  • Comprehensive library covering a wide range of machine learning tasks
  • High-performance implementation with native C/C++ backends for some algorithms
  • Supports both Java and Scala, with a user-friendly API
  • Well-documented with extensive examples and tutorials

Cons

  • Steeper learning curve compared to some other ML libraries
  • Less frequent updates and smaller community compared to more popular libraries like scikit-learn
  • Limited support for deep learning compared to specialized frameworks
  • Some advanced features may require more in-depth knowledge of machine learning concepts

Code Examples

  1. Classification using Random Forest:
DataFrame data = Read.csv("iris.csv");
Formula formula = Formula.lhs("species");
RandomForest model = RandomForest.fit(formula, data);
System.out.println("OOB error = " + model.error());
  1. K-means clustering:
double[][] data = MathEx.readCSV("clustering_data.csv");
KMeans kmeans = KMeans.fit(data, 3);
int[] labels = kmeans.predict(data);
  1. Principal Component Analysis (PCA):
val data = Read.csv("pca_data.csv").toArray
val pca = PCA.fit(data)
val projected = pca.project(data)

Getting Started

To use SMILE in your Java or Scala project, add the following dependency to your build file:

For Maven:

<dependency>
    <groupId>com.github.haifengl</groupId>
    <artifactId>smile-core</artifactId>
    <version>2.6.0</version>
</dependency>

For Gradle:

implementation 'com.github.haifengl:smile-core:2.6.0'

Then, import the necessary classes and start using SMILE in your code:

import smile.data.*;
import smile.classification.*;
import smile.regression.*;
import smile.clustering.*;

For more detailed instructions and examples, refer to the official documentation at https://haifengl.github.io/smile/.

Competitor Comparisons

scikit-learn: machine learning in Python

Pros of scikit-learn

  • Larger community and more extensive documentation
  • Wider range of algorithms and tools for machine learning tasks
  • Better integration with other Python scientific computing libraries

Cons of scikit-learn

  • Slower performance for some algorithms compared to SMILE
  • Less support for big data processing and distributed computing
  • More complex API for certain tasks, especially when compared to SMILE's streamlined approach

Code Comparison

SMILE example (Java):

DataFrame df = Read.csv("iris.csv");
KMeans model = new KMeans(3);
int[] labels = model.fit(df).predict(df);

scikit-learn example (Python):

from sklearn.cluster import KMeans
import pandas as pd

df = pd.read_csv("iris.csv")
model = KMeans(n_clusters=3)
labels = model.fit_predict(df)

Both libraries offer similar functionality for common machine learning tasks, but SMILE provides a more concise API in Java, while scikit-learn offers greater flexibility and integration within the Python ecosystem. SMILE may have performance advantages in certain scenarios, particularly for large-scale data processing, while scikit-learn benefits from a larger community and more extensive documentation.

43,242

Apache Spark - A unified analytics engine for large-scale data processing

Pros of Spark

  • Distributed computing capabilities for large-scale data processing
  • Extensive ecosystem with support for SQL, streaming, and machine learning
  • Strong community support and regular updates

Cons of Spark

  • Steeper learning curve and more complex setup
  • Higher resource requirements, especially for smaller datasets
  • Potential overhead for simple tasks that don't require distributed processing

Code Comparison

Spark (Scala):

val df = spark.read.csv("data.csv")
val result = df.groupBy("column").agg(sum("value"))
result.show()

Smile (Java):

DataFrame df = Read.csv("data.csv");
DataFrame result = df.groupBy("column").sum("value");
System.out.println(result);

Key Differences

  • Spark is designed for distributed computing, while Smile focuses on in-memory processing
  • Spark offers a wider range of functionalities, whereas Smile specializes in machine learning and statistical analysis
  • Smile provides a simpler API and is more lightweight, making it easier to integrate into existing Java projects
  • Spark has better support for big data processing and real-time streaming analytics

Use Cases

  • Choose Spark for large-scale data processing, distributed computing, and complex analytics pipelines
  • Opt for Smile when working with smaller datasets, requiring fast in-memory processing, or integrating machine learning into Java applications
7,494

H2O is an Open Source, Distributed, Fast & Scalable Machine Learning Platform: Deep Learning, Gradient Boosting (GBM) & XGBoost, Random Forest, Generalized Linear Modeling (GLM with Elastic Net), K-Means, PCA, Generalized Additive Models (GAM), RuleFit, Support Vector Machine (SVM), Stacked Ensembles, Automatic Machine Learning (AutoML), etc.

Pros of H2O-3

  • Distributed computing support for handling large datasets
  • Extensive API support (R, Python, Java, Scala, REST)
  • Advanced AutoML capabilities

Cons of H2O-3

  • Steeper learning curve due to its distributed nature
  • Requires more system resources for setup and operation

Code Comparison

H2O-3 (Python):

import h2o
h2o.init()
data = h2o.import_file("path/to/data.csv")
model = h2o.automl.H2OAutoML(max_models=10)
model.train(x=["feature1", "feature2"], y="target", training_frame=data)

SMILE (Java):

DataFrame data = Read.csv("path/to/data.csv");
RandomForest model = RandomForest.fit(Formula.lhs("target"), data);
double[] prediction = model.predict(newData);

H2O-3 offers a more automated approach with its AutoML feature, while SMILE provides a more traditional API for machine learning tasks. H2O-3 is better suited for large-scale distributed computing, whereas SMILE is more lightweight and easier to integrate into existing Java applications. Both libraries offer a wide range of machine learning algorithms, but H2O-3 has a broader ecosystem with multiple language bindings and advanced features like AutoML.

28,479

Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow

Pros of XGBoost

  • Highly optimized for performance and scalability
  • Supports distributed computing for large-scale datasets
  • Extensive documentation and active community support

Cons of XGBoost

  • Steeper learning curve for beginners
  • More complex hyperparameter tuning process
  • Limited built-in visualization tools

Code Comparison

XGBoost:

import xgboost as xgb
model = xgb.XGBClassifier()
model.fit(X_train, y_train)
predictions = model.predict(X_test)

Smile:

XGBoost model = XGBoost.fit(X_train, y_train);
int[] predictions = model.predict(X_test);

Key Differences

  • XGBoost is primarily focused on gradient boosting, while Smile offers a broader range of machine learning algorithms
  • Smile provides a more user-friendly API for Java developers, while XGBoost has stronger support for Python users
  • XGBoost excels in handling large-scale datasets and distributed computing, whereas Smile is more suitable for smaller to medium-sized datasets
  • Smile offers built-in data preprocessing and feature selection tools, which are not as extensive in XGBoost

Both libraries have their strengths and are suitable for different use cases. XGBoost is ideal for large-scale gradient boosting tasks, while Smile provides a more comprehensive machine learning toolkit for Java developers.

18,470

A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks.

Error generating comparison

5,638

mlpack: a fast, header-only C++ machine learning library

Pros of mlpack

  • Written in C++, offering high performance and efficiency
  • Extensive collection of machine learning algorithms and tools
  • Supports both command-line interface and C++ API

Cons of mlpack

  • Steeper learning curve due to C++ complexity
  • Less extensive documentation compared to Smile
  • Smaller community and fewer contributors

Code Comparison

mlpack:

#include <mlpack/core.hpp>
#include <mlpack/methods/neighbor_search/neighbor_search.hpp>

using namespace mlpack;

arma::mat data;
data::Load("dataset.csv", data, true);
NeighborSearch<NearestNeighborSort> nn(data);

Smile:

import smile.data.*;
import smile.neighbor.*;

DataFrame data = Read.csv("dataset.csv");
KNNSearch<double[]> knn = new KDTree<>(data.toArray(), data.toArray());

Summary

mlpack offers high performance and a wide range of algorithms but has a steeper learning curve. Smile provides a more user-friendly Java-based approach with comprehensive documentation. Both libraries have their strengths, and the choice depends on specific project requirements and developer preferences.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Statistical Machine Intelligence & Learning Engine SMILE

Maven Central CI

SMILE (Statistical Machine Intelligence & Learning Engine) is a comprehensive, high-performance machine learning framework for the JVM. SMILE v5+ requires Java 25; v4.x requires Java 21; all previous versions require Java 8. SMILE also provides idiomatic APIs for Scala and Kotlin. With advanced data structures and algorithms, SMILE delivers state-of-the-art performance across every aspect of machine learning.


Table of Contents

  1. Features
  2. Module Map
  3. Installation
  4. Quick Start
  5. SMILE Studio & Shell
  6. Model Serialization
  7. Visualization
  8. License
  9. Issues & Discussions
  10. Contributing
  11. Maintainers
  12. Gallery

Features

AreaHighlights
LLMLLaMA-3 inference, tiktoken BPE tokenizer, OpenAI-compatible REST server, SSE chat streaming
Deep LearningLibTorch/GPU backend, EfficientNet-V2 image classification, custom layer API
ClassificationSVM, Decision Trees, Random Forest, AdaBoost, Gradient Boosting, Logistic Regression, Neural Networks, RBF Networks, MaxEnt, KNN, Naïve Bayes, LDA/QDA/RDA
RegressionSVR, Gaussian Process, Regression Trees, GBDT, Random Forest, RBF, OLS, LASSO, ElasticNet, Ridge
ClusteringBIRCH, CLARANS, DBSCAN, DENCLUE, Deterministic Annealing, K-Means, X-Means, G-Means, Neural Gas, Growing Neural Gas, Hierarchical, SIB, SOM, Spectral, Min-Entropy
Manifold LearningIsoMap, LLE, Laplacian Eigenmap, t-SNE, UMAP, PCA, Kernel PCA, Probabilistic PCA, GHA, Random Projection, ICA
Feature EngineeringGenetic Algorithm selection, Ensemble selection, TreeSHAP, SNR, Sum-Squares ratio, data transformations, formula API
NLPSentence / word tokenization, Bigram test, Phrase & Keyword extraction, Stemmer, POS tagging, Relevance ranking
Association RulesFP-growth frequent itemset mining
Sequence LearningHidden Markov Model, Conditional Random Field
Nearest NeighborBK-Tree, Cover Tree, KD-Tree, SimHash, LSH
Numerical MethodsLinear algebra, numerical optimization (BFGS, L-BFGS), interpolation, wavelets, RBF, distributions, hypothesis tests
VisualizationSwing plots (scatter, line, bar, box, histogram, surface, heatmap, contour, …) and declarative Vega-Lite charts

Module Map

Each module has its own detailed user guide. Click the README link for the module overview, or drill into individual topic guides.

base/ — Foundation

Data structures, math, linear algebra, statistical utilities, I/O

DocumentTopics
READMEModule overview and dependency setup
DATA_FRAME.mdDataFrame API — creation, selection, transformation
DATA_IO.mdCSV, JSON, Parquet, Arrow, JDBC, Avro readers/writers
DATA_TRANSFORMATION.mdScalers, encoders, imputers, feature transforms
DATASET.mdBuilt-in benchmark and real-world datasets
FORMULA.mdR-style formula language for model matrices
DISTRIBUTIONS.mdProbability distributions (Normal, Poisson, Beta, …)
HYPOTHESIS_TESTING.mdt-test, chi-squared, ANOVA, KS-test, …
DISTANCES.mdEuclidean, Mahalanobis, Hamming, edit distance, …
NEAREST_NEIGHBOR.mdKD-Tree, Cover Tree, BK-Tree, LSH
KERNELS.mdGaussian, polynomial, Laplacian, and other kernel functions
RBF.mdRadial basis function networks
INTERPOLATION.mdLinear, cubic spline, bilinear, bicubic
GRAPH.mdAdjacency list/matrix graph, BFS/DFS, spanning trees
SORT.mdQuick sort, heap sort, counting sort, index sort
HASH.mdLocality-sensitive hashing, SimHash
RNG.mdRandom number generators, sampling, permutations
BFGS.mdL-BFGS and BFGS numerical optimizers
ICA.mdIndependent Component Analysis
TENSOR.mdN-dimensional array (CPU tensor without LibTorch)
WAVELET.mdDWT, CWT, and wavelet families
GAP.mdGAP statistic for optimal cluster count estimation
COMPRESSED_SENSING.mdCompressed sensing and basis pursuit

core/ — Machine Learning Algorithms

Classification, regression, clustering, manifold learning, and more

DocumentTopics
READMEModule overview
CLASSIFICATION.mdSVM, Random Forest, AdaBoost, GBDT, KNN, Naïve Bayes, LDA, …
REGRESSION.mdSVR, Gaussian Process, LASSO, Ridge, ElasticNet, GBDT, …
CLUSTERING.mdK-Means, DBSCAN, BIRCH, SOM, Spectral Clustering, …
FEATURE_ENGINEERING.mdFeature selection, PCA, ICA, projection, encoding
MANIFOLD.mdt-SNE, UMAP, IsoMap, LLE, Laplacian Eigenmap
ANOMALY_DETECTION.mdIsolationForest, one-class SVM, local outlier factor
ASSOCIATION_RULE_MINING.mdFP-growth, association rules, frequent itemsets
SEQUENCE.mdHMM (Baum-Welch, Viterbi), CRF
TIME_SERIES.mdARIMA, box-plots, autocorrelation
REGRESSION.mdFull regression API reference
TRAINING.mdCross-validation, bootstrap, hyper-parameter search
VALIDATION.mdHold-out, k-fold, leave-one-out evaluation
VALIDATION_METRICS.mdAccuracy, AUC, F1, RMSE, MAE, confusion matrix
HYPER_PARAMETER_OPTIMIZATION.mdGrid search, random search, Bayesian optimization
VECTOR_QUANTIZATION.mdLVQ, Neural Gas, SOM as vector quantizers
ONNX.mdExporting and importing models via ONNX

deep/ — Deep Learning & LLMs

LibTorch-backed GPU/CPU tensor operations, neural network layers, LLaMA-3 inference, EfficientNet

DocumentTopics
READMEFull deep-learning & LLM user guide (tensors, layers, loss, optimizer, EfficientNet, LLaMA)

The deep/README.md covers:

  • smile.deep.tensor — Tensor factory, indexing, arithmetic, AutoScope memory management, dtype/device
  • smile.deep.layer — Linear, Conv2d, pooling, normalization (BN/GN/RMS), dropout, embedding, sequential blocks
  • smile.deep.activation — ReLU, GELU, SiLU, Tanh, Sigmoid, Softmax, GLU, HardShrink, …
  • smile.deep.Loss — MSE, cross-entropy, BCE, Huber, KL, hinge, and more
  • smile.deep.Optimizer — SGD, Adam, AdamW, RMSprop
  • smile.deep.Model — Abstract base class + training loop
  • smile.deep.metric — Accuracy, Precision, Recall, F1Score with macro/micro/weighted averaging
  • smile.llm — Message, Role, FinishReason, ChatCompletion records; sinusoidal & RoPE positional encodings
  • smile.llm.tokenizer — Tokenizer interface, Tiktoken BPE implementation (LLaMA-3 compatible)
  • smile.llm.llama — Full LLaMA-3 stack: Llama.build(), generate(), chat(), streaming via SubmissionPublisher
  • smile.vision — VisionModel, ImageDataset, EfficientNet.V2S/M/L() pretrained models, ImageNet labels
  • smile.vision.transform — Transform interface, ImageClassification pipeline, resize/crop/toTensor helpers

nlp/ — Natural Language Processing

Text normalization, tokenization, POS tagging, stemming, relevance ranking

DocumentTopics
READMEModule overview
TOKENIZER.mdSentence splitter, word tokenizer, regex tokenizer
POS.mdPart-of-speech tagging (Brill tagger, HMM tagger)
STEM.mdPorter, Lancaster, Lovins stemmers; lemmatization
COLLOCATION.mdBigram/trigram statistical tests, phrase extraction
RELEVANCE.mdTF-IDF, BM25, keyword extraction
TAXONOMY.mdWordNet integration, synsets, hypernyms

plot/ — Data Visualization

Swing-based interactive plots and declarative Vega-Lite charts

DocumentTopics
READMESwing plotting API — scatter, line, bar, box, histogram, heatmap, surface, contour, wireframe
VEGA.mdDeclarative smile.plot.vega (Vega-Lite) — JSON spec generation, web/Jupyter rendering

serve/ — Inference Server

Quarkus-based REST inference service with OpenAI-compatible API and SSE streaming

DocumentTopics
READMEBuilding and running the server, /chat/completions endpoint, SSE streaming, configuration

studio/ — Interactive Shell & Desktop IDE

REPL / notebook environment for Java, Scala, and Kotlin

DocumentTopics
README.mdDesktop Studio notebook UI, cell types, output rendering
CLICLI entry points (smile, smile shell, smile scala, smile kotlin, smile server)

scala/ — Scala API

Idiomatic Scala shim — concise wrappers, symbolic operators, Scala collections integration

DocumentTopics
READMEAPI overview, smile.classification, smile.regression, smile.clustering, smile.plot in Scala

kotlin/ — Kotlin API

Idiomatic Kotlin shim — extension functions, named parameters, builder DSLs

DocumentTopics
READMEAPI overview, extension functions, Kotlin-style builders
packages.mdFull package-by-package listing of all Kotlin extension functions

json/ — JSON Library (Scala)

Lightweight zero-dependency JSON library for Scala with a clean DSL

DocumentTopics
READMEParsing, building, pattern matching, path navigation, serialization

spark/ — Apache Spark Integration

Use SMILE models inside Spark ML pipelines

DocumentTopics
READMESmileTransformer, SmileClassifier, SmileRegressor; training and scoring in Spark DataFrames

Installation

Maven

<!-- Core ML algorithms -->
<dependency>
  <groupId>com.github.haifengl</groupId>
  <artifactId>smile-core</artifactId>
  <version>6.1.0</version>
</dependency>

<!-- Deep learning + LLMs (requires LibTorch) -->
<dependency>
  <groupId>com.github.haifengl</groupId>
  <artifactId>smile-deep</artifactId>
  <version>6.1.0</version>
</dependency>

<!-- Natural language processing -->
<dependency>
  <groupId>com.github.haifengl</groupId>
  <artifactId>smile-nlp</artifactId>
  <version>6.1.0</version>
</dependency>

<!-- Data visualization -->
<dependency>
  <groupId>com.github.haifengl</groupId>
  <artifactId>smile-plot</artifactId>
  <version>6.1.0</version>
</dependency>

SBT (Scala)

libraryDependencies += "com.github.haifengl" %% "smile-scala" % "6.1.0"

Gradle (Kotlin)

dependencies {
    implementation("com.github.haifengl:smile-kotlin:6.1.0")
}

Native Libraries (BLAS / LAPACK)

Several algorithms (manifold learning, Gaussian Process, MLP, some clustering) require BLAS and LAPACK.

Linux (Ubuntu / Debian)

sudo apt update
sudo apt install libopenblas-dev libarpack2-dev

macOS (Homebrew)

brew install arpack
# If macOS SIP strips DYLD_LIBRARY_PATH, copy the dylib to your working dir:
cp /opt/homebrew/lib/libarpack.dylib .

Windows — pre-built DLLs are included in the bin/ directory of the release package. Add that directory to PATH.

GPU (CUDA) — make sure the LibTorch CUDA native libraries are on java.library.path and that your Bytedeco pytorch classifier matches your CUDA version (e.g., linux-x86_64-gpu-cuda12.4).


Quick Start

import smile.classification.RandomForest;
import smile.data.formula.Formula;
import smile.io.Read;

// Load data
var data = Read.csv("src/test/resources/iris.csv");

// Train a random forest
var forest = RandomForest.fit(Formula.lhs("species"), data);

// Predict
int label = forest.predict(data.get(0));
System.out.println("Predicted class: " + label);

For deep learning and LLM examples, see deep/README.md. For visualization examples, see plot/README.md.


SMILE Studio & Shell

SMILE ships with an interactive desktop Studio (notebook-style) and a set of CLI shells. See studio/README.md for full documentation.

Download a pre-packaged release from the releases page, then:

cd bin
path/to/smile/bin/setup      # install required native dependencies
path/to/smile/bin/smile      # launch SMILE Studio from your project directory

Other entry points:

CommandDescription
smileDesktop notebook IDE
smile shellJava REPL with all SMILE packages pre-imported
smile scalaScala REPL
smile trainTrain a supervised learning model
smile predictPredict on a file using a saved model
smile serveStart the LLM inference server

To increase the JVM heap:

path/to/smile/bin/smile -J-Xmx30G

Model Serialization

Most SMILE models implement java.io.Serializable. You can serialize a trained model to disk and load it in a production environment or inside a Spark job:

// Save
try (var out = new ObjectOutputStream(new FileOutputStream("model.ser"))) {
    out.writeObject(forest);
}

// Load
try (var in = new ObjectInputStream(new FileInputStream("model.ser"))) {
    var loaded = (RandomForest) in.readObject();
}

Visualization

SMILE provides two visualization layers:

  • smile.plot.swing — Swing-based interactive 2D/3D plots. See plot/README.md.
  • smile.plot.vega — Declarative Vega-Lite charts for browsers and Jupyter. See plot/VEGA.md.
<dependency>
  <groupId>com.github.haifengl</groupId>
  <artifactId>smile-plot</artifactId>
  <version>6.1.0</version>
</dependency>

License

SMILE employs a dual license model designed to meet the development and distribution needs of both commercial distributors (OEMs, ISVs, VARs) and open source projects. For details, see LICENSE. To acquire a commercial license, contact smile.sales@outlook.com.


Issues & Discussions

ChannelPurpose
GitHub DiscussionsQuestions, ideas, show-and-tell
Stack Overflow [smile]Technical Q&A
Issue TrackerBug reports and feature requests
Online DocsTutorials and programming guides
Java API · Scala API · Kotlin API · Clojure APIAPI Javadoc

Contributing

Please read CONTRIBUTING.md for build and test instructions.


Maintainers


Gallery

SPLOM

Scatterplot Matrix

Scatter

Scatter Plot

Heart

Line Plot

Surface

Surface Plot

Scatter

Bar Plot

Box Plot

Box Plot

Histogram

Histogram Heatmap

Rolling

Rolling Average

Map

Geo Map

UMAP

UMAP

Text

Text Plot

Contour

Heatmap with Contour

Hexmap

Hexmap

IsoMap

IsoMap

LLE

LLE

Kernel PCA

Kernel PCA

Neural Network

Neural Network

SVM

SVM

Hierarchical Clustering

Hierarchical Clustering

SOM

SOM

DBSCAN

DBSCAN

Neural Gas

Neural Gas

Wavelet

Wavelet

Mixture

Exponential Family Mixture

Teapot

Teapot Wireframe

Interpolation

Grid Interpolation