Posts

ML Lab

Image
import pandas as pd import matplotlib.pyplot as plt from sklearn.tree import DecisionTreeClassifier, plot_tree # Load the data data = pd.read_csv("/PlayTennisData.csv") # Prepare the data X = data.drop('PlayTennis', axis=1) y = data['PlayTennis'] X = pd.get_dummies(X) y = y.map({'yes': 1, 'no': 0}) # Fit the Decision Tree Classifier classifier = DecisionTreeClassifier(criterion='entropy') classifier.fit(X, y) # Plot the tree plt.figure(figsize=(20, 10))  # Adjust the size as needed plot_tree(classifier, filled=True, feature_names=X.columns, class_names=['no', 'yes'], rounded=True, fontsize=12) plt.show() #prog 9 import numpy as np import matplotlib.pyplot as plt from statsmodels.nonparametric.smoothers_lowess import lowess from math import pi # Generate sample data n = 100 x = np.linspace(0, 2 * pi, n) y = np.sin(x) + 0.3 * np.random.randn(n) # Apply LOWESS smoothed = lowess(y, x, frac=0.25, it=3) # Plot results plt.plot...

IT Lab

Click here 👉    IT Lab 1 - 3 Click here 👉    IT Lab 4 - 12