This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyspark.sql.functions import pandas_udf, PandasUDFType | |
@pandas_udf('string', PandasUDFType.SCALAR) | |
def get_zip_pdf_b(lat_series, lng_series): | |
pdf = brd_pdf.value | |
zip_series= [] | |
for k in range(len(lat_series)): | |
lat = lat_series[k] | |
lng = lng_series[k] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from uszipcode import SearchEngine | |
import sqlite3 | |
search = SearchEngine(db_file_dir="/tmp/db") | |
conn = sqlite3.connect("/tmp/db/simple_db.sqlite") | |
pdf = pd.read_sql_query("select zipcode, lat, lng, radius_in_miles, | |
bounds_west, bounds_east, bounds_north, bounds_south from | |
simple_zipcode",conn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val df = spark.createDataFrame( | |
Seq((0, "john.doe@gmail.com", "John"), (1, "JackieChan234@xyz.com","jack"), (2, "ping_pong@missed.org","Al")) | |
).toDF("id", "email", "first_name") | |
scala> df.show(false) | |
+---+---------------------+----------+ | |
|id |email |first_name| | |
+---+---------------------+----------+ | |
|0 |john.doe@gmail.com |John | | |
|1 |JackieChan234@xyz.com|jack | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val stringChecker = new StringChecker(uid = "string_checker", model = new StringCheckerModel(caseSensitive = false)). | |
setInputCols("text", "query"). | |
setOutputCol("is_it_there?") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ml.combust.mleap.core.feature | |
import ml.combust.mleap.core.Model | |
import ml.combust.mleap.core.types.{ScalarType, StructField, StructType} | |
/** | |
* Created by mostafam on 6/30/20. | |
*/ | |
case class StringCheckerModel(caseSensitive: Boolean) extends Model { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ml.combust.mleap.runtime.transformer.feature | |
import ml.combust.mleap.core.feature.StringCheckerModel | |
import ml.combust.mleap.core.types._ | |
import ml.combust.mleap.runtime.frame.{FrameBuilder, Row, Transformer} | |
import ml.combust.mleap.runtime.function.{StructSelector, UserDefinedFunction} | |
import scala.util.Try | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.apache.spark.ml.mleap.feature | |
import ml.combust.mleap.core.feature.StringCheckerModel | |
import org.apache.hadoop.fs.Path | |
import org.apache.spark.annotation.DeveloperApi | |
import org.apache.spark.ml.Transformer | |
import org.apache.spark.ml.param.ParamMap | |
import org.apache.spark.ml.param.shared.{HasInputCols, HasOutputCol} | |
import org.apache.spark.ml.util._ | |
import org.apache.spark.sql.functions._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ml.combust.mleap.bundle.ops.feature | |
import ml.combust.bundle.BundleContext | |
import ml.combust.bundle.dsl._ | |
import ml.combust.bundle.op.OpModel | |
import ml.combust.mleap.bundle.ops.MleapOp | |
import ml.combust.mleap.core.feature.StringCheckerModel | |
import ml.combust.mleap.runtime.MleapContext | |
import ml.combust.mleap.runtime.transformer.feature.StringChecker | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.apache.spark.ml.bundle.extension.ops.feature | |
import ml.combust.bundle.BundleContext | |
import ml.combust.bundle.dsl._ | |
import ml.combust.bundle.op.{OpModel, OpNode} | |
import ml.combust.mleap.core.feature.StringCheckerModel | |
import org.apache.spark.ml.bundle.SparkBundleContext | |
import org.apache.spark.ml.mleap.feature.StringChecker | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> import org.apache.spark.ml.mleap.feature.StringChecker | |
scala> import ml.combust.mleap.core.feature.StringCheckerModel | |
scala> import org.apache.spark.ml.bundle.SparkBundleContext | |
scala> import ml.combust.bundle.BundleFile | |
scala> import ml.combust.mleap.spark.SparkSupport._ | |
scala> import org.apache.spark.ml.{Pipeline, PipelineModel} | |
scala> import org.apache.spark.ml.feature.{StringIndexer,VectorAssembler} | |
scala> import org.apache.spark.sql._ | |
scala> import org.apache.spark.sql.functions._ | |
scala> import resource._ |