Random Forest Regression की तैयारी

PySpark के साथ Feature Engineering

John Hogue

Lead Data Scientist, General Mills

फीचर्स के लिए आवश्यक धारणाएँ

Random Forest Regression

  • Skewed/Non Normal डेटा? ठीक
  • Unscaled? ठीक
  • Missing डेटा? ठीक
  • Categorical डेटा? ठीक

धारणाएँ

PySpark के साथ Feature Engineering

जोड़े गए फीचर्स

Economic

  • 30 Year Mortgage Rates

Governmental

  • शहर का Median Home Price
  • शहर के Home Age Percentages
  • शहर के Home Size Percentages

Social

  • Walk Score
  • Bike Score

Seasonal

  • Bank Holidays
PySpark के साथ Feature Engineering

Engineered फीचर्स

Temporal फीचर्स

  • एक साल के डेटा से सीमित मूल्य
  • Holiday Weeks

Rates, Ratios, Sums

  • Business संदर्भ
  • Personal संदर्भ

Expanded फीचर्स

  • Non-Free Form Text कॉलम्स
  • कम Observations हटाने की ज़रूरत
# What is shape of our data?
print((df.count(), len(df.columns)))
(5000, 126)
PySpark के साथ Feature Engineering

Dataframe कॉलम्स से फीचर वेक्टर

from pyspark.ml.feature import VectorAssembler
# Replace Missing values
df = df.fillna(-1)
# Define the columns to be converted to vectors
features_cols = list(df.columns)
# Remove the dependent variable from the list
features_cols.remove('SALESCLOSEPRICE')
PySpark के साथ Feature Engineering

Dataframe कॉलम्स से फीचर वेक्टर

# Create the vector assembler transformer
vec = VectorAssembler(inputCols=features_cols, outputCol='features')

# Apply the vector transformer to data df = vec.transform(df)
# Select only the feature vectors and the dependent variable ml_ready_df = df.select(['SALESCLOSEPRICE', 'features'])
# Inspect Results ml_ready_df.show(5)
+----------------+--------------------+
| SALESCLOSEPRICE|            features|
+----------------+--------------------+
|143000          |(125,[0,1,2,3,5,6...|
|190000          |(125,[0,1,2,3,5,6...|
|225000          |(125,[0,1,2,3,5,6...|
|265000          |(125,[0,1,2,3,4,5...|
|249900          |(125,[0,1,2,3,4,5...|
+----------------+--------------------+
only showing top 5 rows
PySpark के साथ Feature Engineering

अब हम machine learning के लिए तैयार हैं!

PySpark के साथ Feature Engineering

Preparing Video For Download...