This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.linear_model import LinearRegression | |
lr = LinearRegression() | |
x = <Some independent data> | |
y = <Some Dependent data> | |
lr.fit(x, y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lm(formula = <Dependent Variable> ~ <Independent Variable>, data = <Some DataFrame>) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.sql.SparkSession | |
import org.apache.spark.storage.StorageLevel | |
case class Panel(user_id: String, date_joined: String, zip_shipping: String, date_newest_receipt: String, | |
date_oldest_receipt: String, prop_30d_syncable: String, date_last_sync: String, isp: String, | |
syncable: Int) | |
object Demo extends App { | |
import sparkSession.implicits._ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.couchbase.client.java.search._ | |
import com.couchbase.spark.connection.CouchbaseConnection | |
import com.couchbase.spark._ | |
val fullTextSearch = SearchQuery.match("term"); // Enable the search query to look to match specifically on a term | |
val result = sparkSession.sparkContext.couchbaseQuery(SearchQuery("my_search_term", fullTextSearch)) | |
.collect() | |
.someMethod() ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set up A Streaming Context | |
val ssc = new StreamingContext(conf, Seconds(2)) | |
ssc | |
.couchbaseStream(from = FromBeginning, to = ToInfinity) | |
.someMethod() | |
ssc.start() | |
ssc.awaitTermination() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// borrowed from: https://developer.couchbase.com/documentation/server/4.5/connectors/spark-2.0/working-with-rdds.html | |
import com.couchbase.spark._ | |
sc | |
.couchbaseGet[JsonDocument](Seq("airline_10123", "airline_10748")) | |
.collect() | |
.foreach(println) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"SELECT * from `records` where ANY p in payments SATISFIES p in [1,2,3,4,5] END" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"SELECT * from records where tag = 'victoria'" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{"id":"1","display":"melbourne","tag":"victoria", "payments";[5,4,3,2,1]}, | |
{"id":"2","display":"geelong","tag":"victoria", "payments";[1,2,3,4,5]}, | |
{"id":"3","display":"swan hill","tag":"victoria", "payments";[10,12,13,14,15]}, | |
{"id":"4","display":"brisbane","tag":"queensland", "payments";[8,7,6,5,4,3]}, | |
{"id":"5","display":"gold coast","tag":"queensland", "payments";[111,222,333,444,555]}, | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.sql._ | |
import spray.json._ | |
import com.couchbase.client.java.query.N1qlQuery | |
import com.couchbase.spark.connection.CouchbaseConnection | |
import com.couchbase.spark._ | |
val sparkSession = "..." | |
import sparkSession.sqlContext.implicits._ |