<jupyter_start><jupyter_text>3DP Dissertation Experiments Fractional Factorial Experiments**Process Parameters:**- Layer Thickness (LH)- Print Speed (PS)- Infill Density (ID)- Raster Width (RW) - Infill Line Width in Cura- Wall Thickness (WT)  Load the needed Pakages- Add to the Conda environment- Packages below are on Google Colab by default<jupyter_code>import random
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import statsmodels.api as sm
import scipy.stats as stats


from statsmodels.formula.api import ols
from statsmodels.stats.anova import anova_lm
from scipy import stats

%matplotlib inline
PlotWidth = 6

import warnings
warnings.filterwarnings('ignore')<jupyter_output><empty_output><jupyter_text>Load Data Files- DOE Schedule- CR6 Results- SWX1 Results  Print Parameter Variables:- **lh_low** = Layer Thickness Lower Limit (mm)- **lh_hi** = Layer Thickness Upper Limit (mm)- **ps_low** = Print Speed Lower Limit (mm/s)- **ps_hi** = Print Speed Upper Limit (mm/s)- **id_low** = Infill Density Lower Limit (%)- **id_hi** = Infill Density Upper Limit (%)- **rw_low** = Raster Width Lower Limit (mm)- **rw_hi** = Raster Width Upper Limit (mm)- **wt_low** = Wall Thickness Lower Limit (mm)- **wt_hi** = Wall Thickness Upper Limit (mm)<jupyter_code>#@title Default title text
lh_low = .16 #@param {type:"number"}
lh_hi = .24 #@param {type:"number"}
ps_low = 50 #@param {type:"number"}
ps_hi = 60 #@param {type:"number"}
id_low = .25 #@param {type:"number"}
id_hi = .15 #@param {type:"number"}
rw_low = .4 #@param {type:"number"}
rw_hi = .8 #@param {type:"number"}
wt_low = 1.2 #@param {type:"number"}
wt_hi = .8 #@param {type:"number"}
# set some variables related to the coffee data set
actual_lows = { 'layer_thickness' : lh_low, 'print_speed' : ps_low, 'infill_density': id_low, 'raster_width': rw_low, 'wall_thickness': wt_low }
actual_highs = { 'layer_thickness' : lh_hi, 'print_speed' : ps_hi, 'infill_density': id_hi, 'raster_width': rw_hi, 'wall_thickness': wt_hi }
units = { 'layer_thickness' : 'mm', 'print_speed' : 'mm/s', 'infill_density': '%', 'raster_width': 'mm', 'wall_thickness': 'mm' }
columns = ['Trial Number', 'Layer Thickness', 'Print Speed', 'Infill Density', 'Raster Width', 'Wall Thickness','Cost','Time', 'Quality']
myDoE = pd.read_csv('https://raw.githubusercontent.com/wilsongis/3DP_Experiments/main/Data/doe-schedule.csv', skiprows=1, names=columns)

display(myDoE)
myDoE['Layer Thickness'] = myDoE['Layer Thickness'].replace([-1,1], [lh_low,lh_hi])
myDoE['Print Speed'] = myDoE['Print Speed'].replace([-1,1], [ps_low,ps_hi])
myDoE['Infill Density'] = myDoE['Infill Density'].replace([-1,1], [id_low,id_hi])
myDoE['Raster Width'] = myDoE['Raster Width'].replace([-1,1], [rw_low,rw_hi])
myDoE['Wall Thickness'] = myDoE['Wall Thickness'].replace([-1,1], [wt_low,wt_hi])
display(myDoE)<jupyter_output><empty_output><jupyter_text>CR6 SE Results<jupyter_code>cr6_results_pd = pd.read_csv('https://raw.githubusercontent.com/wilsongis/3DP_Experiments/main/Data/cr6_results.csv')
cr6_results_pd.head()
cr6_results_pd.describe()<jupyter_output><empty_output><jupyter_text>Cost per Run<jupyter_code>np.random.seed(1234)
cr6Stats=pd.DataFrame({'CCR6SE-Default.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE-Default.gcode'])),
                      'CCR6SE_Run2.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run2.gcode'])),
                      'CCR6SE_Run3.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run3.gcode'])),
                      'CCR6SE_Run4.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run4.gcode'])),
                      'CCR6SE_Run5.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run5.gcode'])),
                      'CCR6SE_Run6.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run6.gcode'])),
                      'CCR6SE_Run7.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run7.gcode'])),
                      'CCR6SE_Run8.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run8.gcode'])),
                      'CCR6SE_Run9.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run9.gcode'])),
                      'CCR6SE_Run10.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run10.gcode'])),
                      'CCR6SE_Run11.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run11.gcode'])),
                      'CCR6SE_Run12.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run12.gcode'])),
                      'CCR6SE_Run13.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run13.gcode'])),
                      'CCR6SE_Run14.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run14.gcode'])),
                      'CCR6SE_Run15.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run15.gcode'])),
                      'CCR6SE_Run16.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run16.gcode'])),
                      'CCR6SE_Run17.gcode':(list(cr6_results_pd['Used Filament Cost'][cr6_results_pd['File Name']=='CCR6SE_Run17.gcode']))
                     })
