text:
Join Movie Lover's Club
Box Office > 21 Jump Street leads weekend box office
21 Jump Street leads weekend box office
By Alexandra Heilbron on March 19, 2012 | 1 Comment
The hilarious new comedy 21 Jump Street, starring Channing Tatum and Jonah Hill and featuring a cameo by Johnny Depp, took over the top spot at the weekend box office, grossing an estimated $35 million. Tribute viewers gave it a high rating of 4.6 out of 5 stars. After two weekends at the top Dr. Seuss' The Lorax was knocked to second place, earning an additional $22.8 million. John Carter was pushed to third place in its second weekend out, taking in $13.5 million with a Tribute.ca rating of 4.3 stars. Project X, about high school misfits who throw an out-of-control party dropped a spot to fourth, earning an extra $4 million and getting a 2.5 star rating from Tribute users. Eddie Murphy's comedy A Thousand Words earned just $3.8 million, but climbed a spot to fifth place. The limited amount of Tribute.ca viewers who voted on it gave it 4.3 stars.
21 jump street A Thousand Words Channing Tatum Dr. Seuss' The Lorax Eddie Murphy Johnny Depp Jonah Hill Project X
Comments & Discussion
123 • March 19, 2012 @ 10:42 AM
It really doesn't surprise me that Eddie Murphy's movie is so low. Dumb actor, dumb storyline…his career is pretty much over.
Email Address (will not be published) *
Channing Tatum's stalker found living in his home
Actor Channing Tatum is seeking to file a restraining order against an alleged stalker who was found staying in his vacant Los Angeles home last month.
Channing Tatum and Jenna Dewan headed for divorce
April 3, 2018 | 4 Comments
Channing Tatum and Jenna Dewan, who married in 2009 and have a four-year-old daughter together, announced hours ago that their marriage is coming to an end.
Kingsman: The Golden Circle – Blu-ray review
December 14, 2017 | Leave a Comment
Kingsman: The Secret Service left a big mark on the world of spy movies, can it's sequel Kingsman: The Golden Circle live up to the hype? Check out our review.
After sitting atop the box office since its release, comic book sequel Wonder Woman 1984...
Check out DVDs, Blu-rays and streaming shows (Netflix, Amazon Prime Video, BritBox, Disney+, Acorn TV,...
Search by Theater


text:
Іван Михайлович Мусієнко (, село Калаборок Новогеоргіївського району на Кіровоградщині) — український політик, член Соціалістичної партії України. Народний депутат України 1-го та 3-го скликань.

Біографія
Трудову діяльність розпочав у 1960 робітником на будівництві Кременчуцької ГЕС. З 1960 року — голова Ново-Георгіївської районної ради спортивного товариства «Колгоспник» м. Кремгес Кіровоградської області.

З 1962 року — студент Київського державного університету. Член КПРС з 1963.

З 1963 року — служба в Радянській Армії. З 1966 року — студент Київського державного університету.

Отримав вищу освіту на філософському факультеті Київського державного університету ім. Т.Шевченка. Навчався і працював в Інституті філософії Академії наук УРСР.

З 1970 року — аспірант, молодший науковий співробітник відділу діалектичного матеріалізму Інституту філософії Академії наук УРСР.

З 1974 року — консультант з питань філософії, заступник завідувача Київського будинку політосвіти.

З 1980 року — інструктор відділу пропаганди, заступник завідувача відділу пропаганди Київського міського комітету КПУ.

З 1984 року — інструктор відділу пропаганди, консультант загального відділу ЦК КПУ.

З 1988 року — помічник Другого, Першого секретаря ЦК КПУ.

У 1990—1991 роках — завідувач ідеологічного відділу ЦК Компартії України.

З березня 1990 — Депутат Верховної ради УРСР 12-го скликання та Народний депутат України 1-го скликання, обраний у Новоукраїнському виборчому окрузі № 234 (Кіровоградська область). Член Комісії Верховної Ради у закордонних справах.

З жовтня 1991 р. член Соціалістичної партії України. Брав участь у роботі оргкомітету щодо створення партії. Обирався до керівних органів партії, Головою ЦКК, членом Політради СПУ. Член бюро Київської міської організації СПУ.

З 1994 року — помічник Голови Верховної Ради України.

З березня 1998 по квітень 2002 — Народний депутат України 3-го скликання, обраний за виборчим списком Соціалістичної партії України. Заступник голови Комітету у закордонних справах. Працював над законопроєктами з питань соціальної політики, розвитку системи місцевого самоврядування, правового забезпечення міжнародної діяльності України. Очолював українську частину (співголова) першого складу Комітету з питань міжпарламентського співробітництва Україна — ЄС. Керівник групи міжпарламентських зв'язків Україна — Велика Британія.

Автор і співавтор законів про зовнішньополітичну й економічну діяльність держави.

Активно працював над розвитком міжпарламентських зв'язків України, утвердженням її зовнішньополітичного авторитету. Ініціатор ухвалення рішень Верховної Ради України щодо вступу України до МПА СНД та Міжпарламентського Союзу (МПС).

Нагороди

Ордена «За заслуги» III ступеня (серпень 1998).

Примітки

Посилання
 Сайт СПУ

Народні депутати України 1-го скликання
Народні депутати України 3-го скликання
Уродженці Світловодського району
Члени Соціалістичної партії України

redpajama_set_name: RedPajamaWikipedia


Clear Your Mind x L.S.
The homie S.T.T.R.E.S.S. outta North Carolina laced us with this beat, and since The Fam is now based out of Toronto, we linked with local MC L.S. to make this conscious cut.
Recorded by Cee and Notion @ Illnote Studios, Toronto, Canada.
Mixed, Mastered and Engineered by Notion.


The Google search algorithm versus online content marketing. This is the current debate in the world of digital marketing and communication and it's been around at least since late last year. The fickleness and unpredictability of the algorithm, combined with recent and notorious penalizations against companies that were doing the whole back linking thing wrong, has gotten many into thinking about the implications of this debate. Should SEO experts keep focusing on links and keywords, or is this kind of approach dated and all but obsolete? The truth, as always, is somewhere in the middle: the algorithm still largely dictates the trends in terms of online marketing, brand awareness, and even community building. However, there can be no talk of SEO at the moment, without taking into consideration the relevance of good content.
Content marketing is important. Brand building is important. Online PR and community management are also important. They are part of the broader picture on marketing and their growing relevance signals a more integrated approach toward digital marketing and communication. However, they do not exclude keeping track of algorithm updates – especially for companies that have come this far through keyword strategizing and optimization toward greater organic search visibility.
The worst way to think of the algorithm (or the least efficient, in milder terms) is to panic every time there is even a minor update. Not that this isn't a common occurrence. Since the beginning of 2013, guest posters, for one, have regularly run into situations in which a webmaster will have worked themselves into a frenzy after an update and changed their policy on guest posts overnight. Literally. There is, however, a proper way to look into algorithm updates – and that involves a hefty dose of data analysis, critical thinking and actual strategizing, which takes into account cold, hard facts, not speculation.
Consider the last two major updates that Google rolled out and the massive number of companies that took a heavy blow in their wake. Panda and Penguin actually managed to close down companies, which were penalized by Google, following the algorithm changes, and lost a major chunk of their visibility by being removed from the SERPs. On the one hand, it makes sense that Google should update the way their crawlers process the information on the web. On the other, though, it would be unwise (putting in mildly…) to completely disregard the algorithm and dismiss it as passé. It's still a game changer, if there ever was one.
You may have read the above statement and thought to yourself, 'Oh, great, the conspiracy of Google! Give me a break, will you…' Far from being proponents of conspiracy theories, we do believe that the gigantic search engine and its algorithm are literally changing the world as we know it, while we're living in it. Consider the allegation that every four out of five searches via search engines are being performed through Google. The company is grossing over $40,000,000,000 each year. The algorithm is effectively a gateway to the repository of the world's knowledge. And if you don't think that means changing the world, you might just be deluded.


Rapid Radio - Need to get hold of us?
Cnr Gundry + Abbey Streets behind The Dog's Bollix Irish pub.
At Rapid Radio we're happy to quote on any product, new sales, upgrades and insurance valuations.
To enquire about a specific product, please visit the products section, find the product you are after and click "Enquire". Please fill in the following information and we will get in touch with you shortly.


text:
layout: global
title: Spark MLContext Programming Guide
description: Spark MLContext Programming Guide
---

* This will become a table of contents (this text will be scraped).
{:toc}

# Overview

The Spark `MLContext` API offers a programmatic interface for interacting with SystemML from Spark using languages
such as Scala and Java. When interacting with `MLContext` from Spark, `DataFrame`s and `RDD`s can be passed
to SystemML. These data representations are converted to a
binary-block data format, allowing for SystemML's optimizations to be performed.

# Spark Shell (Scala) Example

## Start Spark Shell with SystemML

To use SystemML with the Spark Shell, the SystemML jar can be referenced using the Spark Shell's `--jars` option.
Instructions to build the SystemML jar can be found in the [SystemML GitHub README](https://github.com/apache/incubator-systemml).

{% highlight bash %}
./bin/spark-shell --executor-memory 4G --driver-memory 4G --jars SystemML.jar
{% endhighlight %}

Here is an example of Spark Shell with SystemML and YARN.

{% highlight bash %}
./bin/spark-shell --master yarn-client --num-executors 3 --driver-memory 5G --executor-memory 5G --executor-cores 4 --jars SystemML.jar
{% endhighlight %}

## Create MLContext

An `MLContext` object can be created by passing its constructor a reference to the `SparkContext`.

{% highlight scala %}
scala>import org.apache.sysml.api.MLContext
import org.apache.sysml.api.MLContext

scala> val ml = new MLContext(sc)
ml: org.apache.sysml.api.MLContext = org.apache.sysml.api.MLContext@33e38c6b
{% endhighlight %}

{% highlight scala %}
import org.apache.sysml.api.MLContext
val ml = new MLContext(sc)
{% endhighlight %}

## Create DataFrame

For demonstration purposes, we'll create a `DataFrame` consisting of 100,000 rows and 1,000 columns
of random `double`s.

{% highlight scala %}
scala> import org.apache.spark.sql._
import org.apache.spark.sql._

scala> import org.apache.spark.sql.types.{StructType,StructField,DoubleType}
import org.apache.spark.sql.types.{StructType, StructField, DoubleType}

scala> import scala.util.Random
import scala.util.Random

scala> val numRows = 100000
numRows: Int = 100000

scala> val numCols = 1000
numCols: Int = 1000

scala> val data = sc.parallelize(0 to numRows-1).map { _ => Row.fromSeq(Seq.fill(numCols)(Random.nextDouble)) }
data: org.apache.spark.rdd.RDD[org.apache.spark.sql.Row] = MapPartitionsRDD[1] at map at <console>:33

scala> val schema = StructType((0 to numCols-1).map { i => StructField("C" + i, DoubleType, true) } )
schema: org.apache.spark.sql.types.StructType = StructType(StructField(C0,DoubleType,true), StructField(C1,DoubleType,true), StructField(C2,DoubleType,true), StructField(C3,DoubleType,true), StructField(C4,DoubleType,true), StructField(C5,DoubleType,true), StructField(C6,DoubleType,true), StructField(C7,DoubleType,true), StructField(C8,DoubleType,true), StructField(C9,DoubleType,true), StructField(C10,DoubleType,true), StructField(C11,DoubleType,true), StructField(C12,DoubleType,true), StructField(C13,DoubleType,true), StructField(C14,DoubleType,true), StructField(C15,DoubleType,true), StructField(C16,DoubleType,true), StructField(C17,DoubleType,true), StructField(C18,DoubleType,true), StructField(C19,DoubleType,true), StructField(C20,DoubleType,true), StructField(C21,DoubleType,true), ...

scala> val df = sqlContext.createDataFrame(data, schema)
df: org.apache.spark.sql.DataFrame = [C0: double, C1: double, C2: double, C3: double, C4: double, C5: double, C6: double, C7: double, C8: double, C9: double, C10: double, C11: double, C12: double, C13: double, C14: double, C15: double, C16: double, C17: double, C18: double, C19: double, C20: double, C21: double, C22: double, C23: double, C24: double, C25: double, C26: double, C27: double, C28: double, C29: double, C30: double, C31: double, C32: double, C33: double, C34: double, C35: double, C36: double, C37: double, C38: double, C39: double, C40: double, C41: double, C42: double, C43: double, C44: double, C45: double, C46: double, C47: double, C48: double, C49: double, C50: double, C51: double, C52: double, C53: double, C54: double, C55: double, C56: double, C57: double, C58: double, C5...

{% endhighlight %}

{% highlight scala %}
import org.apache.spark.sql._
import org.apache.spark.sql.types.{StructType,StructField,DoubleType}
import scala.util.Random
val numRows = 100000
val numCols = 1000
val data = sc.parallelize(0 to numRows-1).map { _ => Row.fromSeq(Seq.fill(numCols)(Random.nextDouble)) }
val schema = StructType((0 to numCols-1).map { i => StructField("C" + i, DoubleType, true) } )
val df = sqlContext.createDataFrame(data, schema)
{% endhighlight %}

## Helper Methods

For convenience, we'll create some helper methods. The SystemML output data is encapsulated in
an `MLOutput` object. The `getScalar()` method extracts a scalar value from a `DataFrame` returned by
`MLOutput`. The `getScalarDouble()` method returns such a value as a `Double`, and the
`getScalarInt()` method returns such a value as an `Int`.

{% highlight scala %}
scala> import org.apache.sysml.api.MLOutput
import org.apache.sysml.api.MLOutput

scala> def getScalar(outputs: MLOutput, symbol: String): Any =
     | outputs.getDF(sqlContext, symbol).first()(1)
getScalar: (outputs: org.apache.sysml.api.MLOutput, symbol: String)Any

scala> def getScalarDouble(outputs: MLOutput, symbol: String): Double =
     | getScalar(outputs, symbol).asInstanceOf[Double]
getScalarDouble: (outputs: org.apache.sysml.api.MLOutput, symbol: String)Double

scala> def getScalarInt(outputs: MLOutput, symbol: String): Int =
     | getScalarDouble(outputs, symbol).toInt
getScalarInt: (outputs: org.apache.sysml.api.MLOutput, symbol: String)Int

{% endhighlight %}

{% highlight scala %}
import org.apache.sysml.api.MLOutput
def getScalar(outputs: MLOutput, symbol: String): Any =
outputs.getDF(sqlContext, symbol).first()(1)
def getScalarDouble(outputs: MLOutput, symbol: String): Double =
getScalar(outputs, symbol).asInstanceOf[Double]
def getScalarInt(outputs: MLOutput, symbol: String): Int =
getScalarDouble(outputs, symbol).toInt

{% endhighlight %}

## Convert DataFrame to Binary-Block Matrix

SystemML is optimized to operate on a binary-block format for matrix representation. For large
datasets, conversion from DataFrame to binary-block can require a significant quantity of time.
Explicit DataFrame to binary-block conversion allows algorithm performance to be measured separately
from data conversion time.

The SystemML binary-block matrix representation can be thought of as a two-dimensional array of blocks, where each block
consists of a number of rows and columns. In this example, we specify a matrix consisting
of blocks of size 1000x1000. The experimental `dataFrameToBinaryBlock()` method of `RDDConverterUtilsExt` is used
to convert the `DataFrame df` to a SystemML binary-block matrix, which is represented by the datatype
`JavaPairRDD[MatrixIndexes, MatrixBlock]`.

{% highlight scala %}
scala> import org.apache.sysml.runtime.instructions.spark.utils.{RDDConverterUtilsExt => RDDConverterUtils}
import org.apache.sysml.runtime.instructions.spark.utils.{RDDConverterUtilsExt=>RDDConverterUtils}

scala> import org.apache.sysml.runtime.matrix.MatrixCharacteristics;
import org.apache.sysml.runtime.matrix.MatrixCharacteristics

scala> val numRowsPerBlock = 1000
numRowsPerBlock: Int = 1000

scala> val numColsPerBlock = 1000
numColsPerBlock: Int = 1000

scala> val mc = new MatrixCharacteristics(numRows, numCols, numRowsPerBlock, numColsPerBlock)
mc: org.apache.sysml.runtime.matrix.MatrixCharacteristics = [100000 x 1000, nnz=-1, blocks (1000 x 1000)]

scala> val sysMlMatrix = RDDConverterUtils.dataFrameToBinaryBlock(sc, df, mc, false)
sysMlMatrix: org.apache.spark.api.java.JavaPairRDD[org.apache.sysml.runtime.matrix.data.MatrixIndexes,org.apache.sysml.runtime.matrix.data.MatrixBlock] = org.apache.spark.api.java.JavaPairRDD@2bce3248

{% endhighlight %}

{% highlight scala %}
import org.apache.sysml.runtime.instructions.spark.utils.{RDDConverterUtilsExt => RDDConverterUtils}
import org.apache.sysml.runtime.matrix.MatrixCharacteristics;
val numRowsPerBlock = 1000
val numColsPerBlock = 1000
val mc = new MatrixCharacteristics(numRows, numCols, numRowsPerBlock, numColsPerBlock)
val sysMlMatrix = RDDConverterUtils.dataFrameToBinaryBlock(sc, df, mc, false)

{% endhighlight %}

## DML Script

For this example, we will utilize the following DML Script called `shape.dml` that reads in a matrix and outputs the number of rows and the
number of columns, each represented as a matrix.

{% highlight r %}
X = read($Xin)
m = matrix(nrow(X), rows=1, cols=1)
n = matrix(ncol(X), rows=1, cols=1)
write(m, $Mout)
write(n, $Nout)
{% endhighlight %}

## Execute Script

Let's execute our DML script, as shown in the example below. The call to `reset()` of `MLContext` is not necessary here, but this method should
be called if you need to reset inputs and outputs or if you would like to call `execute()` with a different script.

An example of registering the `DataFrame df` as an input to the `X` variable is shown but commented out. If a DataFrame is registered directly,
it will implicitly be converted to SystemML's binary-block format. However, since we've already explicitly converted the DataFrame to the
binary-block fixed variable `systemMlMatrix`, we will register this input to the `X` variable. We register the `m` and `n` variables
as outputs.

When SystemML is executed via `DMLScript` (such as in Standalone Mode), inputs are supplied as either command-line named arguments
or positional argument. These inputs are specified in DML scripts by prepending them with a `$`. Values are read from or written
to files using `read`/`write` (DML) and `load`/`save` (PyDML) statements. When utilizing the `MLContext` API,
inputs and outputs can be other data representations, such as `DataFrame`s. The input and output data are bound to DML variables.
The named arguments in the `shape.dml` script do not have default values set for them, so we create a `Map` to map the required named
arguments to blank `String`s so that the script can pass validation.

The `shape.dml` script is executed by the call to `execute()`, where we supply the `Map` of required named arguments. The
execution results are returned as the `MLOutput` fixed variable `outputs`. The number of rows is obtained by calling the `getStaticInt()`
helper method with the `outputs` object and `"m"`. The number of columns is retrieved by calling `getStaticInt()` with
`outputs` and `"n"`.

{% highlight scala %}
scala> ml.reset()

scala> //ml.registerInput("X", df) // implicit conversion of DataFrame to binary-block

scala> ml.registerInput("X", sysMlMatrix, numRows, numCols)

scala> ml.registerOutput("m")

scala> ml.registerOutput("n")

scala> val nargs = Map("Xin" -> " ", "Mout" -> " ", "Nout" -> " ")
nargs: scala.collection.immutable.Map[String,String] = Map(Xin -> " ", Mout -> " ", Nout -> " ")

scala> val outputs = ml.execute("shape.dml", nargs)
15/10/12 16:29:15 WARN : Your hostname, derons-mbp.usca.ibm.com resolves to a loopback/non-reachable address: 127.0.0.1, but we couldn't find any external IP address!
15/10/12 16:29:15 WARN OptimizerUtils: Auto-disable multi-threaded text read for 'text' and 'csv' due to thread contention on JRE < 1.8 (java.version=1.7.0_80).
outputs: org.apache.sysml.api.MLOutput = org.apache.sysml.api.MLOutput@4d424743

scala> val m = getScalarInt(outputs, "m")
m: Int = 100000

scala> val n = getScalarInt(outputs, "n")
n: Int = 1000

{% endhighlight %}

{% highlight scala %}
ml.reset()
//ml.registerInput("X", df) // implicit conversion of DataFrame to binary-block
ml.registerInput("X", sysMlMatrix, numRows, numCols)
ml.registerOutput("m")
ml.registerOutput("n")
val nargs = Map("Xin" -> " ", "Mout" -> " ", "Nout" -> " ")
val outputs = ml.execute("shape.dml", nargs)
val m = getScalarInt(outputs, "m")
val n = getScalarInt(outputs, "n")

{% endhighlight %}

## DML Script as String

The `MLContext` API allows a DML script to be specified
as a `String`. Here, we specify a DML script as a fixed `String` variable called `minMaxMeanScript`.
This DML will find the minimum, maximum, and mean value of a matrix.

{% highlight scala %}
scala> val minMaxMeanScript: String =
     | """
     | Xin = read(" ")
     | minOut = matrix(min(Xin), rows=1, cols=1)
     | maxOut = matrix(max(Xin), rows=1, cols=1)
     | meanOut = matrix(mean(Xin), rows=1, cols=1)
     | write(minOut, " ")
     | write(maxOut, " ")
     | write(meanOut, " ")
     | """
minMaxMeanScript: String =
"
Xin = read(" ")
minOut = matrix(min(Xin), rows=1, cols=1)
maxOut = matrix(max(Xin), rows=1, cols=1)
meanOut = matrix(mean(Xin), rows=1, cols=1)
write(minOut, " ")
write(maxOut, " ")
write(meanOut, " ")
"

{% endhighlight %}

{% highlight scala %}
val minMaxMeanScript: String =
"""
Xin = read(" ")
minOut = matrix(min(Xin), rows=1, cols=1)
maxOut = matrix(max(Xin), rows=1, cols=1)
meanOut = matrix(mean(Xin), rows=1, cols=1)
write(minOut, " ")
write(maxOut, " ")
write(meanOut, " ")
"""

{% endhighlight %}

## Scala Wrapper for DML

We can create a Scala wrapper for our invocation of the `minMaxMeanScript` DML `String`. The `minMaxMean()` method
takes a `JavaPairRDD[MatrixIndexes, MatrixBlock]` parameter, which is a SystemML binary-block matrix representation.
It also takes a `rows` parameter indicating the number of rows in the matrix, a `cols` parameter indicating the number
of columns in the matrix, and an `MLContext` parameter. The `minMaxMean()` method
returns a tuple consisting of the minimum value in the matrix, the maximum value in the matrix, and the computed
mean value of the matrix.

{% highlight scala %}
scala> import org.apache.sysml.runtime.matrix.data.MatrixIndexes
import org.apache.sysml.runtime.matrix.data.MatrixIndexes

scala> import org.apache.sysml.runtime.matrix.data.MatrixBlock
import org.apache.sysml.runtime.matrix.data.MatrixBlock

scala> import org.apache.spark.api.java.JavaPairRDD
import org.apache.spark.api.java.JavaPairRDD

scala> def minMaxMean(mat: JavaPairRDD[MatrixIndexes, MatrixBlock], rows: Int, cols: Int, ml: MLContext): (Double, Double, Double) = {
     | ml.reset()
     | ml.registerInput("Xin", mat, rows, cols)
     | ml.registerOutput("minOut")
     | ml.registerOutput("maxOut")
     | ml.registerOutput("meanOut")
     | val outputs = ml.executeScript(minMaxMeanScript)
     | val minOut = getScalarDouble(outputs, "minOut")
     | val maxOut = getScalarDouble(outputs, "maxOut")
     | val meanOut = getScalarDouble(outputs, "meanOut")
     | (minOut, maxOut, meanOut)
     | }
minMaxMean: (mat: org.apache.spark.api.java.JavaPairRDD[org.apache.sysml.runtime.matrix.data.MatrixIndexes,org.apache.sysml.runtime.matrix.data.MatrixBlock], rows: Int, cols: Int, ml: org.apache.sysml.api.MLContext)(Double, Double, Double)

{% endhighlight %}

{% highlight scala %}
import org.apache.sysml.runtime.matrix.data.MatrixIndexes
import org.apache.sysml.runtime.matrix.data.MatrixBlock
import org.apache.spark.api.java.JavaPairRDD
def minMaxMean(mat: JavaPairRDD[MatrixIndexes, MatrixBlock], rows: Int, cols: Int, ml: MLContext): (Double, Double, Double) = {
ml.reset()
ml.registerInput("Xin", mat, rows, cols)
ml.registerOutput("minOut")
ml.registerOutput("maxOut")
ml.registerOutput("meanOut")
val outputs = ml.executeScript(minMaxMeanScript)
val minOut = getScalarDouble(outputs, "minOut")
val maxOut = getScalarDouble(outputs, "maxOut")
val meanOut = getScalarDouble(outputs, "meanOut")
(minOut, maxOut, meanOut)
}

{% endhighlight %}

## Invoking DML via Scala Wrapper

Here, we invoke `minMaxMeanScript` using our `minMaxMean()` Scala wrapper method. It returns a tuple
consisting of the minimum value in the matrix, the maximum value in the matrix, and the mean value of the matrix.

{% highlight scala %}
scala> val (min, max, mean) = minMaxMean(sysMlMatrix, numRows, numCols, ml)
15/10/13 14:33:11 WARN OptimizerUtils: Auto-disable multi-threaded text read for 'text' and 'csv' due to thread contention on JRE < 1.8 (java.version=1.7.0_80).
min: Double = 5.378949397005783E-9
max: Double = 0.9999999934660398
mean: Double = 0.499988222338507

{% endhighlight %}

{% highlight scala %}
val (min, max, mean) = minMaxMean(sysMlMatrix, numRows, numCols, ml)

{% endhighlight %}

* * *

# Java Example

Next, let's consider a Java example. The `MLContextExample` class creates an `MLContext` object from a `JavaSparkContext`.
Next, it reads in a matrix CSV file as a `JavaRDD<String>` object. It registers this as input `X`. It registers
two outputs, `m` and `n`. A `HashMap` maps the expected command-line arguments of the `shape.dml` script to spaces so that
it passes validation. The `shape.dml` script is executed, and the number of rows and columns in the matrix are output
to standard output.

{% highlight java %}
package org.apache.sysml;

import java.util.HashMap;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.DataFrame;
import org.apache.spark.sql.SQLContext;

import org.apache.sysml.api.MLContext;
import org.apache.sysml.api.MLOutput;

public class MLContextExample {

	public static void main(String[] args) throws Exception {

		SparkConf conf = new SparkConf().setAppName("MLContextExample").setMaster("local");
		JavaSparkContext sc = new JavaSparkContext(conf);
		SQLContext sqlContext = new SQLContext(sc);
		MLContext ml = new MLContext(sc);

		JavaRDD<String> csv = sc.textFile("A.csv");
		ml.registerInput("X", csv, "csv");
		ml.registerOutput("m");
		ml.registerOutput("n");
		HashMap<String, String> cmdLineArgs = new HashMap<String, String>();
		cmdLineArgs.put("X", " ");
		cmdLineArgs.put("m", " ");
		cmdLineArgs.put("n", " ");
		MLOutput output = ml.execute("shape.dml", cmdLineArgs);
		DataFrame mDf = output.getDF(sqlContext, "m");
		DataFrame nDf = output.getDF(sqlContext, "n");
		System.out.println("rows:" + mDf.first().getDouble(1));
		System.out.println("cols:" + nDf.first().getDouble(1));
	}

}

{% endhighlight %}

* * *

# Zeppelin Notebook Example - Linear Regression Algorithm

Next, we'll consider an example of a SystemML linear regression algorithm run from Spark through an Apache Zeppelin notebook.
Instructions to clone and build Zeppelin can be found at the [GitHub Apache Zeppelin](https://github.com/apache/incubator-zeppelin)
site. This example also will look at the Spark ML linear regression algorithm.

This Zeppelin notebook example can be imported by choosing `Import note` -> `Add from URL` from the Zeppelin main page, then insert the following URL:

    https://raw.githubusercontent.com/apache/incubator-systemml/master/samples/zeppelin-notebooks/2AZ2AQ12B/note.json

Alternatively download note.json, then import it by choosing `Import note` -> `Choose a JSON here` from the Zeppelin main page.

A `conf/zeppelin-env.sh` file is created based on `conf/zeppelin-env.sh.template`. For
this demonstration, it features `SPARK_HOME`, `SPARK_SUBMIT_OPTIONS`, and `ZEPPELIN_SPARK_USEHIVECONTEXT`
environment variables:

	export SPARK_HOME=/Users/example/spark-1.5.1-bin-hadoop2.6
	export SPARK_SUBMIT_OPTIONS="--jars /Users/example/systemml/system-ml/target/SystemML.jar"
	export ZEPPELIN_SPARK_USEHIVECONTEXT=false

Start Zeppelin using the `zeppelin.sh` script:

	bin/zeppelin.sh

After opening Zeppelin in a brower, we see the "SystemML - Linear Regression" note in the list of available
Zeppelin notes.

![Zeppelin Notebook](img/spark-mlcontext-programming-guide/zeppelin-notebook.png "Zeppelin Notebook")

If we go to the "SystemML - Linear Regression" note, we see that the note consists of several cells of code.

![Zeppelin 'SystemML - Linear Regression' Note](img/spark-mlcontext-programming-guide/zeppelin-notebook-systemml-linear-regression.png "Zeppelin 'SystemML - Linear Regression' Note")

Let's briefly consider these cells.

## Trigger Spark Startup

This cell triggers Spark to initialize by calling the `SparkContext` `sc` object. Information regarding these startup operations can be viewed in the
console window in which `zeppelin.sh` is running.

**Cell:**
{% highlight scala %}
// Trigger Spark Startup
sc
{% endhighlight %}

**Output:**
{% highlight scala %}
res8: org.apache.spark.SparkContext = org.apache.spark.SparkContext@6ce70bf3
{% endhighlight %}

## Generate Linear Regression Test Data

The Spark `LinearDataGenerator` is used to generate test data for the Spark ML and SystemML linear regression algorithms.

**Cell:**
{% highlight scala %}
// Generate data
import org.apache.spark.mllib.util.LinearDataGenerator

val numRows = 10000
val numCols = 1000
val rawData = LinearDataGenerator.generateLinearRDD(sc, numRows, numCols, 1).toDF()

// Repartition into a more parallelism-friendly number of partitions
val data = rawData.repartition(64).cache()
{% endhighlight %}

**Output:**
{% highlight scala %}
import org.apache.spark.mllib.util.LinearDataGenerator
numRows: Int = 10000
numCols: Int = 1000
rawData: org.apache.spark.sql.DataFrame = [label: double, features: vector]
data: org.apache.spark.sql.DataFrame = [label: double, features: vector]
{% endhighlight %}

## Train using Spark ML Linear Regression Algorithm for Comparison

For purpose of comparison, we can train a model using the Spark ML linear regression
algorithm.

**Cell:**
{% highlight scala %}
// Spark ML
import org.apache.spark.ml.regression.LinearRegression

// Model Settings
val maxIters = 100
val reg = 0
val elasticNetParam = 0  // L2 reg

// Fit the model
val lr = new LinearRegression()
  .setMaxIter(maxIters)
  .setRegParam(reg)
  .setElasticNetParam(elasticNetParam)
val start = System.currentTimeMillis()
val model = lr.fit(data)
val trainingTime = (System.currentTimeMillis() - start).toDouble / 1000.0

// Summarize the model over the training set and gather some metrics
val trainingSummary = model.summary
val r2 = trainingSummary.r2
val iters = trainingSummary.totalIterations
val trainingTimePerIter = trainingTime / iters
{% endhighlight %}

**Output:**
{% highlight scala %}
import org.apache.spark.ml.regression.LinearRegression
maxIters: Int = 100
reg: Int = 0
elasticNetParam: Int = 0
lr: org.apache.spark.ml.regression.LinearRegression = linReg_a7f51d676562
start: Long = 1444672044647
model: org.apache.spark.ml.regression.LinearRegressionModel = linReg_a7f51d676562
trainingTime: Double = 12.985
trainingSummary: org.apache.spark.ml.regression.LinearRegressionTrainingSummary = org.apache.spark.ml.regression.LinearRegressionTrainingSummary@227ba28b
r2: Double = 0.9677118209276552
iters: Int = 17
trainingTimePerIter: Double = 0.7638235294117647
{% endhighlight %}

## Spark ML Linear Regression Summary Statistics

Summary statistics for the Spark ML linear regression algorithm are displayed by this cell.

**Cell:**
{% highlight scala %}
// Print statistics
println(s"R2: ${r2}")
println(s"Iterations: ${iters}")
println(s"Training time per iter: ${trainingTimePerIter} seconds")
{% endhighlight %}

**Output:**
{% highlight scala %}
R2: 0.9677118209276552
Iterations: 17
Training time per iter: 0.7638235294117647 seconds
{% endhighlight %}

## SystemML Linear Regression Algorithm

The `linearReg` fixed `String` variable is set to
a linear regression algorithm written in DML, SystemML's Declarative Machine Learning language.

**Cell:**
{% highlight scala %}
// SystemML kernels
val linearReg =
"""
#
# THIS SCRIPT SOLVES LINEAR REGRESSION USING THE CONJUGATE GRADIENT ALGORITHM
#
# INPUT PARAMETERS:
# --------------------------------------------------------------------------------------------
# NAME  TYPE   DEFAULT  MEANING
# --------------------------------------------------------------------------------------------
# X     String  ---     Matrix X of feature vectors
# Y     String  ---     1-column Matrix Y of response values
# icpt  Int      0      Intercept presence, shifting and rescaling the columns of X:
#                       0 = no intercept, no shifting, no rescaling;
#                       1 = add intercept, but neither shift nor rescale X;
#                       2 = add intercept, shift & rescale X columns to mean = 0, variance = 1
# reg   Double 0.000001 Regularization constant (lambda) for L2-regularization; set to nonzero
#                       for highly dependend/sparse/numerous features
# tol   Double 0.000001 Tolerance (epsilon); conjugate graduent procedure terminates early if
#                       L2 norm of the beta-residual is less than tolerance * its initial norm
# maxi  Int      0      Maximum number of conjugate gradient iterations, 0 = no maximum
# --------------------------------------------------------------------------------------------
#
# OUTPUT:
# B Estimated regression parameters (the betas) to store
#
# Note: Matrix of regression parameters (the betas) and its size depend on icpt input value:
#         OUTPUT SIZE:   OUTPUT CONTENTS:                HOW TO PREDICT Y FROM X AND B:
# icpt=0: ncol(X)   x 1  Betas for X only                Y ~ X %*% B[1:ncol(X), 1], or just X %*% B
# icpt=1: ncol(X)+1 x 1  Betas for X and intercept       Y ~ X %*% B[1:ncol(X), 1] + B[ncol(X)+1, 1]
# icpt=2: ncol(X)+1 x 2  Col.1: betas for X & intercept  Y ~ X %*% B[1:ncol(X), 1] + B[ncol(X)+1, 1]
#                        Col.2: betas for shifted/rescaled X and intercept
#

fileX = "";
fileY = "";
fileB = "";

intercept_status = ifdef ($icpt, 0);     # $icpt=0;
tolerance = ifdef ($tol, 0.000001);      # $tol=0.000001;
max_iteration = ifdef ($maxi, 0);        # $maxi=0;
regularization = ifdef ($reg, 0.000001); # $reg=0.000001;

X = read (fileX);
y = read (fileY);

n = nrow (X);
m = ncol (X);
ones_n = matrix (1, rows = n, cols = 1);
zero_cell = matrix (0, rows = 1, cols = 1);

# Introduce the intercept, shift and rescale the columns of X if needed

m_ext = m;
if (intercept_status == 1 | intercept_status == 2)  # add the intercept column
{
    X = append (X, ones_n);
    m_ext = ncol (X);
}

scale_lambda = matrix (1, rows = m_ext, cols = 1);
if (intercept_status == 1 | intercept_status == 2)
{
    scale_lambda [m_ext, 1] = 0;
}

if (intercept_status == 2)  # scale-&-shift X columns to mean 0, variance 1
{                           # Important assumption: X [, m_ext] = ones_n
    avg_X_cols = t(colSums(X)) / n;
    var_X_cols = (t(colSums (X ^ 2)) - n * (avg_X_cols ^ 2)) / (n - 1);
    is_unsafe = ppred (var_X_cols, 0.0, "<=");
    scale_X = 1.0 / sqrt (var_X_cols * (1 - is_unsafe) + is_unsafe);
    scale_X [m_ext, 1] = 1;
    shift_X = - avg_X_cols * scale_X;
    shift_X [m_ext, 1] = 0;
} else {
    scale_X = matrix (1, rows = m_ext, cols = 1);
    shift_X = matrix (0, rows = m_ext, cols = 1);
}

# Henceforth, if intercept_status == 2, we use "X %*% (SHIFT/SCALE TRANSFORM)"
# instead of "X".  However, in order to preserve the sparsity of X,
# we apply the transform associatively to some other part of the expression
# in which it occurs.  To avoid materializing a large matrix, we rewrite it:
#
# ssX_A  = (SHIFT/SCALE TRANSFORM) %*% A    --- is rewritten as:
# ssX_A  = diag (scale_X) %*% A;
# ssX_A [m_ext, ] = ssX_A [m_ext, ] + t(shift_X) %*% A;
#
# tssX_A = t(SHIFT/SCALE TRANSFORM) %*% A   --- is rewritten as:
# tssX_A = diag (scale_X) %*% A + shift_X %*% A [m_ext, ];

lambda = scale_lambda * regularization;
beta_unscaled = matrix (0, rows = m_ext, cols = 1);

if (max_iteration == 0) {
    max_iteration = m_ext;
}
i = 0;

# BEGIN THE CONJUGATE GRADIENT ALGORITHM
r = - t(X) %*% y;

if (intercept_status == 2) {
    r = scale_X * r + shift_X %*% r [m_ext, ];
}

p = - r;
norm_r2 = sum (r ^ 2);
norm_r2_initial = norm_r2;
norm_r2_target = norm_r2_initial * tolerance ^ 2;

while (i < max_iteration & norm_r2 > norm_r2_target)
{
    if (intercept_status == 2) {
        ssX_p = scale_X * p;
        ssX_p [m_ext, ] = ssX_p [m_ext, ] + t(shift_X) %*% p;
    } else {
        ssX_p = p;
    }

    q = t(X) %*% (X %*% ssX_p);

    if (intercept_status == 2) {
        q = scale_X * q + shift_X %*% q [m_ext, ];
    }

    q = q + lambda * p;
    a = norm_r2 / sum (p * q);
    beta_unscaled = beta_unscaled + a * p;
    r = r + a * q;
    old_norm_r2 = norm_r2;
    norm_r2 = sum (r ^ 2);
    p = -r + (norm_r2 / old_norm_r2) * p;
    i = i + 1;
}
# END THE CONJUGATE GRADIENT ALGORITHM

if (intercept_status == 2) {
    beta = scale_X * beta_unscaled;
    beta [m_ext, ] = beta [m_ext, ] + t(shift_X) %*% beta_unscaled;
} else {
    beta = beta_unscaled;
}

# Output statistics
avg_tot = sum (y) / n;
ss_tot = sum (y ^ 2);
ss_avg_tot = ss_tot - n * avg_tot ^ 2;
var_tot = ss_avg_tot / (n - 1);
y_residual = y - X %*% beta;
avg_res = sum (y_residual) / n;
ss_res = sum (y_residual ^ 2);
ss_avg_res = ss_res - n * avg_res ^ 2;

R2_temp = 1 - ss_res / ss_avg_tot
R2 = matrix(R2_temp, rows=1, cols=1)
write(R2, "")

totalIters = matrix(i, rows=1, cols=1)
write(totalIters, "")

# Prepare the output matrix
if (intercept_status == 2) {
    beta_out = append (beta, beta_unscaled);
} else {
    beta_out = beta;
}

write (beta_out, fileB);
"""
{% endhighlight %}

**Output:**

None

## Helper Methods

This cell contains helper methods to return `Double` and `Int` values from output generated by the `MLContext` API.

**Cell:**
{% highlight scala %}
// Helper functions
import org.apache.sysml.api.MLOutput

def getScalar(outputs: MLOutput, symbol: String): Any =
    outputs.getDF(sqlContext, symbol).first()(1)

def getScalarDouble(outputs: MLOutput, symbol: String): Double =
    getScalar(outputs, symbol).asInstanceOf[Double]

def getScalarInt(outputs: MLOutput, symbol: String): Int =
    getScalarDouble(outputs, symbol).toInt
{% endhighlight %}

**Output:**
{% highlight scala %}
import org.apache.sysml.api.MLOutput
getScalar: (outputs: org.apache.sysml.api.MLOutput, symbol: String)Any
getScalarDouble: (outputs: org.apache.sysml.api.MLOutput, symbol: String)Double
getScalarInt: (outputs: org.apache.sysml.api.MLOutput, symbol: String)Int
{% endhighlight %}

## Convert DataFrame to Binary-Block Format

SystemML uses a binary-block format for matrix data representation. This cell
explicitly converts the `DataFrame` `data` object to a binary-block `features` matrix
and single-column `label` matrix, both represented by the
`JavaPairRDD[MatrixIndexes, MatrixBlock]` datatype.

**Cell:**
{% highlight scala %}
// Imports
import org.apache.sysml.api.MLContext
import org.apache.sysml.runtime.instructions.spark.utils.{RDDConverterUtilsExt => RDDConverterUtils}
import org.apache.sysml.runtime.matrix.MatrixCharacteristics;

// Create SystemML context
val ml = new MLContext(sc)

// Convert data to proper format
val mcX = new MatrixCharacteristics(numRows, numCols, 1000, 1000)
val mcY = new MatrixCharacteristics(numRows, 1, 1000, 1000)
val X = RDDConverterUtils.vectorDataFrameToBinaryBlock(sc, data, mcX, false, "features")
val y = RDDConverterUtils.dataFrameToBinaryBlock(sc, data.select("label"), mcY, false)
// val y = data.select("label")

// Cache
val X2 = X.cache()
val y2 = y.cache()
val cnt1 = X2.count()
val cnt2 = y2.count()
{% endhighlight %}

**Output:**
{% highlight scala %}
import org.apache.sysml.api.MLContext
import org.apache.sysml.runtime.instructions.spark.utils.{RDDConverterUtilsExt=>RDDConverterUtils}
import org.apache.sysml.runtime.matrix.MatrixCharacteristics
ml: org.apache.sysml.api.MLContext = org.apache.sysml.api.MLContext@38d59245
mcX: org.apache.sysml.runtime.matrix.MatrixCharacteristics = [10000 x 1000, nnz=-1, blocks (1000 x 1000)]
mcY: org.apache.sysml.runtime.matrix.MatrixCharacteristics = [10000 x 1, nnz=-1, blocks (1000 x 1000)]
X: org.apache.spark.api.java.JavaPairRDD[org.apache.sysml.runtime.matrix.data.MatrixIndexes,org.apache.sysml.runtime.matrix.data.MatrixBlock] = org.apache.spark.api.java.JavaPairRDD@b5a86e3
y: org.apache.spark.api.java.JavaPairRDD[org.apache.sysml.runtime.matrix.data.MatrixIndexes,org.apache.sysml.runtime.matrix.data.MatrixBlock] = org.apache.spark.api.java.JavaPairRDD@56377665
X2: org.apache.spark.api.java.JavaPairRDD[org.apache.sysml.runtime.matrix.data.MatrixIndexes,org.apache.sysml.runtime.matrix.data.MatrixBlock] = org.apache.spark.api.java.JavaPairRDD@650f29d2
y2: org.apache.spark.api.java.JavaPairRDD[org.apache.sysml.runtime.matrix.data.MatrixIndexes,org.apache.sysml.runtime.matrix.data.MatrixBlock] = org.apache.spark.api.java.JavaPairRDD@334857a8
cnt1: Long = 10
cnt2: Long = 10
{% endhighlight %}

## Train using SystemML Linear Regression Algorithm

Now, we can train our model using the SystemML linear regression algorithm. We register the features matrix `X` and the label matrix `y` as inputs. We register the `beta_out` matrix,
`R2`, and `totalIters` as outputs.

**Cell:**
{% highlight scala %}
// Register inputs & outputs
ml.reset()
ml.registerInput("X", X, numRows, numCols)
ml.registerInput("y", y, numRows, 1)
// ml.registerInput("y", y)
ml.registerOutput("beta_out")
ml.registerOutput("R2")
ml.registerOutput("totalIters")

// Run the script
val start = System.currentTimeMillis()
val outputs = ml.executeScript(linearReg)
val trainingTime = (System.currentTimeMillis() - start).toDouble / 1000.0

// Get outputs
val B = outputs.getDF(sqlContext, "beta_out").sort("ID").drop("ID")
val r2 = getScalarDouble(outputs, "R2")
val iters = getScalarInt(outputs, "totalIters")
val trainingTimePerIter = trainingTime / iters
{% endhighlight %}

**Output:**
{% highlight scala %}
start: Long = 1444672090620
outputs: org.apache.sysml.api.MLOutput = org.apache.sysml.api.MLOutput@5d2c22d0
trainingTime: Double = 1.176
B: org.apache.spark.sql.DataFrame = [C1: double]
r2: Double = 0.9677079547216473
iters: Int = 12
trainingTimePerIter: Double = 0.09799999999999999
{% endhighlight %}

## SystemML Linear Regression Summary Statistics

SystemML linear regression summary statistics are displayed by this cell.

**Cell:**
{% highlight scala %}
// Print statistics
println(s"R2: ${r2}")
println(s"Iterations: ${iters}")
println(s"Training time per iter: ${trainingTimePerIter} seconds")
B.describe().show()
{% endhighlight %}

**Output:**
{% highlight scala %}
R2: 0.9677079547216473
Iterations: 12
Training time per iter: 0.2334166666666667 seconds
+-------+-------------------+
|summary|                 C1|
+-------+-------------------+
|  count|               1000|
|   mean| 0.0184500840658385|
| stddev| 0.2764750319432085|
|    min|-0.5426068958986378|
|    max| 0.5225309861616542|
+-------+-------------------+
{% endhighlight %}

* * *

# Jupyter (PySpark) Notebook Example - Poisson Nonnegative Matrix Factorization

Here, we'll explore the use of SystemML via PySpark in a [Jupyter notebook](http://jupyter.org/).
This Jupyter notebook example can be nicely viewed in a rendered state
[on GitHub](https://github.com/apache/incubator-systemml/blob/master/samples/jupyter-notebooks/SystemML-PySpark-Recommendation-Demo.ipynb),
and can be [downloaded here](https://raw.githubusercontent.com/apache/incubator-systemml/master/samples/jupyter-notebooks/SystemML-PySpark-Recommendation-Demo.ipynb) to a directory of your choice.

From the directory with the downloaded notebook, start Jupyter with PySpark:

    PYSPARK_DRIVER_PYTHON=jupyter PYSPARK_DRIVER_PYTHON_OPTS="notebook" $SPARK_HOME/bin/pyspark --master local[*] --jars $SYSTEMML_HOME/target/SystemML.jar --py-files $SYSTEMML_HOME/src/main/java/org/apache/sysml/api/python/SystemML.py --driver-class-path $SYSTEMML_HOME/target/SystemML.jar

This will open Jupyter in a browser:

![Jupyter Notebook](img/spark-mlcontext-programming-guide/jupyter1.png "Jupyter Notebook")

We can then open up the `SystemML-PySpark-Recommendation-Demo` notebook:

![Jupyter Notebook](img/spark-mlcontext-programming-guide/jupyter2.png "Jupyter Notebook")

## Set up the notebook and download the data

{% highlight python %}
%load_ext autoreload
%autoreload 2
%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (10, 6)
{% endhighlight %}

{% highlight python %}
%%sh
# Download dataset
curl -O http://snap.stanford.edu/data/amazon0601.txt.gz
gunzip amazon0601.txt.gz
{% endhighlight %}

## Use PySpark to load the data in as a Spark DataFrame

{% highlight python %}
# Load data
import pyspark.sql.functions as F
dataPath = "amazon0601.txt"

X_train = (sc.textFile(dataPath)
    .filter(lambda l: not l.startswith("#"))
    .map(lambda l: l.split("\t"))
    .map(lambda prods: (int(prods[0]), int(prods[1]), 1.0))
    .toDF(("prod_i", "prod_j", "x_ij"))
    .filter("prod_i < 500 AND prod_j < 500") # Filter for memory constraints
    .cache())

max_prod_i = X_train.select(F.max("prod_i")).first()[0]
max_prod_j = X_train.select(F.max("prod_j")).first()[0]
numProducts = max(max_prod_i, max_prod_j) + 1 # 0-based indexing
print("Total number of products: {}".format(numProducts))
{% endhighlight %}

## Create a SystemML MLContext object

{% highlight python %}
# Create SystemML MLContext
from SystemML import MLContext
ml = MLContext(sc)
{% endhighlight %}

## Define a kernel for Poisson nonnegative matrix factorization (PNMF) in DML

{% highlight python %}
# Define PNMF kernel in SystemML's DSL using the R-like syntax for PNMF
pnmf = """
# data & args
X = read($X)
X = X+1 # change product IDs to be 1-based, rather than 0-based
V = table(X[,1], X[,2])
size = ifdef($size, -1)
if(size > -1) {
    V = V[1:size,1:size]
}
max_iteration = as.integer($maxiter)
rank = as.integer($rank)

n = nrow(V)
m = ncol(V)
range = 0.01
W = Rand(rows=n, cols=rank, min=0, max=range, pdf="uniform")
H = Rand(rows=rank, cols=m, min=0, max=range, pdf="uniform")
losses = matrix(0, rows=max_iteration, cols=1)

# run PNMF
i=1
while(i <= max_iteration) {
  # update params
  H = (H * (t(W) %*% (V/(W%*%H))))/t(colSums(W))
  W = (W * ((V/(W%*%H)) %*% t(H)))/t(rowSums(H))

  # compute loss
  losses[i,] = -1 * (sum(V*log(W%*%H)) - as.scalar(colSums(W)%*%rowSums(H)))
  i = i + 1;
}

# write outputs
write(losses, $lossout)
write(W, $Wout)
write(H, $Hout)
"""
{% endhighlight %}

## Execute the algorithm

{% highlight python %}
# Run the PNMF script on SystemML with Spark
ml.reset()
outputs = ml.executeScript(pnmf, {"X": X_train, "maxiter": 100, "rank": 10}, ["W", "H", "losses"])
{% endhighlight %}

## Retrieve the losses during training and plot them

{% highlight python %}
# Plot training loss over time
losses = outputs.getDF(sqlContext, "losses")
xy = losses.sort(losses.ID).map(lambda r: (r[0], r[1])).collect()
x, y = zip(*xy)
plt.plot(x, y)
plt.xlabel('Iteration')
plt.ylabel('Loss')
plt.title('PNMF Training Loss')
{% endhighlight %}

![Jupyter Loss Graph](img/spark-mlcontext-programming-guide/jupyter_loss_graph.png "Jupyter Loss Graph")

redpajama_set_name: RedPajamaGithub


We have provided the selection of example international relations dissertation topics below to help and inspire you.
NATO and Libya: An indefensible intervention into a sovereign state.
Notwithstanding issues as to the desirability of General Gaddafi (from a Western democratic viewpoint), NATO's involvement in the Libyan civil war helped to bring about regime change. This dissertation addresses the political motivations that enabled an organisation usually associated with peace keeping to seemingly change its operational mandate to one in which the rebel cause was directly assisted. In so doing it questions whether it is appropriate for NATO to be used as a political tool by which to further the regime change desires of its leading members (the US and the UK) and seeks to evaluate the potential damage done to NATO's reputation (in the Eastern world) as a consequence of the Libyan expedition.
Dunne, T. and Gifkins, J. (2011). 'Libya and the state of intervention', Australian Journal of International Affairs, Vol. 65(5), pp. 515-529.
Glanville, L. (2012). 'Intervention in Libya: From sovereign consent to regional consent', International Studies Perspectives, DOI: 10.1111/j.1528-3585.2012.00497.x.
Kielsgard, M. (2012). 'National self-defence in the age of terrorism: Immediacy and state attribution', Ius Gentium: Comparative Perspectives on Law and Justice, Vol. 14(4), pp. 315-343.
Syria: The steady emergence of a new Cold War front?
The re-election of Vladimir Putin as Russian president and Russia's support for Syria has led, this dissertation contends, to a fundamental shift in power-relations within the Middle East. Support for the Assad regime from Moscow has, in stark contrast to the situation in Libya, meant that neither NATO nor American or UK forces have been directly involved in supporting the rebels' cause. There has also been a substantially more muted response from the West with regard to Syrian atrocities within Turkey. Advancing the proposition that the underlying reason for this 'weakness' in response from the West (in contrast to that deployed against either Iraq or Libya) is the support for the Syrian regime from Russia; this dissertation questions whether a post-communist, new Cold War front is emerging in which Russia (under Putin) will not tolerate Western involvement in a country that has traditionally been viewed as part of Russia's 'sphere of influence'.
Guiora, A.N. (2012). 'Intervention in Libya, yes; Intervention in Syria, no: Deciphering the Obama administration', University of Utah Working Paper JEL: K33.
Hasler, S. (2012). Explaining humanitarian intervention in Libya and non-intervention in Syria. Master's thesis, US Naval Postgraduate School, Monterey, CA.
Troyansky, V. (2012). 'Russia's support for al-Asad's Syria: Reasons old and new', Syrian Studies Association Newsletter, Vol. 17(1).
A survey of the effects of sanctions upon the ordinary citizens of Iran.
The rial (Iran's currency) has plummeted from 10,500 to the US Dollar last year to a present value in the region of 37,500. The sanctions imposed upon Iran by the EU in January have resulted in the Iranian government being unable to earn foreign currency and as a result the number of bankruptcies amongst Iranian firms is rising. As UN Secretary General, Ban Ki-moon has noted, 'the sanctions have had significant effects on the general population, including an escalation in inflation, a rise in commodities and energy costs, an increase in the rate of unemployment and a shortage of necessary items, including medicine' (de Pasquale, 2012). This dissertation not only questions whether it is morally appropriate to continue to enforce sanctions that harm ordinary people but also evaluates the effects that those sanctions are having on ordinary Iranians' perceptions of both their own government and those inflicting the sanctions. Accordingly, therefore, with primary research for this study being carried out within Iran itself, this is a dissertation that benefits from a research approach that utilises both primary and secondary data.
De Pasquale, R. (2012). 'UN Chief says sanctions harm Iranians', ABC News, October 6th 2012. Available at: http://abcnews.go.com/US/wireStory/chief-sanctions-harm-iranians-17409619#.UHiRwlEmyZQ .
Peksen, D. (2011). 'Economic sanctions and human security: The public health effect of economic sanctions', Foreign Policy Analysis, Vol. 7, pp. 237-251.
Takeyh, R. and Maloney, S. (2011). 'The self-limiting success of Iran sanctions', International Affairs, Vol. 87, pp. 1297-1312.
A reappraisal of foreign aid in the age of Austerity Britain.
Undertaking an audit of existing programmes supported and funded by the UK's Department for International Development, this dissertation questions the ongoing need for Britain to give aid to India. Informed through interviews with senior politicians and bureaucrats in both Whitehall and New Delhi, this study questions the appropriateness of such aid and the political motivation behind it. In so doing it questions the extent to which the giving of aid can not only be seen as both patronising and imperialistic but also the extent to which, rather than improving relations between the two countries, it actually worsens them. For as India's Finance Minister, Pranab Mukherjee notes, India '[does] not require the aid… it is a peanut in our total development exercises [expenditure]' (Gilligan, 2012).
Dunne, M., Hall-Matthews, D. and Lightfoot, S. (2011). 'Our aid': UK international development policy under the Coalition', Political Insight, Vol. 2, pp. 29-31.
Gilligan, A. (2012). 'India tells Britain: We don't want your aid', Daily Telegraph, February 4th 2012. Available at: http://www.telegraph.co.uk/news/worldnews/asia/india/9061844/India-tells-Britain-We-dont-want-your-aid.html .
Kimura, H. and Todo, Y. (2010). 'Is foreign aid a vanguard of foreign direct investment? A gravity-equation approach', World Development, Vol 38(4), pp. 482-497.
The UN Security Council permanent members: The case for expansion or replacement.
Founded in 1946, the five permanent members of the Security Council are France, China, the United Kingdom, the United States, and the USSR (seat now occupied by Russia). Given the rise in importance of nations such as India and Japan, this dissertation presents an initial case for expanding the number of permanent members to seven. In so doing, this study is also particularly mindful of the declining military capabilities of Britain and France (who now, for instance, share aircraft carriers). Accordingly whilst it suggests that expansion of the permanent members would acknowledge the growing military and economic importance of China and India but enable the retention of traditional members such as Britain and France, it could be alternatively proffered that their seats should either be shared or given to the EU.
Blum, Y.Z. (2005). 'Proposals for UN Security Council reform', The American Journal of International Law, Vol. 99(3), pp. 632-649.
Hurd, I. (2008). 'Myths of membership: The politics of legitimation in UN Security Council reform', Global Governance: A Review of Multilateralism and International Organizations, Vol. 14(2), pp. 199-217.
McDonald, K.C. and Patrick, S.M. (2010). UN Security Council enlargement and U.S. interests. New York: Council on Foreign Relations.
A reappraisal of the Cuban Missile Crisis.
This dissertation presents a revisionist interpretation of the Cuban Missile Crisis. In so doing it re-evaluates the foreign policies pursued by both the Soviet Union and the United States and proposes that it should, at best, be interpreted as a representing only a limited diplomatic success for Kennedy's presidency. Accordingly, it suggests that whilst direct armed conflict between the Soviet Union and the United States was avoided, the longer-term results of the crisis left Kennedy's wider Latin American policies in tatters and also strengthened the Soviet position in southern Europe, through the removal of the Thor and Jupiter missiles in Turkey.
Dallek, R. (1983). The American style of foreign policy. New York: Knopf.
Furensko, A. and Naftali, T. (1997). One hell of a gamble: Khrushchev, Castro, Kennedy and the Cuban Missile Crisis: 1958-1964. London: John Murray.
Pope, R.R. (1982). Soviet views on the Cuban Missile Crisis: Myth and reality in foreign policy analysis. Washington, DC: University of Illinois .
The Warsaw Pact: A Russian defence mechanism born out of fears for security?
International relations between East and West were dominated in the latter half of the twentieth century by feelings of mistrust. In revisiting this era of international relations, this dissertation focuses on Russian fears of Western imperialism and accordingly assesses the extent to which the creation of the Warsaw Pact should be evaluated not as an example of 'creeping Russian imperialism' but rather primarily motivated by the need to safeguard herself 'against a recovered Germany or Japan or hostile capitalist states' (Offner, 2002, p. 128). Noting Stalin's comment at Yalta (1945) that the question of Poland was therefore 'not only a question of honour, but also one of security' (cited, Hanhimäki and Westad, 2003, p. 43), this is a dissertation that uses a range of primary and secondary sources to further a revisionist critique.
Hanhimäki, J.M. and Westad, O.A. (eds) (2003). The Cold War: A history in documents and eyewitness accounts. Oxford: Oxford University Press.
Offner, A.A. (2002). Another such victory: President Truman and the Cold War, 1945-1953. Stanford, CA: Stanford University Press.
Gaddis, J.L. (1987). The long peace: Enquiries into the history of the Cold War. Oxford: Oxford University Press.
Inspired by a singular desire for oil: Explaining American foreign policy in the Middle East from 1960-2000.
Senator Ernest Hollings (Democrat: South Carolina) opined, in Senate on the 12th January 1991, that President George H.W. Bush had been prompted to act over Kuwait by the need to protect American oil interests and would not act in other areas of 'naked aggression' (such as Lithuania) because 'Lithuania does not have oil'. This dissertation, in noting that America has become increasingly dependent upon imported oil since the late 1960s, advances the proposal that oil rather than ideology has been, consequentially, the predominant shaper of American foreign policy in the region and so doing it looks not only at Iraq but also America's changing relationship with Iran and Saudi Arabia.
Bromley, S. (2005). 'The United States and the control of world oil', Government and Opposition, Vol. 40, pp. 225-255.
Cameron, F. (2005). US foreign policy after the Cold War. London: Routledge.
Halper, S. and Clarke, J. (2004). America alone: The Neo-Conservatives and the global order. Cambridge: Cambridge University Press.
An unknown and unpredictable entity: The problem of North Korea within an international relations context.
As a secretive, largely closed, militaristic communist state which has recently undergone a change in leadership, it can be readily advanced that North Korea possesses a variety of problems for both students and practitioners of International Relations. Indeed, reports of imminent war between North and South Korea, as well as concerns that North Korea has not only the capability to make nuclear weapons but also the ability to launch them to a distance that includes American territory, suggests that there may be little to distinguish between fact, rhetoric and scaremongering. This dissertation uses qualitative and quantitative research techniques through the conducting of primary interviews with residents, dissidents and embassy staff, to attempt to shed light on the reality of the situation in North Korea and, through so doing, to allay Western fears as to the 'danger' that North Korea represents.
Cohen, J.M. (2012). 'Confronting the real missile threat: Iran or North Korea', Research Paper, Army War College. Carlisle Barracks, PA: US Army.
Sattler, M. (2010). Can the United States cap North Korea's nuclear weapon by using the policy of benign-neglect? Master's thesis, Georgetown University.
Snyder, S. (2009). 'North Korea's nuclear and missile tests and six-party talks: Where do we go from here?', Testimony before the House Committee on Foreign Affairs Subcommittee on Asia, the Pacific, and the Global Environment Subcommittee on Terrorism, Nonproliferation and Trade. Washington, DC: The Asia Foundation.
International 'sabre-rattling' as a political tactic to distract attention from domestic difficulties.
This dissertation investigates the use of sabre-rattling rhetoric as a mechanism by which to distract voters' attention from domestic difficulties. In so doing this dissertation investigates the present rhetoric of the Argentinean President Cristina Fernández de Kirchner and her comments regarding the sovereignty of the Falkland Islands. Noting not only the historic role of Britain in protecting the islands from forces of aggression but also the desire of the people of the islands to remain 'under the Crown', this dissertation seeks to evaluate the harm that such sabre-rattling does to the wider international reputation of countries such as Argentina.
Calvo, E. and Murillo, M.V. (2012). 'Argentina: The persistence of Peronism', Journal of Democracy, Vol. 23(2), pp. 148-161.
Dodds, K. (2012). 'Stormy waters: Britain, the Falkland Islands and UK-Argentine relations', International Affairs, Vol. 88, pp. 683-700.
Howkins, A. (2010). 'A formal end to informal imperialism: Environmental nationalism, sovereignty disputes, and the decline of British interests in Argentina 1933-1955', British Scholar, Vol. 3(2), pp. 235-262.
"International Relations Dissertation Topics." UKEssays.com. 11 2018. All Answers Ltd. 04 2019 <https://www.ukessays.com/dissertation/topics/international-relations.php?vref=1>.
"International Relations Dissertation Topics." All Answers Ltd. ukessays.com, November 2018. Web. 24 April 2019. <https://www.ukessays.com/dissertation/topics/international-relations.php?vref=1>.
UKEssays. November 2018. International Relations Dissertation Topics. [online]. Available from: https://www.ukessays.com/dissertation/topics/international-relations.php?vref=1 [Accessed 24 April 2019].
UKEssays. International Relations Dissertation Topics [Internet]. November 2018. [Accessed 24 April 2019]; Available from: https://www.ukessays.com/dissertation/topics/international-relations.php?vref=1.


text:
Q: Nested for loop python equation I am new to python and coding and I have a problem where I need to use nested for loops to solve an equation where i^3 + j^3 + k^3 = N. Where N is 50 to 53 and i, j, k have a range of -800 to 800.
I do not understand how to use a nested for loop for this. Every example I have seen of for loops they are used for creating matrices or arrays.
The code I have tried output a very large amounts of falses.
for i in range (-800,801):
    for j in range (-800,801):
        for k in range(-800,801):
            for N in range (50,54):
                print(i**3+j**3+k**3==N,end=" ")
            print()

Am I on the right track here? I got a large amount of false outputs so does that mean it ran it and is giving me a every possible outcome? I just need to know the numbers that exists that make the statement true

A: I think what you want to do is check if
i^3+j^3+k^3==N
and only print i, j and k if the statement is true.
You can do that by adding:
for i in range(-800, 801):
    for j in range(-800, 801):
        for k in range(-800, 801):
            for N in range(50, 54):
                if i**3+j**3+k**3 == N:
                    print(i, j, k, N)

output:
-796 602 659 51
-796 659 602 51

A: The nested loops are not your problem, they are already correct.
You need to print the values of i, j, k, and N only if they satisfy the equation. For this purpose of conditional execution of code, Python (as many other programming languages) has if statements.
You learn about them in the official Python tutorial or in any good beginners book about programming in Python, like Think Python or Automate the Boring Stuff with Python.
In your case, you can apply an if statement like this:
Instead of unconditionally printing
print(i**3+j**3+k**3==N,end=" ")

use
if i**3+j**3+k**3==N:
    print(i, j, k, N)

A: This will give you the number of times the equation is correct:
count = 0
for i in range(-800,801):
    for j in range(-800,801):
        for k in range(-800,801):
            for N in range(50,54):
                if (i**3 + j**3 + k**3) == N:
                    count+= 1
print(count)

redpajama_set_name: RedPajamaStackExchange


text:
EPF Plastic is the Italian distributor and service partner of Shibaura Machine, already Toshiba Machine, one of the world's leading manufacturers of industrial technology, and specifically plastic injection molding machines.
The Japanese giant was established in 1938 as Shibaura Machine Tool Company and, in 1961, the company name was changed to Toshiba Machine Company. The name Toshiba is the result of the combination of TOkyo Denky and SHIBAura Seisaku-sho, founded respectively in 1875 and 1890. On 1st April 2020, Toshiba Machine returns to its origins by changing its name back to Shibaura Machine and continuing its tradition of historic Japanese production inspired by Technology, Innovation and Quality.
EPF became an official partner of Toshiba Machine in 2013 and it has since been offering a wide range of sales and post-sales services for the Italian market. Equipped with a dedicated branch office located just south of Milan that includes a management office, warehouse, showroom and technology centre, the EPF Plastic division was established to manage these operations.
The advantages:
RELIABILITYEFFICIENCYSAVINGREPEATABILITY
A WIDE RANGE OF FULL-ELECTRIC INJECTION MOLDING MACHINES
FOR ALL APPLICATION SECTORS
SHIBAURA and EPF have decided to approach the European market exclusively with full-electric machines. This decision stems from a careful analysis of the international market, which shows that, in recent years, the purchase of these products has significantly increased in countries such as Japan (by 80%) and the USA (by 50%).
With the EC-SXIII series, Shibaura presents the sixth generation of full-electric injection moulding machines, available from 50 to 2,500 tons: a mature product characterized by over twenty years of know-how and experience, which guarantees high productivity and absolute precision. Adaptability is one of the core strengths of Shibaura moulding machines, they are ideal for multiple applications in sectors such as automotive, medical, electrical, electronic, packaging and technical.
The emerging needs of Industry 4.0 and IoT do not catch Shibaura solutions unprepared: moulding machines can be connected to data collection systems and interfaced with MES systems, communicate with other machines through OPC-UA protocol and, more generally, implement the latest Euromap interfaces.
In terms of sustainability and energy saving, the Japanese manufacturer was able to effectively develop a machine with kW/kg consumption values that fully comply with industry standards. This result was achieved because the 'heart' of the machine is made up of drives, electric motors and controllers. These were developed ad hoc for the moulding sector and built entirely by Shibaura, and, in addition, they stand out globally for efficiency, performance and reliability.
These are just some of the outstanding features and performances that Shibaura machines can guarantee:
Fast and simultaneous axis movements increase the productivity;
The effective geometry of the toggle closure ensures uniform distribution of the closing force and reduces deformation and stress on the moulds;
Using linear guides for all movements reduce the friction and the energy consumption;
Polymer plastification is managed with closed-loop process adjustments, which allows the use of regranulated scraps or recycled materials.
ALL INJECTION MOLDING MACHINES
Cookie Policy • Privacy Policy • Company Data
Follow us on web:
Registered office: Via Langhe, 24 – 12061 Carrù (CN)
Company Registration – VAT – Fiscal Code: 00165950049
Paid-up share capital: € 78.520,00
Information ex art. 1, paragraph 125, of Law 4 August 2017 n. 124
According to the disposition referred to art. 1, paragraph 125 of Law 124/2017, on the obligation to provide additional information on sums of money received in the financial year as grants, contributions, remunerated assignments and in any case economic advantages of any kind from the public administrations and from the subjects of which to paragraph 125 of the same article, the company attests that it has received in the course of 2018 the following contributions:
3.000,00 Euro from the Chamber of Commerce Industry Crafts and Agriculture of Cuneo;
25.589,00 Euro from the GSE as contributions tariffs incentives PV;
1.665,92 Euro as an on-the-spot exchange contribution;
133.330,00 as contribution (bonus) for Research and Development;
27.132,35 Euro as an INPS facility for staff costs.
The Company also certifies the existence of contributions. Its publication is available in the National State Aid Register.
This site or third-party tools used by the site, make use of cookies that are necessary for its functionality and useful for the purposes outlined in the cookie policy. If you would like to know more or opt-out of all or some of the cookies, please refer to the cookie policy.Got itRead the Cookie Policy

redpajama_set_name: RedPajamaCommonCrawl


text:
Q: Magento2 and Oauth 2.0 Magento 2.2.4  how can in use Oauth 2.0 for rest api resource access?
Is it posible to use Oauth 2.0 with magento 2.2.4 like Oauth 1.0.

A: Currently Magento 2.2 supports oAuth 1.0a.
There are a few ways to implement this and recommend reading the devdocs page for further information: https://devdocs.magento.com/guides/v2.2/get-started/authentication/gs-authentication-oauth.html


text:
La DFL Supercup 2021 fue la  duodécima edición de la Supercopa de Alemania. Fue el partido de fútbol anual disputado entre los ganadores de la pasada temporada de la Bundesliga y la DFB-Pokal. El partido tuvo lugar el 17 de agosto de 2021.

El partido enfrentó al Bayern Múnich, campeón de la Bundesliga 2020-21, contra el campeón de la Copa de Alemania 2020-21 el Borussia Dortmund. Borussia Dortmund, los campeones de la DFB-Pokal, fueron los anfitriones en el Signal Iduna Park en Dortmund. El equipo bávaro ganó por 3-1 en los 90 minutos y consiguió su noveno título de Supercopa alemana.

Equipos participantes

Distribución geográfica de los clubes

Partido
El horario corresponde al huso horario de Alemania (Hora central europea): UTC+2 en horario de verano (CEST).

Véase también
 Supercopa de Alemania
 1. Bundesliga 2020-21
 Copa de Alemania 2020-21

Referencias

2021
Deporte en Alemania en 2021
Fútbol en 2021


text:
Experimental Studies of Radiation Reaction and Photon-Photon Collisions in Ultrahigh Intensity Regimes
Guillermo Marrero Samarin
School of Mathematics and Physics
Quantum Electrodynamics (QED), in the perturbative limit has proved to be one of the most robust theoretical frameworks in physics, exhibiting vast calculation potential and being corroborated repeatedly by experimental observations. Nonetheless, there are still some open questions with regards to the theory in the non-perturbative limit, one of them being the problem of Radiation Reaction. Ongoing work in this field seeks to establish the exact relationship between the radiation emitted by a charged particle and its own motion.
An additional prospect of the advancement of the field of QED is the realisation of a photon-photon collider, one in which pairs of particles and anti-particles may be produced. While there are various mechanisms which entail the production of an electronpositron pair from photon-photon collisions, the most fundamental variant of the process has not been yet measured in isolation. This is the Breit-Wheeler process and it entails the collision of two real photons with a centre-of-mass energy above the rest mass of the particle-antiparticle pair.
The present document details an account of experimental works carried out in the aforementioned fields, with results being presented in both the subject of Radiation Reaction and Pair Production. The experiments were both carried out in all-optical scenarios, demonstrating the versatility and potential of the combination of laser-plasmaaccelerators and ultra-intense field capabilities in the same experimental facility.
The first of the experimental findings was the observation of non-perturbative Radiation Reaction effects in the collision of an electron beam of energy exceeding 2 GeV with an external electro-magnetic field of intensity of ≈ 1020 W/cm2 . This was the first successful execution of a laser-based radiation reaction experiment in a regime where the onset of quantum effects in electron dynamics was evident.
Furthermore, results from pair production from photon-photon collisions in the linear regime are also detailed. The experiment design, detector design and analysis methods are outlined and indications of the possible presence of positrons generated by the Breit-Wheeler process are presented with events beyond one standard deviation being observed. A statistical analysis was performed to ascertain the conditions necessary to observe events beyond two standard deviations in the same experimental conditions.
Gianluca Sarri (Supervisor) & Matthew Zepf (Supervisor)
Quantum Electrodynamics
Radiation Reaction
Photon Collisions
Pair Production
Marrero Samarin, G. (Author). Jul 2020
File: application/pdf, 26.3 MB
Experimental signatures of the quantum nature of radiation reaction in the field of an ultraintense laser
Laser-Wakefield Electron Beams as Drivers of High-Quality Positron Beams and Inverse-Compton-Scattered Photon Beams
A spectrometer for ultrashort gamma-ray pulses with photon energies greater than 10 MeV
Characterisation of laser-driven relativistic positron beams
Experimental Observation of a Current-Driven Instability in a Neutral Electron-Positron Beam
General features of experiments on the dynamics of laser-driven electron-positron beams


text:
Justice for Jonathan Mitchell
In Albuquerque, NM, on a dark night in a quiet neighborhood, 23 year-old Iraq War Veteran Jonathan Mitchell was shot and killed in March 2013. He was killed by Donnie Pearson. Pearson has not been arrested due to a claim of self-defense.
The story given to police is Pearson's and his neighbor's story. Ventana Ranch resident Jose Beltran told police that when he came home from work, he saw a man with a gun in his driveway. Instead of parking, he drove away and called his family to warn them. One of Beltran's family members then called Pearson and told him that Jose said he saw an armed man in the driveway.
Pearson told police that he then got his 15 year-old son, and they both got into Pearson's SUV, and set out to look for the suspicious man with a gun. Read the rest of this entry →
Tags: change.org, Donnie Pearson, Jonathan Mitchell, Justice for Jonathan Mitchell, New Mexico, petition, self defense
The Worst Shot Came From The Justice System
The case of Howard Morgan
Imagine being put on trial for four counts of attempted murder, four counts of aggravated battery with a firearm against a police officer, and two counts of discharging a firearm.
The jury acquits you of the two counts of firing a firearm and four counts of aggravated battery with a firearm. Logically, you would think that a finding of not guilty would also be entered on the charges of attempted murder, but the jury deadlocks on those charges.
According to your defense attorneys, ten jurors considered you not guilty of attempted murder, and two others would not agree. The judge declares a mistrial.
Then imagine being put on trial again and the court orders that the second jury cannot know that the first jury acquitted you on the charges of discharging a firearm and aggravated battery. The second jury enters a conviction for attempted murder, aggravated battery, and discharging a firearm. You are sentenced to 100 years in total, but since one sentence is 40 years, the judge orders that your sentences run concurrent meaning, you will serve 40 years in prison. At the age of 61, does it really make much difference?
Protesters and your family say that the second trial violated double jeopardy.
Okay, that started at what is now the present. Let's go to the beginning. Read the rest of this entry →
Posted in Cases, Howard Morgan, Uncategorized
Tags: appeal, Benjamin Crump, change.org, Chicago, Howard Morgan, shot 28 times
Justice for Ethan
On January 12, 2013 in Frederick, MD, 26-year-old Ethan Saylor went to see the movie "Zero Dark Thirty" in a theater inside a mall. After the movie, Ethan wanted to see it again. Someone told him he needed to buy another ticket. Ethan had Down syndrome — a genetic condition that impairs physical growth and intelligence. Ethan does not carry cash. He had an IPhone. Because his mom later saw four, 4-1-1 calls on his IPhone, she believes he was using it to try to get information on how to purchase another ticket using his IPhone.
However, the off-duty sheriff deputies moonlighting as mall security didn't listen to Saylor's aide who told them to wait it out. Ethan's mom was on the way and he just needed some time.
The deputies grabbed Ethan out of his seat. A heavy guy weighing 294 lbs, they drug him to the door and face-down, three deputies were on him in a heap putting on handcuffs, with Ethan on the bottom. Witnesses say that Ethan cried out "Ouch!" "Don't touch me!" "I need help, Mommy." Then he went silent. When the officers realized Ethan was no longer breathing, they turned him over and tried to resuscitate him.
Ethan's mom was 5 minutes away from the theater when she received a call diverting her to the hospital.
An autopsy showed that Ethan's larynx had been crushed and he died by suffocation. The medical examiner ruled Ethan Saylor's death a homicide.
David Tolleson, Executive Director of the National Down Syndrome Congress, stated, "Advancements for people with disabilities have created more opportunities for inclusion in society, which means more people with disabilities are more likely to be "out in the community. It is critical that law enforcement agencies learn strategies on how to 'support, serve and protect' people with disabilities"
A grand jury cleared the three officers of wrongdoing. The case inflamed disability groups, some of which have started online petitions to demand justice for Ethan. Ethan's sister has started a petition on change.org, requesting Maryland Governor Martin O'Malley to conduct an independent investigation and formal training of police.
https://www.change.org/petitions/justice-for-ethan-governor-martin-o-malley-we-need-an-independent-investigation-and-training-for-police.
More on this story here.
"Injustice anywhere is a threat to justice everywhere." Dr. Martin Luther King, Jr.
Posted in Cases, Cops Gone Wild, Department of Justice, Ethan Saylor, Uncategorized
Tags: change.org, Down sydrome, Ethan Saylor, justice, Maryland, petition, police brutality
Let Us Not Forget Kevin Cunningham, The Creator Of The Petition.
Posted by blushedbrown
There are many supporters for Justice for Trayvon Martin. Those supporters include family members of Trayvon Martin, civil rights activists, bloggers, and anyone else who deems that the killing of Trayvon Martin was unjustified in every regard.
Mr. Mark O'Mara likes to tell his spiel of how the Martin/Fulton family hired a publicist named Ryan Julison to champion their cause in getting media recognition. The fact of the matter is that it was Natalie Jackson who sought him out and hired him for the family. She knows as well as all people of color, a case like this will not get the media attention it deserves without a publicist.
The shooting of Trayvon was on local TV in Florida. For two weeks, other than those locally in Florida, no one else knew about the killing of an unarmed teenager in Sanford, Florida. Considering the options left for the family, since no arrest was made, a publicist was an option to use. Tracy and Sybrina were interviewed on CBS News Morning. They have done what other parents do; get on TV and plead their case. I have often viewed news cast of tragedies happening to families, but the majority of those people who get to have their say on TV are generally white. Most news media outlets will put the face of a white child missing more often than a black child missing. Most media outlets will put the face of a killing of a white person more often than the killing of a black or brown person. This is the bias of the media outlets. This practice of media bias has been done for a very long time.
The sheer fact that a publicist had to be employed speaks to this mindset and recognition of media bias. A crime committed against a black person is not as newsworthy as a crime committed against a white person.
Which leads me to the power of the internet.
Through a law school linkserv, Kevin Cunningham learned about the killing of Trayvon Martin on March 8th 2012, 11 days after Trayvon was killed.
Kevin Cunningham, 31, of Washington, D.C., attended Howard University. The student body of Howard University today consists of 80% black and 1% white.
Kevin Cunningham used the power of the internet. He created the petition on Change.org. This petition garnered more attention than what the publicist was trying to do at the time.
O'Mara loves to rant and rave about how Martin/Fulton hired a publicist to get "their" message out. He is so wrong, I just had to call it out.
Granted the publicist did some work, but it was the petition that made it national and global news through the use of the internet.
The petition, from its inception garnered 100 signatures the first day. After a few days, it was 10,000.
A spokesperson, Megan Lubin from Change.org contacted Kevin Cunningham and suggested, which is a rare thing for this organization to do, would be to turn over the petition to Tracy Martin and Sybrina Fulton.
Quote from Sybrina Fulton:
"When we heard about the petition, we were overwhelmed that someone we didn't know would take the time and effort to raise awareness about our son," Trayvon's mother said.
She speaks not only for the efforts of Kevin Cunningham, but for all those who signed the petition.
The petition in its final tally was 2,278,303. It is currently, the largest petition in Change.org. history. On April 11, 2012, it was announced that a capias for the arrest of the neighborhood watch captain that killed Trayvon Martin was issued, charging him, George Michael Zimmerman, with 2nd degree murder. State's Attorney Angela Corey said that they were not pressured by outside forces to arrest George Zimmerman. The results of the investigation give evidence of 2nd degree murder, but that investigation would not have happened if not but for the efforts of Tracy, Sybrina, lawyers, ordinary people, and Kevin Cunningham who posted a petition that let everyone know that George Zimmerman should be held accountable for the killing of Trayvon Martin.
O'Mara doesn't like pointing out the fact that the petition and the will of the family did more in a matter of days than any publicist would or could have done in the same time frame.
O'Mara and company would like to have the American & Global Public believe that if not for the hired help of a publicist, the killing of Trayvon Martin and the pending case of Fl vs GZ would not have been in the public eye.
HE IS DEAD WRONG!
We are included in those 2,278,301. The public outcry on the streets and on the internet are the reason why the killing of Trayvon Martin is front and center. Not because of the sole work of a publicist.
We demanded Justice — this call came from everybody.
We intend to get that Justice for Trayvon Martin.
If not for people like Kevin Cunningham who had the courage and the idea of starting a petition, I believe this case would have never gotten to where it is now. It's the people who spoke up against the injustice of it all that has gotten to where we are now, and a lot of those people are on the internet. We don't have access to big media outlets. We don't have the money to buy air time. But our voices are just as powerful if not more than the media and radio.
Case in point: The defendant's family has been on TV an Radio. It has gotten them, nothing, nada, zilch.
No amount of TV coverage can speak as much as our signatures, petitions, marches, blogs, and our continued support for Trayvon Martin and his family.
The internet can be a powerful tool to use for creating awareness. I am proud to be a part of the positive work and continuing efforts in our quest for Justice for Trayvon Martin.
The one year anniversary of the death of Trayvon Martin is in three days. I thought it was appropriate to go back and look at who and when people got involved.
Kevin Cunningham was at the front of the line.
Kevin Cunningham, from our home here at BlackButterfly7, thank you from the bottom of all of our hearts.
#True Warrior Kevin Cunningham
http://blogs.findlaw.com/strategist/2012/03/howard-law-grads-petition-helped-spark-trayvon-martin-protest.html
http://www.irishcentral.com/news/Super-Irish-Kevin-Cunninghams-online-petition-for-Trayvon-Martin-gets-2-million-signatures-145104605.html?page=1
Posted in Heroes, Justice For Trayvon, Trayvon Martin
Tags: change.org, George Zimmerman, justice for Trayvon, Kevin Cunningham, Mark O'Mara, neighborhood watch, petition, Sybrina Fulton, Tracy Martin, Trayvon Martin


text:
FROM janes/alpine-lamp
MAINTAINER hnicke
COPY index.php /www
COPY mysql-credentials.php /www
COPY createdb.sql /

EXPOSE 80

RUN nohup mysqld --skip-grant-tables --bind-address 0.0.0.0 --user mysql > /dev/null 2>&1 & \
    sleep 10 && mysql -u root < /createdb.sql

ENTRYPOINT httpd && \
           nohup mysqld --skip-grant-tables --bind-address 0.0.0.0 --user mysql > /dev/null 2>&1 & \
           tail -f /dev/null


text:
Home » Records Management » Transfer of Records to the National Archives
According to Section 11(2) of the National Archives and Records Service Act (Act No. 43 of 1996 as amended) (NARSSA Act), public records determined by the National Archivist as having archival value must be kept by the governmental body for twenty years from the date that the records came into being. These records are indicated by an A20 symbol on the disposal schedule. Governmental bodies must however keep all their records in safe custody until they receive disposal authority from the National Archivist. Only once written disposal authority has been obtained may the governmental body consider arranging for the transfer of their archival records to an archives repository.
As the National Archives and Records Service of South Africa (NARSSA) is not yet equipped to take electronic records into custody, the National Archivist may recommend that electronic records remain in the custody of a governmental body. The National Archivist may also instruct a governmental body to transfer its electronic records into archival custody in an archival acceptable medium such as paper or microfilm.
If another Act of Parliament determines that records should remain in the custody of a specific governmental body or person, the governmental body may not transfer its records to an archives repository except if the National Archivist has authorised the transfer of the records. The National Archivist may nevertheless require that records in the custody of specific functionaries be managed as described in this manual.
The National Archivist may also in consultation with a governmental body, identify archival and/or essential records that should remain in the custody of the governmental body. This will be done mainly in cases where the records are of such a specialised nature that the NARSSA's staff are not qualified to make them accessible to researchers, or they have such high functional value for the body that transfer into archival custody will hamper the body's service delivery.
Transfer to archives repositories
The head of the governmental body must submit a written request to the head of the archives repository to initiate a transfer of records or complete the Electronic Transfer List depicted below. Once approval has been given for the transfer, records must be packed as described according to prescripts in Annexure 16 of the Records Management Policy Manual and dispatched at the body's expense to the archives repository. A copy of the transfer list (Annexure 17 of the Records Management Policy Manual) must accompany the transfer. Another duplicate copy of the list must be submitted together with a transfer letter to the head of the repository. The records should be arranged and packed in the same sequence as described on the transfer list. Any relevant registers or indexes should accompany these records. The head of a repository may refuse to accept records into custody if they are not packed as prescribed. Such records may be referred back to the body to correct the errors.
Records may only be sent to the repositories designated by the NARSSA (Contact paticulars: National and Provincial Archives Services). Audio-visual records must be transferred to the National Film, Video and Sound Archives as this archives repository is specifically equipped to care for these records. Arrangements for transfers must be made with the Head of the Film, Video and Sound Archives before any transfers take place. An agreement may be made between the National Archivist and a governmental body to arrange for a systematic transfer of records to the National Archives Repository, in which case the governmental body will transfer records annually in the period agreed upon.


The power of images. The power of perspective. It's pretty clear by now that we are going to need a lot more than walls of words, thick reports and endless expert conferences to turn the world toward sustainability. So to help our cause we invite our readers to jump in and share with us striking their "social space" graphics which illustrate in telling ways the world's streets and all that takes place thereon in many places and in many ways. To get a feel for how this works out using our challenging 990 x 180 pixels format, read on — or if you are in a hurry click here to go direct to the photo gallery.
There is more than a bit of the "medium is the message" of Marshall McLuhan in this somewhat unusual elongated rectangular format with, as with poetry, its strict dimension of 990 × 180 pixels. It is, we would say, a basically "social space format". In our mind's eye most of us tend to envisage, to think of many things out there in front of our noses in terms of squares or rectangles, which naturally enough is how most of us end up taking our pictures.
But this elongated frame takes us beyond a single individual subject and the eye travels quite further than usual and in the process brings us to think, yes, of more social spaces. Have a look at some of the following examples and see for yourself if this makes any sense at all.
Just this morning for instance we had the luck to receive and to be able to share with you the splendid street scene you see above, showing an intersection of bus services right in the middle of the beautiful city of Lisbon. And all this thanks to our colleague Miguel Barroso from Lisbon.
The shot is taken from the city's historic Praça do Comércio (Commerce Square), and just behind those columns you enter into the city's pedestrian network. Makes you want to go to Lisbon, eh?
A few weeks ago, this next great shot was shared with us by Karthik Rao-Cavale, whose fine new blog "India lives in her cities too!" with its sub-title "A closer look at Indian cities, streets and neighbourhoods" at http://vishwakarman.wordpress.com/ — is a thoughtful source for anyone who shares WOrld Streets interests and concern.
What you see here is a 990 x 180 section of a photograph taken by Jeroen Swolfs (www.jeroenswolfs.nl) who has launched a Dutch project entitled Streets of the world (http://www.streetsoftheworld.nl) in which he is reporting on his world-wide pictorial vagabondage which thus far has had him photographing life on more than forty countries on four continents thus far. We have invited him to share some of his photos with us occasionally and hope you will be seeing him often on World Streets.
Well, very nice indeed but we could not use it as our feature graphic for the story and the week, so we needed to find what would work out with our demanding format, to which challenge we came up with this.
You may like it or not, but there is no denying that this is a social format. And that is exactly what we are looking for.
Thanks for sharing, and again click here for the latest collection of social space photos from World Streets.


text:
#ifdef KERNEL
#include "dir.h"
#include "exec.h"
#include "time.h"
#include "resource.h"
#else
#include <sys/dir.h>
#include <sys/exec.h>
#include <sys/time.h>
#include <sys/resource.h>
#endif

/*
 * data that doesn't need to be referenced while the process is swapped.
 * For PIC32, the user block is USIZE bytes long; resides at virtual kernel loc
 * 0x80007400; contains the system stack (and possibly network stack) per
 * user; is cross referenced with the proc structure for the same process.
 */
#define MAXCOMLEN   MAXNAMLEN   /* <= MAXNAMLEN, >= sizeof(ac_comm) */

struct user {
    struct  proc *u_procp;          /* pointer to proc structure */
    int     *u_frame;               /* address of users saved frame */
    char    u_comm[MAXCOMLEN + 1];  /* command file name */
    label_t u_qsave;                /* for non-local gotos on interrupts */
    label_t u_rsave;                /* save info when exchanging stacks */
    label_t u_ssave;                /* label variable for swapping */

/* syscall parameters and results */
    int     u_arg[6];               /* arguments to current system call */
    int     u_rval;                 /* return value */
    int     u_error;                /* return error code */

/* 1.1 - processes and protection */
    uid_t   u_uid;                  /* effective user id */
    uid_t   u_svuid;                /* saved user id */
    uid_t   u_ruid;                 /* real user id */
    gid_t   u_svgid;                /* saved group id */
    gid_t   u_rgid;                 /* real group id */
    gid_t   u_groups[NGROUPS];      /* groups, 0 terminated */

/* 1.2 - memory management */
    size_t  u_tsize;                /* text size (clicks) */
    size_t  u_dsize;                /* data size (clicks) */
    size_t  u_ssize;                /* stack size (clicks) */

/* 1.3 - signal management */
    sig_t   u_signal[NSIG];         /* disposition of signals */
    long    u_sigmask[NSIG];        /* signals to be blocked */
    long    u_sigonstack;           /* signals to take on sigstack */
    long    u_sigintr;              /* signals that interrupt syscalls */
    long    u_oldmask;              /* saved mask from before sigpause */
    int     u_code;                 /* ``code'' to trap */
    int     u_psflags;              /* Process Signal flags */
    struct  sigaltstack u_sigstk;   /* signal stack info */
    u_int   u_sigtramp;             /* pointer to trampoline code in user space */

/* 1.4 - descriptor management */
    struct  file *u_ofile[NOFILE];  /* file structures for open files */
    char    u_pofile[NOFILE];       /* per-process flags of open files */
    int u_lastfile;                 /* high-water mark of u_ofile */
#define UF_EXCLOSE  0x1             /* auto-close on exec */
#define UF_MAPPED   0x2             /* mapped from device */
    struct  inode *u_cdir;          /* current directory */
    struct  inode *u_rdir;          /* root directory of current process */
    struct  tty *u_ttyp;            /* controlling tty pointer */
    dev_t   u_ttyd;                 /* controlling tty dev */
    int     u_cmask;                /* mask for file creation */

/* 1.5 - timing and statistics */
    struct  k_rusage u_ru;          /* stats for this proc */
    struct  k_rusage u_cru;         /* sum of stats for reaped children */
    struct  k_itimerval u_timer[2]; /* profile/virtual timers */
    long    u_start;
    int     u_dupfd;                /* XXX - see kern_descrip.c/fdopen */

    struct uprof {                  /* profile arguments */
        unsigned *pr_base;          /* buffer base */
        unsigned pr_size;           /* buffer size */
        unsigned pr_off;            /* pc offset */
        unsigned pr_scale;          /* pc scaling */
    } u_prof;

/* 1.6 - resource controls */
    struct  rlimit u_rlimit[RLIM_NLIMITS];

/* namei & co. */
    struct  nameicache {            /* last successful directory search */
        off_t nc_prevoffset;        /* offset at which last entry found */
        ino_t nc_inumber;           /* inum of cached directory */
        dev_t nc_dev;               /* dev of cached directory */
    } u_ncache;
    int     u_stack[1];             /* kernel stack per user
                                     * extends from u + USIZE
                                     * backward not to reach here */
};

#include <sys/errno.h>

#ifdef KERNEL
extern  struct user u, u0;

/*
 * Increment user profiling counters.
 */
void addupc (caddr_t pc, struct uprof *pbuf, int ticks);

#endif


An early scene from a new feature-length film takes place at a rural antenatal clinic in Tanzania. It shows Minza, a young pregnant woman, distracted and disinterested during a group health and nutrition education session on why good nutrition during the first 1,000 days matters for early childhood development. This sets the stage for the remainder of the film, which follows Minza as she learns about the importance of good nutrition and how poor nutrition and feeding practices can have serious consequences.
The storyline of Ngoma ya Roho—"Dance of the Soul" in Swahili—reflects everyday life in Tanzania, where high rates of malnutrition affect every community, as well as national development. The film conveys evidence-based nutrition messages on the importance of dietary diversity during pregnancy and childhood and models optimal feeding and hygiene practices during the critical first 1,000 days.
FANTA teamed with Tanzania-based sub-partner Media for Development International and local film industry talent to produce Ngoma ya Roho in Swahili. Written by an award-winning Tanzanian woman writer and directed by a leading Tanzanian producer who has the ear of the President on youth issues, the film addresses the complex determinants of stunting, engaging audiences using proven edutainment techniques. Production and distribution of the film contribute to the Government of Tanzania's commitment to nutrition advocacy by promoting positive change in social norms and behaviors known to affect nutrition.
Ummy Mwalimu, the Minister of Health, Community Development, Gender, Elderly and Children, a strong advocate of the film's message, endorsed the film and speaks to her nation on a short video during which she stresses the importance of dietary diversity and hygiene for young children—and all Tanzanians.
FANTA and Media for Development International also developed an interactive film discussion guide. A film poster and postcard are available for download and use.
Read an interview with John Riber, the director of Ngoma Ya Roho.