# In pyspark we do the ML different. We do not do any test or train split
# Whatever features we will have will be grouped togather to form an independent feature 
# We use VectorAssembler for that purpose
from pyspark.ml.feature import VectorAssembler
featureassembler = VectorAssembler(inputCols = [""], outputCols = [""])
output.featuressembler.transform(training)

from pyspark.ml.regression import LinearRegression
##train test split
train_data,test_data=finalized_data.randomSplit([0.75,0.25])
regressor=LinearRegression(featuresCol='Independent Features', labelCol='Salary')
regressor=regressor.fit(train_data)

regressor.coefficients
regressor.intercept
pred_results=regressor.evaluate(test_data)
pred_results.predictions.show()
pred_results.meanAbsoluteError,pred_results.meanSquaredError

d30e9a5a74d2c4bfe3259f8a1a0d70f40b680d10
<mask token>

<mask token>
output.featuressembler.transform(training)
<mask token>
regressor.coefficients
regressor.intercept
<mask token>
pred_results.predictions.show()
pred_results.meanAbsoluteError, pred_results.meanSquaredError

<mask token>
featureassembler = VectorAssembler(inputCols=[''], outputCols=[''])
output.featuressembler.transform(training)
<mask token>
train_data, test_data = finalized_data.randomSplit([0.75, 0.25])
regressor = LinearRegression(featuresCol='Independent Features', labelCol=
    'Salary')
regressor = regressor.fit(train_data)
regressor.coefficients
regressor.intercept
pred_results = regressor.evaluate(test_data)
pred_results.predictions.show()
pred_results.meanAbsoluteError, pred_results.meanSquaredError

from pyspark.ml.feature import VectorAssembler
featureassembler = VectorAssembler(inputCols=[''], outputCols=[''])
output.featuressembler.transform(training)
from pyspark.ml.regression import LinearRegression
train_data, test_data = finalized_data.randomSplit([0.75, 0.25])
regressor = LinearRegression(featuresCol='Independent Features', labelCol=
    'Salary')
regressor = regressor.fit(train_data)
regressor.coefficients
regressor.intercept
pred_results = regressor.evaluate(test_data)
pred_results.predictions.show()
pred_results.meanAbsoluteError, pred_results.meanSquaredError

# In pyspark we do the ML different. We do not do any test or train split
# Whatever features we will have will be grouped togather to form an independent feature 
# We use VectorAssembler for that purpose
from pyspark.ml.feature import VectorAssembler
featureassembler = VectorAssembler(inputCols = [""], outputCols = [""])
output.featuressembler.transform(training)

from pyspark.ml.regression import LinearRegression
##train test split
train_data,test_data=finalized_data.randomSplit([0.75,0.25])
regressor=LinearRegression(featuresCol='Independent Features', labelCol='Salary')
regressor=regressor.fit(train_data)

regressor.coefficients
regressor.intercept
pred_results=regressor.evaluate(test_data)
pred_results.predictions.show()
pred_results.meanAbsoluteError,pred_results.meanSquaredError
