Data Science 👩‍💻 | Data Preprocessing with Orange Tool

#Python Script for Discreetizationiris = Orange.data.Table("iris.tab")disc = Orange.preprocess.Discretize()disc.method = Orange.preprocess.discretize.EqualFreq(n=3)d_iris = disc(iris)print("Original dataset:\n")for e in iris[:3]:print(e)print("Discretized dataset:")for e in d_iris[:3]:print(e)
  • binary variables are transformed into 0.0/1.0 or -1.0/1.0 indicator variables, depending upon the argument zero_based.
  • multinomial variables are treated according to the argument multinomial_treatment.
  • discrete attribute with only one possible value are removed.
#python script for Continuization
import Orangetitanic = Orange.data.Table("titanic")continuizer = Orange.preprocess.Continuize()titanic1 = continuizer(titanic)print("Before Continuization : ",titanic.domain)print("After Continuization : ",titanic1.domain)#Data of row 15 in the before and after continuizationprint("15th row data before : ",titanic[15])print("15th row data after : ",titanic1[15])
#python script for Normalizationfrom Orange.data import Tablefrom Orange.preprocess import Normalizedata = Table("iris")normalizer = Normalize(norm_type=Normalize.NormalizeBySpan)normalized_data = normalizer(data)print("Before Normalization : ",iris[2])print("After Normalization : ",normalized_data[2])
#python script for Randomizefrom Orange.data import Tablefrom Orange.preprocess import Randomizedata = Table("iris")randomizer = Randomize(Randomize.RandomizeClasses)randomized_data = randomizer(data)print("Before randomization : ",iris[2])print("After Randomization : ",randomized_data[2])

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store