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
// You can run this gist in a scala console | |
import java.awt.image.{BufferedImage} | |
import java.awt.Color | |
// Set image pixel at (0, 0) | |
val image = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_GRAY) | |
val b: Byte = 26 | |
val color = new Color(b & 0xff, b & 0xff, b & 0xff) | |
image.setRGB(0, 0, color.getRGB) |
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 transformer | |
from sparkdl.transformers import KerasVectorTransformer | |
# Create input DataFrame | |
data = [(Vectors.sparse(5, [(1, 1.0), (3, 7.0)]),), | |
(Vectors.dense([2.0, 0.0, 3.0, 4.0, 5.0]),), | |
(Vectors.dense([4.0, 0.0, 0.0, 6.0, 7.0]),)] | |
df = spark.createDataFrame(data, ["features"]) | |
# Create KerasVectorTransformer |
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 numpy as np | |
from matplotlib import pyplot as plt | |
def make_plot(X, y, clf, title, filename): | |
''' | |
Plots the decision boundary of the classifier <clf> (assumed to have been fitted | |
to X via clf.fit()) against the matrix of examples X with corresponding labels y. | |
Uses <title> as the title of the plot, saving the plot to <filename>. | |
''' |
NewerOlder