Forum Discussion
How to do the Machine Model application in Fabric?
Hi kirah2128 ,
Can you please check your input data and also the version configuration from your end once?
Do let me know incase of further queries.
This is the model
here is how I supply the ML with the new inputs from lakehouse source.
# Initialize Spark session
spark = SparkSession.builder.getOrCreate()
# Load data from your Spark SQL environment or DataFrame
df = spark.sql("SELECT removal_reasons, reliability_tracked FROM lakehouse1.part_removal")
# Initialize the tokenizer
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
# Tokenization function
def tokenize_text(text):
tokens = tokenizer(text, padding="max_length", truncation=True, max_length=128, return_tensors="np")
return tokens['input_ids'][0].tolist(), tokens['attention_mask'][0].tolist()
# Register UDF for tokenization
@udf(ArrayType(IntegerType()))
def udf_tokenize_input_ids(text):
return tokenize_text(text)[0]
@udf(ArrayType(IntegerType()))
def udf_tokenize_attention_mask(text):
return tokenize_text(text)[1]
# Apply the UDF to add tokenized columns
df = df.withColumn("input_ids", udf_tokenize_input_ids(col("removal_reasons")))
df = df.withColumn("attention_mask", udf_tokenize_attention_mask(col("removal_reasons")))
# Ensure the DataFrame has the correct format
df = df.select("input_ids", "attention_mask", "reliability_tracked")- Anonymous2 years agoNot applicable
Hi kirah2128 ,
I was finf this link in Youtube - click here
It looks like some similar issue and he did some changes to make the code work.
Before -
After -
Can you please check the video and let me know if it is helpful.- Anonymous2 years agoNot applicable
Hello kirah2128 ,
We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet .
In case if you have any resolution please do share that same with the community as it can be helpful to others .
Otherwise, will respond back with the more details and we will try to help .- Anonymous2 years agoNot applicable
Hi kirah2128 ,
We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet .
In case if you have any resolution please do share that same with the community as it can be helpful to others .
Otherwise, will respond back with the more details and we will try to help .