Code fuer Hausarbeit f,g
This commit is contained in:
@@ -71,7 +71,10 @@ dfUnivariateAnalyse.to_csv('UnivariateAnalyse.csv')
|
||||
### d) Balkendiagramme
|
||||
|
||||
# Arbeitstabelle erzeugen, die nur die Spalten der nominalen Merkmale enthält:
|
||||
dfNominaleMerkmale = df[["bluetooth", "dual_sim", "4G"]].astype(int) # inkl. Typenumwandlung zur Ganzzahl (int)
|
||||
# inkl. Typenumwandlung zur Ganzzahl: .astype(int)
|
||||
dfNominaleMerkmale = df[["bluetooth", "dual_sim", "4G"]].astype(int)
|
||||
|
||||
# print(df["bluetooth"].value_counts())
|
||||
|
||||
# Jetzt Abwechselnd:
|
||||
# ___Yes = Extrahieren der Datensätze mit Merkmalsausprägung 1 (yes)
|
||||
@@ -104,7 +107,7 @@ dfAnzahlYesNo = pd.DataFrame({'yes': anzahlYes, 'no': anzahlNo}, index=index)
|
||||
|
||||
# Für dieses Dataframe ein Balkendiagramm erzeugen, mit Rotation=0
|
||||
dfAnzahlYesNo.plot.bar()
|
||||
plt.show()
|
||||
#plt.show()
|
||||
|
||||
|
||||
|
||||
@@ -127,6 +130,7 @@ arrYpredicted = steigung * werteListeX + yAchsAbschn # using y = m*x + n,
|
||||
print("Regressionsgleichung:", "y =", steigung, "* x +", yAchsAbschn)
|
||||
|
||||
# Plot Linear Regression Line
|
||||
plt.clf() # Clear last plot image
|
||||
plt.plot(werteListeX, arrYpredicted, label='Lin Regression', color='red', linestyle='solid') # https://scriptverse.academy/tutorials/python-matplotlib-plot-straight-line.html
|
||||
# Show Plot Image
|
||||
plt.xlabel('ram', color='black')
|
||||
@@ -136,3 +140,29 @@ plt.scatter(werteListeX, werteListeY)
|
||||
#plt.show()
|
||||
|
||||
|
||||
### f) Skalierung in [0, 1]
|
||||
dfMetrischeMerkmale["battery_power_skaliert"] = dfMetrischeMerkmale["battery_power"] / dfMetrischeMerkmale["battery_power"].max()
|
||||
dfMetrischeMerkmale["int_memory_skaliert"] = dfMetrischeMerkmale["int_memory"] / dfMetrischeMerkmale["int_memory"].max()
|
||||
dfMetrischeMerkmale["ram_skaliert"] = dfMetrischeMerkmale["ram"] / dfMetrischeMerkmale["ram"].max()
|
||||
# print(dfMetrischeMerkmale)
|
||||
# battery_power int_memory ... int_memory_skaliert ram_skaliert
|
||||
# 0 1043 5 ... 0.078125 0.874245
|
||||
# 1 841 61 ... 0.953125 0.979628
|
||||
# 2 1807 27 ... 0.421875 0.602616
|
||||
# ...
|
||||
|
||||
### g) Boxplots
|
||||
|
||||
plt.clf() # Clear last plot image
|
||||
plt.close('all')
|
||||
plt.boxplot(dfMetrischeMerkmale["battery_power"], showfliers=True)
|
||||
plt.show()
|
||||
#dfMetrischeMerkmale.boxplot("battery_power", showfliers=True, backend="matplotlib")
|
||||
#plt.show()
|
||||
plt.clf() # Clear last plot image
|
||||
dfMetrischeMerkmale.boxplot("int_memory", showfliers=True)
|
||||
plt.show()
|
||||
plt.clf() # Clear last plot image
|
||||
dfMetrischeMerkmale.boxplot("ram", showfliers=True)
|
||||
plt.show()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user