Example Analysis of adaboost algorithm in python Machine Learning Sklearn
This article mainly shows you "Python machine learning Sklearn adaboost algorithm example analysis", the content is simple and easy to understand, organized clearly, I hope to help you solve doubts, let Xiaobian lead you to study and learn "Python machine learning Sklearn adaboost algorithm example analysis" this article bar.
Pandas Batch Processing Physical Test Scores import numpy as npimport pandas as pdfrom pandas import Series, Dataimport Framematplotlib.pyplot as pltdata = pd.read_excel("/Users/zhucan/Desktop/18th Grade High Physical Test Scores Summary.xls")cond = data["Class"] != "class"data = data[cond] data.fillna(0,inplace=True)data.isnull().any() There is no empty data
Results:
Class False
Gender False
Name False
1000 m False
50 m False
Long jump False
Forward Bend False
False
Vital capacity False
Height False
Weight False
dtype: bool
data.head()
#1000 m score has string with intdef convert(x): if isinstance(x,str): minute,second = x.split("'") int(minute) minute = int(minute) second = int(second) return minute + second/100.0 else: return xdata["1000m"] = data["1000m"].map(convert)
score = pd.read_excel("/Users/zhucan/Desktop/Body Side Scores.xls",header=[0,1])score
def convert(item): m,s = item.strip('"').split("'") m,s =int(m),int(s) return m+s/100.0score.iloc[:,-4] = score.iloc[:,-4].map(convert) def convert(item): m,s = item.strip('"').split("'") m,s =int(m),int(s) return m+s/100.0 score.iloc[:,-2] = score.iloc[:,-2].map(convert)score
data.columns = ['class',' gender','name',' male 1000','male 50m run',' long jump','forward flex',' pull-up','vital capacity',' height','weight'] data["male 50m run"] = data["male 50m run"].astype(np.float)for col in ["male 1000","male 50m run"]: #Criteria for obtaining results s = score[col] def convert(x): for i in range(len(s)): if xs["score"].iloc[-1]: return 0 #Running too slow elif (x>s["score"].iloc[i-1]) and (xs["score"].iloc[i]: return s["fraction"].iloc[i] return 0 data[col+"score"] = data[col].map(convert)
data.columns
Results:
Index(['class',' gender','name',' male 1000','male 50m run',' long jump','forward flex',' pull-up','vital capacity',' height', 'weight',' men's 1000 performance','men's 50-meter running performance',' long jump performance','body forward bend performance',' pull up performance','vital capacity performance'], dtype='object')#According to the index order, go to data values cols = [' class','gender',' name','male 1000',' male 1000','male 50m run',' male 50m run','long jump',' long jump','body flexion','body flexion','pull-up',' vital capacity ',' vital capacity ',' height','weight'] data[cols]
#Calculate BMIdata["BMI"] = data["Weight"]/data["Height"]def convert(x): if x>100: return x/100 else: return xdata["Height"] = data["Height"].map(convert)data["BMI"] = data["Weight"]/(data["Height"])**2def convert_bmi(x): if x >= 26.4: return 60 elif (x 23.3 and x = 16.5 and x