Ejemplo n.º 1
0
ProductTable.append_column('Difference From Fresh20', 20)
pandasDF_withColumnDifference_From_Fresh20 = ProductTable.to_df()
X_New_Prediction = pandasDF_withColumnDifference_From_Fresh20[[
    'ProductTypeA', 'ProductTypeB', 'ProductTypeC', 'ProductTypeD',
    'ProductTypeE', 'ProductTypeF', 'ProductTypeG', 'ProductTypeH',
    'ProductTypeI', 'BaseIngredientA', 'BaseIngredientB', 'BaseIngredientC',
    'BaseIngredientD', 'BaseIngredientE', 'BaseIngredientF', 'ProcessTypeA',
    'ProcessTypeB', 'ProcessTypeC', 'Difference From Fresh20', 'WarmClimate',
    'ColdClimate', 'HighTemperatureandHumidity', 'PackagingStabilizerAdded',
    'PackagingStabilizerNotAdded', 'Processing Agent Stability Index',
    'PreservativeAdded', 'PreservativeNotAdded'
]]

#NEW COLOMN ShelfLife AS PREDICTED OUTPUT FROM MODEL
ProductTable.append_column('ShelfLifeInWeeks', clf1.predict(X_New_Prediction))
ProductTable = ProductTable.move_column('ShelfLifeInWeeks', 2)
ProductTableOut.append_column('Prediction', clf1.predict(X_New_Prediction))
ProductTableOut['Prediction'] = ProductTableOut.apply(lambda x: math.floor(x),
                                                      'Prediction')

ProductTableOut.show(5)

#RELATIVE IMPORTANCE OF VARIABLES IN THE MODEL
print("RELATIVE IMPORTANCE OF VARIABLES IN THE MODEL")
importances = pd.DataFrame({
    'feature': X_Train_DTC.columns,
    'importance': np.round(clf1.feature_importances_, 3)
})
importances = importances.sort_values('importance', ascending=False)
print(importances)
Ejemplo n.º 2
0
 def move_column(self, *args, **kwargs):
     return self._fix_(Table.move_column(self, *args, **kwargs))