<jupyter_start><jupyter_text>Elongation<jupyter_code>from statsmodels.regression.linear_model import OLS

result = smf.ols(formula = 'elongation ~ layer_height + wall_thickness + infill_density + infill_pattern + nozzle_temperature + bed_temperature + print_speed + material + fan_speed', 
                 data = data).fit()
result.summary()
import seaborn as sns
from patsy import dmatrices

sns.pairplot(data[['layer_height', 'wall_thickness', 'infill_density', 'infill_pattern', 'nozzle_temperature','bed_temperature', 'print_speed', 'material', 'fan_speed']]);


from statsmodels.stats.outliers_influence import variance_inflation_factor

y, X = dmatrices('elongation ~ layer_height + wall_thickness + infill_density + infill_pattern + nozzle_temperature + bed_temperature + print_speed + material + fan_speed ', data, return_type = 'dataframe')

vif = pd.DataFrame()
vif["VIF Factor"] = [variance_inflation_factor(X.values, i) for i in range(X.shape[1])]
vif["features"] = X.columns 
vif<jupyter_output><empty_output><jupyter_text>다중 공선성 검사를 통해 10이상인 변수들 drop- material, nozzle_temperature, bed_temperature, fan_speed<jupyter_code>from statsmodels.regression.linear_model import OLS

result = smf.ols(formula = 'elongation ~ layer_height + wall_thickness + infill_density + infill_pattern + print_speed', data = data).fit()
result.summary()<jupyter_output><empty_output><jupyter_text>유의 확률 P>[t]를 보고, 0.05보다 작은 변수들을 유의미하다고 본다.p>[t]가 0.05보다 큰 변수들 drop- infill_pattern, print_speed<jupyter_code>result = smf.ols(formula = 'elongation ~ layer_height + infill_density + wall_thickness ', data = data).fit()
result.summary()
result = smf.ols(formula = 'elongation ~ layer_height  + wall_thickness', data = data).fit()
result.summary()
result = smf.ols(formula = 'elongation ~ layer_height + infill_density', data = data).fit()
result.summary()

sns.pairplot(data[['layer_height', 'wall_thickness']]);

sns.pairplot(data[['layer_height', 'infill_density']]);
y, X = dmatrices('elongation ~ layer_height +  wall_thickness ', data, return_type = 'dataframe')

vif = pd.DataFrame()
vif["VIF Factor"] = [variance_inflation_factor(X.values, i) for i in range(X.shape[1])]
vif["features"] = X.columns 
vif
from sklearn.pipeline import Pipeline
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import StandardScaler

data_pipeline = Pipeline([
    ('imputer', SimpleImputer(strategy="median")),
    ('std_scaler', StandardScaler()),
])
imputer = SimpleImputer(strategy="median")

error = np.array(error)
error =error.reshape(-1, 1)
error = imputer.fit_transform(error)
error_std = data_pipeline.fit_transform(error)

error_std


x = np.linspace(1,len(error), len(error))
pos_two = [2]*len(error)
neg_two = [-2]*len(error)
plt.plot(x, error_std,'bo', x, pos_two, 'r-', x, neg_two, 'r-')
plt.grid()
#save_fig('equal_var_test.png')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1362369337979094, 'fraction_numerical': 0.005226480836236934, 'mean_word_length': 6.822888283378747, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '568762', 'license': 'MIT', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1062, 'n_words': 201, 'path': 'feature analysis/data_elongation.ipynb', 'repo_name': 'klee30810/3DPrinting', 'size': '2870'}