display(cr6Stats)
cr6Stats.describe()<jupyter_output><empty_output><jupyter_text>Cost Analysis<jupyter_code>y_cost = myDoE['Cost']
X = myDoE[['Layer Thickness', 'Print Speed', 'Infill Density', 'Raster Width', 'Wall Thickness']]

## An intercept is not added by default, so we need to add that here
X = sm.add_constant(X)
cost_results = sm.OLS(y_cost, X).fit()
cost_results.summary()

print(cost_results.summary())<jupyter_output>OLS Regression Results                            
==============================================================================
Dep. Variable:                   Cost   R-squared:                       0.609
Model:                            OLS   Adj. R-squared:                  0.445
Method:                 Least Squares   F-statistic:                     3.730
Date:                Sat, 22 May 2021   Prob (F-statistic):             0.0286
Time:                        19:59:24   Log-Likelihood:                 53.591
No. Observations:                  18   AIC:                            -95.18
Df Residuals:                      12   BIC:                            -89.84
Df Model:                           5                                         
Covariance Type:            nonrobust                                         
===================================================================================
                      coef    std err          [...]<jupyter_text>: p-value is more than 0.05 , So we can say that variances among groups are equal.<jupyter_code>F, p = stats.f_oneway(myDoE['Layer Thickness'],myDoE['Print Speed'],myDoE['Infill Density'],myDoE['Raster Width'],myDoE['Wall Thickness'])
print('F statistic =', F, 'p value :',p)<jupyter_output>F statistic = 2013.3540406868271 p value : 2.7314528895214388e-83<jupyter_text>Seeing if the overall model is significant<jupyter_code>F, p = stats.f_oneway(myDoE['Layer Thickness'],myDoE['Print Speed'],myDoE['Infill Density'],myDoE['Raster Width'],myDoE['Wall Thickness'])
# Seeing if the overall model is significant
print('F-Statistic=%.3f, p=%.3f' % (F, p))
df_melt = pd.melt(myDoE.reset_index(), id_vars=['index'], value_vars=['Layer Thickness', 'Print Speed', 'Infill Density', 'Raster Width', 'Wall Thickness'])
display(df_melt)<jupyter_output><empty_output><jupyter_text>Time Analysis<jupyter_code>y_time = myDoE['Time']
time_results = sm.OLS(y_time, X).fit()
time_results.summary()

print(time_results.summary())<jupyter_output>OLS Regression Results                            
==============================================================================
Dep. Variable:                   Time   R-squared:                       0.406
Model:                            OLS   Adj. R-squared:                  0.159
Method:                 Least Squares   F-statistic:                     1.643
Date:                Sat, 22 May 2021   Prob (F-statistic):              0.223
Time:                        19:59:24   Log-Likelihood:                -170.03
No. Observations:                  18   AIC:                             352.1
Df Residuals:                      12   BIC:                             357.4
Df Model:                           5                                         
Covariance Type:            nonrobust                                         
===================================================================================
                      coef    std err          [...]<jupyter_text>Quality Analysis<jupyter_code>y_qual = myDoE['Quality']
qual_results = sm.OLS(y_qual, X).fit()
qual_results.summary()

print(qual_results.summary())<jupyter_output>OLS Regression Results                            
==============================================================================
Dep. Variable:                Quality   R-squared:                        -inf
Model:                            OLS   Adj. R-squared:                   -inf
Method:                 Least Squares   F-statistic:                    -2.400
Date:                Sat, 22 May 2021   Prob (F-statistic):               1.00
Time:                        19:59:24   Log-Likelihood:                 608.09
No. Observations:                  18   AIC:                            -1204.
Df Residuals:                      12   BIC:                            -1199.
Df Model:                           5                                         
Covariance Type:            nonrobust                                         
===================================================================================
                      coef    std err          [...]
{'fraction_non_alphanumeric': 0.17618719889883, 'fraction_numerical': 0.0327401435453741, 'mean_word_length': 2.7548911037283133, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '214879', 'license': 'MIT', 'n_tokens_mistral': 3494, 'n_tokens_neox': 3199, 'n_words': 628, 'path': 'Backups/3DP Dissertation.ipynb', 'repo_name': 'wilsongis/3DP_Experiments', 'size': '10171'}